Refactoring validating size and height value.
--HG-- branch : develop
This commit is contained in:
parent
defbdb8e9c
commit
719598b97b
|
@ -505,17 +505,19 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
|||
parser.addPositionalArgument("filename", tr("The measurement file."));
|
||||
//-----
|
||||
QCommandLineOption heightOption(QStringList() << "e" << "height",
|
||||
tr("Open with the base height: 92, 98, 104, 110, 116, 122, 128, 134, 140, 146, 152, 158, 164, 170, 176, 182 or "
|
||||
"188 cm."), tr("The base height"));
|
||||
tr("Open with the base height. Vali values: %1cm.")
|
||||
.arg(VMeasurement::WholeListHeights(Unit::Cm).join(", ")),
|
||||
tr("The base height"));
|
||||
parser.addOption(heightOption);
|
||||
//-----
|
||||
QCommandLineOption sizeOption(QStringList() << "s" << "size",
|
||||
tr("Open with the base size: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54 or 56 cm."),
|
||||
tr("Open with the base size. Valid values: %1cm.").arg(VMeasurement::WholeListSizes(Unit::Cm).join(", ")),
|
||||
tr("The base size"));
|
||||
parser.addOption(sizeOption);
|
||||
//-----
|
||||
QCommandLineOption unitOption(QStringList() << "u" << "unit",
|
||||
tr("Set pattern file unit: cm, mm, inch."), tr("The pattern unit"));
|
||||
tr("Set pattern file unit: cm, mm, inch."),
|
||||
tr("The pattern unit"));
|
||||
parser.addOption(unitOption);
|
||||
//-----
|
||||
QCommandLineOption testOption(QStringList() << "test",
|
||||
|
@ -532,12 +534,8 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
|||
int height = 0;
|
||||
Unit unit = Unit::Cm;
|
||||
|
||||
{
|
||||
const QString heightValue = parser.value(heightOption);
|
||||
if (not heightValue.isEmpty())
|
||||
{
|
||||
const QStringList heights = VMeasurement::WholeListHeights(Unit::Cm);
|
||||
if (heights.contains(heightValue))
|
||||
if (VMeasurement::IsGradationHeightValid(heightValue))
|
||||
{
|
||||
flagHeight = true;
|
||||
height = heightValue.toInt();
|
||||
|
@ -545,19 +543,13 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
|||
else
|
||||
{
|
||||
qCCritical(mApp, "%s\n",
|
||||
qPrintable(tr("Invalid base height argument. Must be 92, 98, 104, 110, 116, 122, 128, 134, "
|
||||
"140, 146, 152, 158, 164, 170, 176, 182 or 188 cm.")));
|
||||
qPrintable(tr("Invalid base height argument. Must be %1cm.")
|
||||
.arg(VMeasurement::WholeListHeights(Unit::Cm).join(", "))));
|
||||
parser.showHelp(V_EX_USAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const QString sizeValue = parser.value(sizeOption);
|
||||
if (not sizeValue.isEmpty())
|
||||
{
|
||||
const QStringList sizes = VMeasurement::WholeListSizes(Unit::Cm);
|
||||
if (sizes.contains(sizeValue))
|
||||
if (VMeasurement::IsGradationSizeValid(sizeValue))
|
||||
{
|
||||
flagSize = true;
|
||||
size = sizeValue.toInt();
|
||||
|
@ -565,12 +557,10 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
|||
else
|
||||
{
|
||||
qCCritical(mApp, "%s\n",
|
||||
qPrintable(tr("Invalid base size argument. Must be 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, "
|
||||
"42, 44, 46, 48, 50, 52, 54 or 56 cm.")));
|
||||
qPrintable(tr("Invalid base size argument. Must be %1cm.")
|
||||
.arg(VMeasurement::WholeListSizes(Unit::Cm).join(", "))));
|
||||
parser.showHelp(V_EX_USAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const QString unitValue = parser.value(unitOption);
|
||||
|
|
Loading…
Reference in New Issue
Block a user