diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index aaf9cb906..7af004942 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -64,7 +64,7 @@ getSwapChoices( const QVariantMap& configurationMap ) for ( const auto& item : l ) { bool ok = false; - auto v = PartitionActions::Choices::nameToChoice( item, ok ); + auto v = PartitionActions::Choices::swapChoiceNames().find( item, ok ); if ( ok ) { choices.insert( v ); @@ -105,7 +105,8 @@ getSwapChoices( const QVariantMap& configurationMap ) #define COMPLAIN_UNSUPPORTED( x ) \ if ( choices.contains( x ) ) \ { \ - cWarning() << unsupportedSetting << PartitionActions::Choices::choiceToName( x ); \ + bool bogus = false; \ + cWarning() << unsupportedSetting << PartitionActions::Choices::swapChoiceNames().find( x, bogus ); \ choices.remove( x ); \ } diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 0c7ed6e6d..dc4d4eeb4 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -257,8 +257,8 @@ doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition namespace Choices { -static const NamedEnumTable< SwapChoice >& -nameTable() +const NamedEnumTable< SwapChoice >& +swapChoiceNames() { static const NamedEnumTable< SwapChoice > names { { QStringLiteral( "none" ), SwapChoice::NoSwap }, { QStringLiteral( "small" ), SwapChoice::SmallSwap }, @@ -269,19 +269,6 @@ nameTable() return names; } -SwapChoice -nameToChoice( QString name, bool& ok ) -{ - return nameTable().find( name, ok ); -} - -QString -choiceToName( SwapChoice c ) -{ - bool ok = false; - return nameTable().find( c, ok ); -} - SwapChoice pickOne( const SwapChoiceSet& s ) { diff --git a/src/modules/partition/core/PartitionActions.h b/src/modules/partition/core/PartitionActions.h index 558ccb4b9..706fbaea3 100644 --- a/src/modules/partition/core/PartitionActions.h +++ b/src/modules/partition/core/PartitionActions.h @@ -19,6 +19,8 @@ #ifndef PARTITIONACTIONS_H #define PARTITIONACTIONS_H +#include "utils/NamedEnum.h" + #include #include @@ -34,7 +36,7 @@ namespace PartitionActions */ namespace Choices { -/** @brief Ccchoice of swap (size and type) */ +/** @brief Choice of swap (size and type) */ enum SwapChoice { NoSwap, // don't create any swap, don't use any @@ -45,8 +47,7 @@ enum SwapChoice }; using SwapChoiceSet = QSet< SwapChoice >; -SwapChoice nameToChoice( QString name, bool& ok ); -QString choiceToName( SwapChoice ); +const NamedEnumTable< SwapChoice >& swapChoiceNames(); /** @brief Given a set of swap choices, return a sensible value from it. *