[partition] Use new NamedEnum approach

main
Adriaan de Groot 6 years ago
parent 9c2a6b03e4
commit 194f693412

@ -35,6 +35,7 @@
#include "CalamaresVersion.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/Retranslator.h"
#include "widgets/WaitingWidget.h"
#include "GlobalStorage.h"
@ -474,25 +475,17 @@ PartitionViewStep::onLeave()
static PartitionActions::Choices::SwapChoice
nameToChoice( QString name, bool& ok )
{
ok = false;
name = name.toLower();
using namespace PartitionActions::Choices;
// Each return here first sets ok to true, returns enum value
if ( name == QStringLiteral( "none" ) )
return( ok=true, SwapChoice::NoSwap );
else if ( name == QStringLiteral( "small" ) )
return( ok=true, SwapChoice::SmallSwap);
else if ( name == QStringLiteral( "suspend" ) )
return( ok=true, SwapChoice::FullSwap );
else if ( name == QStringLiteral( "reuse" ) )
return( ok=true, SwapChoice::ReuseSwap );
else if ( name == QStringLiteral( "file" ) )
return( ok=true, SwapChoice::SwapFile );
ok = false;
return SwapChoice::NoSwap;
static const NamedEnumTable<SwapChoice> names {
{ QStringLiteral( "none" ), SwapChoice::NoSwap },
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
{ QStringLiteral( "file" ), SwapChoice::SwapFile }
};
return names.find( name, ok );
}

Loading…
Cancel
Save