[partition] Use new NamedEnum approach
This commit is contained in:
parent
9c2a6b03e4
commit
194f693412
@ -35,6 +35,7 @@
|
|||||||
#include "CalamaresVersion.h"
|
#include "CalamaresVersion.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "widgets/WaitingWidget.h"
|
#include "widgets/WaitingWidget.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
@ -474,25 +475,17 @@ PartitionViewStep::onLeave()
|
|||||||
static PartitionActions::Choices::SwapChoice
|
static PartitionActions::Choices::SwapChoice
|
||||||
nameToChoice( QString name, bool& ok )
|
nameToChoice( QString name, bool& ok )
|
||||||
{
|
{
|
||||||
ok = false;
|
|
||||||
name = name.toLower();
|
|
||||||
|
|
||||||
using namespace PartitionActions::Choices;
|
using namespace PartitionActions::Choices;
|
||||||
|
|
||||||
// Each return here first sets ok to true, returns enum value
|
static const NamedEnumTable<SwapChoice> names {
|
||||||
if ( name == QStringLiteral( "none" ) )
|
{ QStringLiteral( "none" ), SwapChoice::NoSwap },
|
||||||
return( ok=true, SwapChoice::NoSwap );
|
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
|
||||||
else if ( name == QStringLiteral( "small" ) )
|
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
|
||||||
return( ok=true, SwapChoice::SmallSwap);
|
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
|
||||||
else if ( name == QStringLiteral( "suspend" ) )
|
{ QStringLiteral( "file" ), SwapChoice::SwapFile }
|
||||||
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 names.find( name, ok );
|
||||||
return SwapChoice::NoSwap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user