Keep order of options.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-11-09 17:23:15 +02:00
parent e7e177898c
commit 01a23b5e08
2 changed files with 88 additions and 92 deletions

View File

@ -66,17 +66,19 @@ const static auto SINGLE_OPTION_GRADATIONHEIGHT = QStringLiteral("e");
#define translate(context, source) QCoreApplication::translate((context), (source))
//---------------------------------------------------------------------------------------------------------------------
VCommandLine::VCommandLine() : parser(), optionsUsed(InitOptionsUsed()), isGuiEnabled(false)
VCommandLine::VCommandLine() : parser(), optionsUsed(), optionsIndex(), isGuiEnabled(false)
{
parser.setApplicationDescription(translate("VCommandLine", "Pattern making program."));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("filename", translate("VCommandLine", "Pattern file."));
QMap<QString, QCommandLineOption *>::const_iterator i = optionsUsed.constBegin();
InitOptions(optionsUsed, optionsIndex);
VCommandLineOptions::const_iterator i = optionsUsed.constBegin();
while (i != optionsUsed.constEnd())
{
parser.addOption(*i.value());
parser.addOption(*((*i)));
++i;
}
}
@ -94,45 +96,44 @@ qreal VCommandLine::Pg2Px(const QString& src, const DialogLayoutSettings& conver
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, QCommandLineOption *> VCommandLine::InitOptionsUsed()
void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int> &optionsIndex)
{
QMap<QString, QCommandLineOption *> options;
int index = 0;
//keep in mind order here - that is how user will see it, so group-up for usability
//=================================================================================================================
options.insert(LONG_OPTION_BASENAME,
new QCommandLineOption(QStringList() << SINGLE_OPTION_BASENAME << LONG_OPTION_BASENAME,
optionsIndex.insert(LONG_OPTION_BASENAME, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_BASENAME << LONG_OPTION_BASENAME,
translate("VCommandLine", "The base filename of exported layout files. Use "
"it to enable console export mode."),
translate("VCommandLine", "The base filename of layout files")));
options.insert(LONG_OPTION_DESTINATION,
new QCommandLineOption(QStringList() << SINGLE_OPTION_DESTINATION << LONG_OPTION_DESTINATION,
optionsIndex.insert(LONG_OPTION_DESTINATION, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_DESTINATION << LONG_OPTION_DESTINATION,
translate("VCommandLine", "The path to output destination folder."),
translate("VCommandLine", "The destination folder")));
options.insert(LONG_OPTION_MEASUREFILE,
new QCommandLineOption(QStringList() << SINGLE_OPTION_MEASUREFILE << LONG_OPTION_MEASUREFILE,
optionsIndex.insert(LONG_OPTION_MEASUREFILE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_MEASUREFILE << LONG_OPTION_MEASUREFILE,
translate("VCommandLine", "Path to custom measure file (export mode)."),
translate("VCommandLine", "The measure file")));
options.insert(LONG_OPTION_EXP2FORMAT,
new QCommandLineOption(QStringList() << SINGLE_OPTION_EXP2FORMAT << LONG_OPTION_EXP2FORMAT,
optionsIndex.insert(LONG_OPTION_EXP2FORMAT, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_EXP2FORMAT << LONG_OPTION_EXP2FORMAT,
translate("VCommandLine", "Number corresponding to output format (default = "
"0, export mode): ") +
DialogSaveLayout::MakeHelpFormatList(),
translate("VCommandLine", "Format number"), "0"));
options.insert(LONG_OPTION_GRADATIONSIZE,
new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
translate("VCommandLine", "Set size value a pattern file, that was opened "
"with standard measurements (export mode). Valid "
"values: %1cm.")
.arg(VMeasurement::WholeListSizes(Unit::Cm).join(", ")),
translate("VCommandLine", "The size value")));
options.insert(LONG_OPTION_GRADATIONHEIGHT,
new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONHEIGHT << LONG_OPTION_GRADATIONHEIGHT,
optionsIndex.insert(LONG_OPTION_GRADATIONHEIGHT, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONHEIGHT << LONG_OPTION_GRADATIONHEIGHT,
translate("VCommandLine", "Set height value a pattern file, that was opened "
"with standard measurements (export mode). Valid "
"values: %1cm.")
@ -140,91 +141,86 @@ QMap<QString, QCommandLineOption *> VCommandLine::InitOptionsUsed()
translate("VCommandLine", "The height value")));
//=================================================================================================================
options.insert(LONG_OPTION_PAGETEMPLATE,
new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGETEMPLATE << LONG_OPTION_PAGETEMPLATE,
optionsIndex.insert(LONG_OPTION_PAGETEMPLATE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGETEMPLATE << LONG_OPTION_PAGETEMPLATE,
translate("VCommandLine", "Number corresponding to page template (default = "
"0, export mode): ") +
DialogLayoutSettings::MakeHelpTemplateList(),
translate("VCommandLine", "Template number"), "0"));
options.insert(LONG_OPTION_PAGEW,
new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEW << LONG_OPTION_PAGEW,
optionsIndex.insert(LONG_OPTION_PAGEW, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEW << LONG_OPTION_PAGEW,
translate("VCommandLine", "Page width in current units like 12.0 (cannot be "
"used with \"%1\", export mode).")
.arg(LONG_OPTION_PAGETEMPLATE),
translate("VCommandLine", "The page width")));
options.insert(LONG_OPTION_PAGEH,
new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEH << LONG_OPTION_PAGEH,
optionsIndex.insert(LONG_OPTION_PAGEH, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEH << LONG_OPTION_PAGEH,
translate("VCommandLine", "Page height in current units like 12.0 (cannot "
"be used with \"%1\", export mode).")
.arg(LONG_OPTION_PAGETEMPLATE),
("The page height")));
options.insert(LONG_OPTION_PAGEUNITS,
new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEUNITS << LONG_OPTION_PAGEUNITS,
optionsIndex.insert(LONG_OPTION_PAGEUNITS, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEUNITS << LONG_OPTION_PAGEUNITS,
translate("VCommandLine", "Page height/width measure units (cannot be used "
"with \"%1\", export mode): ")
.arg(LONG_OPTION_PAGETEMPLATE) + VDomDocument::UnitsHelpString(),
translate("VCommandLine", "The measure unit")));
//=================================================================================================================
options.insert(LONG_OPTION_ROTATE,
new QCommandLineOption(QStringList() << SINGLE_OPTION_ROTATE << LONG_OPTION_ROTATE,
optionsIndex.insert(LONG_OPTION_ROTATE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_ROTATE << LONG_OPTION_ROTATE,
translate("VCommandLine", "Rotation in degrees (one of predefined). Default "
"(or 0) is no-rotate (export mode)."),
translate("VCommandLine", "Angle")));
options.insert(LONG_OPTION_CROP,
new QCommandLineOption(QStringList() << SINGLE_OPTION_CROP << LONG_OPTION_CROP,
optionsIndex.insert(LONG_OPTION_CROP, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_CROP << LONG_OPTION_CROP,
translate("VCommandLine", "Auto crop unused length (export mode).")));
options.insert(LONG_OPTION_UNITE,
new QCommandLineOption(QStringList() << SINGLE_OPTION_UNITE << LONG_OPTION_UNITE,
optionsIndex.insert(LONG_OPTION_UNITE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_UNITE << LONG_OPTION_UNITE,
translate("VCommandLine", "Unite pages if possible (export mode).")));
//=================================================================================================================
options.insert(LONG_OPTION_SAVELENGTH,
new QCommandLineOption(QStringList() << SINGLE_OPTION_SAVELENGTH << LONG_OPTION_SAVELENGTH,
optionsIndex.insert(LONG_OPTION_SAVELENGTH, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_SAVELENGTH << LONG_OPTION_SAVELENGTH,
translate("VCommandLine",
"Save length of the sheet if set. (export mode).")));
options.insert(LONG_OPTION_SHIFTUNITS,
new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTUNITS << LONG_OPTION_SHIFTUNITS,
optionsIndex.insert(LONG_OPTION_SHIFTUNITS, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTUNITS << LONG_OPTION_SHIFTUNITS,
translate("VCommandLine",
"Layout units (as paper's one except px, export mode)."),
translate("VCommandLine", "The unit")));
options.insert(LONG_OPTION_SHIFTLENGTH,
new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTLENGTH << LONG_OPTION_SHIFTLENGTH,
optionsIndex.insert(LONG_OPTION_SHIFTLENGTH, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTLENGTH << LONG_OPTION_SHIFTLENGTH,
translate("VCommandLine", "Shift layout length measured in layout units "
"(export mode)."),
translate("VCommandLine", "Shift length")));
options.insert(LONG_OPTION_GAPWIDTH,
new QCommandLineOption(QStringList() << SINGLE_OPTION_GAPWIDTH << LONG_OPTION_GAPWIDTH,
optionsIndex.insert(LONG_OPTION_GAPWIDTH, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GAPWIDTH << LONG_OPTION_GAPWIDTH,
translate("VCommandLine",
"Gap width x2, measured in layout units. (export mode)."),
translate("VCommandLine", "The gap width")));
options.insert(LONG_OPTION_GROUPPING,
new QCommandLineOption(QStringList() << SINGLE_OPTION_GROUPPING << LONG_OPTION_GROUPPING,
optionsIndex.insert(LONG_OPTION_GROUPPING, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GROUPPING << LONG_OPTION_GROUPPING,
translate("VCommandLine", "Sets layout groupping (export mode): ")
+ DialogLayoutSettings::MakeGroupsHelp(),
translate("VCommandLine", "Grouping type"), "2"));
options.insert(LONG_OPTION_TEST,
new QCommandLineOption(QStringList() << SINGLE_OPTION_TEST << LONG_OPTION_TEST,
optionsIndex.insert(LONG_OPTION_TEST, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_TEST << LONG_OPTION_TEST,
translate("VCommandLine", "Run the program in a test mode. The program this "
"mode load a single pattern file and silently "
"quit without showing the main window. The key "
"have priority before key '%1'.")
.arg(LONG_OPTION_BASENAME)));
return options;
}
//------------------------------------------------------------------------------------------------------
@ -237,11 +233,11 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool x = parser.isSet(*optionsUsed.value(LONG_OPTION_PAGETEMPLATE));
bool x = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGETEMPLATE)));
bool a = parser.isSet(*optionsUsed.value(LONG_OPTION_PAGEH));
bool b = parser.isSet(*optionsUsed.value(LONG_OPTION_PAGEW));
bool c = parser.isSet(*optionsUsed.value(LONG_OPTION_PAGEUNITS));
bool a = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEH)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEW)));
bool c = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)));
if ((a || b || c) && x)
{
@ -260,8 +256,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool a = parser.isSet(*optionsUsed.value(LONG_OPTION_SHIFTLENGTH));
bool b = parser.isSet(*optionsUsed.value(LONG_OPTION_SHIFTUNITS));
bool a = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTLENGTH)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTUNITS)));
if ((a || b) && !(a && b))
{
@ -272,8 +268,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool a = parser.isSet(*optionsUsed.value(LONG_OPTION_GAPWIDTH));
bool b = parser.isSet(*optionsUsed.value(LONG_OPTION_SHIFTUNITS));
bool a = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GAPWIDTH)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTUNITS)));
if ((a || b) && !(a && b))
{
@ -302,46 +298,44 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
if (parser.isSet(*optionsUsed.value(LONG_OPTION_PAGEH))) //at this point we already sure 3 are set or none
{
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEH))))
{ //at this point we already sure 3 are set or none
if (!diag.SelectPaperUnit(parser.value(*optionsUsed.value(LONG_OPTION_PAGEUNITS))))
if (!diag.SelectPaperUnit(parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)))))
{
qCritical() << translate("VCommandLine", "Unsupported paper units.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
diag.SetPaperHeight (Pg2Px(parser.value(*optionsUsed.value(LONG_OPTION_PAGEH)), diag));
diag.SetPaperWidth (Pg2Px(parser.value(*optionsUsed.value(LONG_OPTION_PAGEW)), diag));
diag.SetPaperHeight (Pg2Px(parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEH))), diag));
diag.SetPaperWidth (Pg2Px(parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEW))), diag));
}
if (parser.isSet(*optionsUsed.value(LONG_OPTION_SHIFTUNITS)))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTUNITS))))
{
if (!diag.SelectLayoutUnit(parser.value(*optionsUsed.value(LONG_OPTION_SHIFTUNITS))))
if (!diag.SelectLayoutUnit(parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTUNITS)))))
{
qCritical() << translate("VCommandLine", "Unsupported layout units.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
if (parser.isSet(*optionsUsed.value(LONG_OPTION_SHIFTLENGTH)))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTLENGTH))))
{
diag.SetShift(Lo2Px(parser.value(*optionsUsed.value(LONG_OPTION_SHIFTLENGTH)), diag));
diag.SetShift(Lo2Px(parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SHIFTLENGTH))), diag));
}
if (parser.isSet(*optionsUsed.value(LONG_OPTION_GAPWIDTH)))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GAPWIDTH))))
{
diag.SetLayoutWidth(Lo2Px(parser.value(*optionsUsed.value(LONG_OPTION_GAPWIDTH)), diag));
diag.SetLayoutWidth(Lo2Px(parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GAPWIDTH))), diag));
}
diag.SetAutoCrop(parser.isSet(*optionsUsed.value(LONG_OPTION_CROP)));
diag.SetUnitePages(parser.isSet(*optionsUsed.value(LONG_OPTION_UNITE)));
diag.SetSaveLength(parser.isSet(*optionsUsed.value(LONG_OPTION_SAVELENGTH)));
diag.SetAutoCrop(parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_CROP))));
diag.SetUnitePages(parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_UNITE))));
diag.SetSaveLength(parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_SAVELENGTH))));
diag.SetGroup(OptGroup());
diag.DialogAccepted(); // filling VLayoutGenerator
return res;
@ -378,7 +372,7 @@ void VCommandLine::Reset()
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsTestModeEnabled() const
{
const bool r = parser.isSet(*optionsUsed.value(LONG_OPTION_TEST));
const bool r = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_TEST)));
if (r && parser.positionalArguments().size() != 1)
{
qCritical() << translate("VCommandLine", "Test option can be used with single input file only.") << "/n";
@ -390,7 +384,7 @@ bool VCommandLine::IsTestModeEnabled() const
//------------------------------------------------------------------------------------------------------
bool VCommandLine::IsExportEnabled() const
{
const bool r = parser.isSet(*optionsUsed.value(LONG_OPTION_BASENAME));
const bool r = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BASENAME)));
if (r && parser.positionalArguments().size() != 1)
{
qCritical() << translate("VCommandLine", "Export options can be used with single input file only.") << "/n";
@ -403,9 +397,9 @@ bool VCommandLine::IsExportEnabled() const
DialogLayoutSettings::PaperSizeTemplate VCommandLine::OptPaperSize() const
{
int ppsize = 0;
if (parser.isSet(*optionsUsed.value(LONG_OPTION_PAGETEMPLATE)))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGETEMPLATE))))
{
ppsize = parser.value(*optionsUsed.value(LONG_OPTION_PAGETEMPLATE)).toInt();
ppsize = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGETEMPLATE))).toInt();
}
return static_cast<DialogLayoutSettings::PaperSizeTemplate>(ppsize);
}
@ -414,9 +408,9 @@ DialogLayoutSettings::PaperSizeTemplate VCommandLine::OptPaperSize() const
int VCommandLine::OptRotation() const
{
int rotate = 0;
if (parser.isSet(*optionsUsed.value(LONG_OPTION_ROTATE)))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_ROTATE))))
{
rotate = parser.value(*optionsUsed.value(LONG_OPTION_ROTATE)).toInt();
rotate = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_ROTATE))).toInt();
}
return rotate;
@ -425,7 +419,7 @@ int VCommandLine::OptRotation() const
//------------------------------------------------------------------------------------------------------
Cases VCommandLine::OptGroup() const
{
int r = parser.value(*optionsUsed.value(LONG_OPTION_GROUPPING)).toInt();
int r = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GROUPPING))).toInt();
if ( r < 0 || r >= static_cast<int>(Cases::UnknownCase))
{
r = 0;
@ -437,11 +431,11 @@ Cases VCommandLine::OptGroup() const
QString VCommandLine::OptMeasurePath() const
{
QString measure;
if (parser.isSet(*optionsUsed.value(LONG_OPTION_MEASUREFILE))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_MEASUREFILE)))
&& IsExportEnabled() //todo: don't want yet to allow user set measure file for general loading, because need to fix multiply opened windows as well
)
{
measure = parser.value(*optionsUsed.value(LONG_OPTION_MEASUREFILE));
measure = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_MEASUREFILE)));
}
return measure;
@ -453,7 +447,7 @@ QString VCommandLine::OptBaseName() const
QString path;
if (IsExportEnabled())
{
path = parser.value(*optionsUsed.value(LONG_OPTION_BASENAME));
path = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BASENAME)));
}
return path;
@ -465,7 +459,7 @@ QString VCommandLine::OptDestinationPath() const
QString path;
if (IsExportEnabled())
{
path = parser.value(*optionsUsed.value(LONG_OPTION_DESTINATION));
path = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_DESTINATION)));
}
return path;
@ -475,9 +469,9 @@ QString VCommandLine::OptDestinationPath() const
int VCommandLine::OptExportType() const
{
int r = 0;
if (parser.isSet(*optionsUsed.value(LONG_OPTION_EXP2FORMAT)))
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_EXP2FORMAT))))
{
r = parser.value(*optionsUsed.value(LONG_OPTION_EXP2FORMAT)).toInt();
r = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_EXP2FORMAT))).toInt();
}
return r;
}
@ -497,19 +491,19 @@ bool VCommandLine::IsGuiEnabled() const
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetGradationSize() const
{
return parser.isSet(*optionsUsed.value(LONG_OPTION_GRADATIONSIZE));
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GRADATIONSIZE)));
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetGradationHeight() const
{
return parser.isSet(*optionsUsed.value(LONG_OPTION_GRADATIONHEIGHT));
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GRADATIONHEIGHT)));
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptGradationSize() const
{
const QString size = parser.value(*optionsUsed.value(LONG_OPTION_GRADATIONSIZE));
const QString size = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GRADATIONSIZE)));
if (VMeasurement::IsGradationSizeValid(size))
{
return size;
@ -524,7 +518,7 @@ QString VCommandLine::OptGradationSize() const
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptGradationHeight() const
{
const QString height = parser.value(*optionsUsed.value(LONG_OPTION_GRADATIONHEIGHT));
const QString height = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_GRADATIONHEIGHT)));
if (VMeasurement::IsGradationHeightValid(height))
{
return height;

View File

@ -17,6 +17,7 @@
class VCommandLine;
typedef std::shared_ptr<VCommandLine> VCommandLinePtr;
typedef QList<QCommandLineOption *> VCommandLineOptions;
//@brief: class used to install export command line options and parse their values
//QCommandLineParser* object must exists until this object alive
@ -81,14 +82,15 @@ private:
Q_DISABLE_COPY(VCommandLine)
static VCommandLinePtr instance;
QCommandLineParser parser;
QMap<QString, QCommandLineOption *> optionsUsed;
VCommandLineOptions optionsUsed;
QMap<QString, int> optionsIndex;
bool isGuiEnabled;
friend class VApplication;
static qreal Lo2Px(const QString& src, const DialogLayoutSettings& converter);
static qreal Pg2Px(const QString& src, const DialogLayoutSettings& converter);
static QMap<QString, QCommandLineOption *> InitOptionsUsed();
static void InitOptions(VCommandLineOptions &options, QMap<QString, int> &optionsIndex);
};
#endif // VCMDEXPORT_H