[tracking] Switch setTrackingLevel() to use enum

main
Adriaan de Groot 5 years ago
parent 6d744374db
commit fd2853b2cf

@ -172,34 +172,28 @@ TrackingPage::setGeneralPolicy( QString url )
}
void
TrackingPage::setTrackingLevel( const QString& l )
TrackingPage::setTrackingLevel( TrackingType t )
{
QString level = l.toLower();
QRadioButton* button = nullptr;
if ( level.isEmpty() || level == "none" )
switch( t )
{
button = ui->noneRadio;
}
else if ( level == "install" )
{
button = ui->installRadio;
}
else if ( level == "machine" )
{
button = ui->machineRadio;
}
else if ( level == "user" )
{
button = ui->userRadio;
case TrackingType::NoTracking:
button = ui->noneRadio;
break;
case TrackingType::InstallTracking:
button = ui->installRadio;
break;
case TrackingType::MachineTracking:
button = ui->machineRadio;
break;
case TrackingType::UserTracking:
button = ui->userRadio;
break;
}
if ( button != nullptr )
{
button->setChecked( true );
}
else
{
cWarning() << "unknown default tracking level" << l;
}
}

@ -35,7 +35,8 @@ class TrackingPage : public QWidget
public:
explicit TrackingPage( QWidget* parent = nullptr );
/**
/** @brief Set initial state for each option
*
* Enables or disables the tracking-option block for the given
* tracking option @p t, and sets the initial state of the
* checkbox to the @p user default.
@ -43,19 +44,20 @@ public:
* Call this in ascending order of tracking type.
*/
void enableTrackingOption( TrackingType t, bool enabled );
/**
/** @brief Is the given tracking type enabled?
*
* Returns whether tracking type @p is selected by the user
* (i.e. is the radio button for that level, or for a higher
* tracking level, enabled).
*/
bool getTrackingOption( TrackingType t );
/* URL for given level @p t */
///@brief Set URL for given level @p t
void setTrackingPolicy( TrackingType t, QString url );
/* URL for the global link */
///@brief Set URL for the global link
void setGeneralPolicy( QString url );
/* Select one of the four levels by name */
void setTrackingLevel( const QString& level );
///@brief Select one of the four levels by name
void setTrackingLevel( TrackingType t );
private:
Ui::TrackingPage* ui;

@ -187,7 +187,12 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) );
m_widget->setTrackingLevel( CalamaresUtils::getString( configurationMap, "default" ) );
bool ok;
m_widget->setTrackingLevel( trackingNames().find(CalamaresUtils::getString( configurationMap, "default" ), ok ) );
if ( !ok )
{
cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" );
}
}
const NamedEnumTable< TrackingType >&

Loading…
Cancel
Save