From 6d744374db5ac64fc538f89412eb91f4798187b0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 12 May 2020 11:22:25 +0200 Subject: [PATCH] [tracking] Use enum-conveniences --- src/modules/tracking/TrackingType.h | 12 +++++++++--- src/modules/tracking/TrackingViewStep.cpp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/modules/tracking/TrackingType.h b/src/modules/tracking/TrackingType.h index 02dbd934e..04e8d2ebe 100644 --- a/src/modules/tracking/TrackingType.h +++ b/src/modules/tracking/TrackingType.h @@ -19,11 +19,17 @@ #ifndef TRACKINGTYPE_H #define TRACKINGTYPE_H +#include "utils/NamedEnum.h" + enum class TrackingType { - InstallTracking, - MachineTracking, - UserTracking + NoTracking, // Do not enable tracking at all + InstallTracking, // Track that *this* install has happened + MachineTracking, // Track the machine, ongoing + UserTracking // Track the user, ongoing }; +// Implemented in TrackingViewStep.cpp +const NamedEnumTable< TrackingType >& trackingNames(); + #endif //TRACKINGTYPE_H diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index a51864ea9..2cb97f079 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -189,3 +189,20 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); m_widget->setTrackingLevel( CalamaresUtils::getString( configurationMap, "default" ) ); } + +const NamedEnumTable< TrackingType >& +trackingNames() +{ + // *INDENT-OFF* + // clang-format off + static const NamedEnumTable< TrackingType > names { + { QStringLiteral( "none" ), TrackingType::NoTracking }, + { QStringLiteral( "install" ), TrackingType::InstallTracking }, + { QStringLiteral( "machine" ), TrackingType::MachineTracking }, + { QStringLiteral( "user" ), TrackingType::UserTracking } + }; + // clang-format on + // *INDENT-ON* + + return names; +}