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

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

@ -187,7 +187,12 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); 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 >& const NamedEnumTable< TrackingType >&

Loading…
Cancel
Save