Simplify calls to QCommandLineParser::addOption.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-04-05 17:20:22 +03:00
parent 83e61a85a8
commit e04e4907b5
2 changed files with 161 additions and 361 deletions

View file

@ -58,7 +58,7 @@ qreal Pg2Px(const QString& src, const DialogLayoutSettings& converter)
} // anonymous namespace } // anonymous namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCommandLine::VCommandLine() : parser(), optionsUsed(), isGuiEnabled(false) VCommandLine::VCommandLine() : parser(), isGuiEnabled(false)
{ {
parser.setApplicationDescription(translate("VCommandLine", "Pattern making program.")); parser.setApplicationDescription(translate("VCommandLine", "Pattern making program."));
parser.addHelpOption(); parser.addHelpOption();
@ -567,362 +567,186 @@ void VCommandLine::InitCommandLineOptions()
{ {
//keep in mind order here - that is how user will see it, so group-up for usability //keep in mind order here - that is how user will see it, so group-up for usability
//================================================================================================================= //=================================================================================================================
VCommandLineOption option = parser.addOptions({
VCommandLineOption(QStringList({SINGLE_OPTION_BASENAME, LONG_OPTION_BASENAME}), {{SINGLE_OPTION_BASENAME, LONG_OPTION_BASENAME},
translate("VCommandLine", "The base filename of exported layout files. Use it to " translate("VCommandLine", "The base filename of exported layout files. Use it to enable console export mode."),
"enable console export mode."), translate("VCommandLine", "The base filename of layout files")},
translate("VCommandLine", "The base filename of layout files")); {{SINGLE_OPTION_DESTINATION, LONG_OPTION_DESTINATION},
optionsUsed.insert(LONG_OPTION_BASENAME, option); translate("VCommandLine", "The path to output destination folder. By default the directory at which the "
parser.addOption(option); "application was started."),
translate("VCommandLine", "The destination folder")},
option = VCommandLineOption(QStringList({SINGLE_OPTION_DESTINATION, LONG_OPTION_DESTINATION}), {{SINGLE_OPTION_MEASUREFILE, LONG_OPTION_MEASUREFILE},
translate("VCommandLine", "The path to output destination folder. By default the " translate("VCommandLine", "Path to custom measure file (export mode)."),
"directory at which the application was started."), translate("VCommandLine", "The measure file")},
translate("VCommandLine", "The destination folder")); {{SINGLE_OPTION_NESTING_TIME, LONG_OPTION_NESTING_TIME},
optionsUsed.insert(LONG_OPTION_DESTINATION, option); translate("VCommandLine", "<Time> in minutes given for the algorithm to find best layout. Time must be in "
parser.addOption(option); "range from 1 minute to 60 minutes. Default value 1 minute."),
translate("VCommandLine", "Time")},
option = VCommandLineOption(QStringList({SINGLE_OPTION_MEASUREFILE, LONG_OPTION_MEASUREFILE}), {LONG_OPTION_EFFICIENCY_COEFFICIENT,
translate("VCommandLine", "Path to custom measure file (export mode)."), translate("VCommandLine", "Set layout efficiency <coefficient>. Layout efficiency coefficient is the ratio of "
translate("VCommandLine", "The measure file")); "the area occupied by the pieces to the bounding rect of all pieces. If nesting reaches required level the "
optionsUsed.insert(LONG_OPTION_MEASUREFILE, option); "process stops. If value is 0 no check will be made. Сoefficient must be in range from 0 to 100. Default "
parser.addOption(option); "value 0."),
translate("VCommandLine", "Coefficient")},
option = VCommandLineOption(QStringList({SINGLE_OPTION_NESTING_TIME, LONG_OPTION_NESTING_TIME}), {{SINGLE_OPTION_EXP2FORMAT, LONG_OPTION_EXP2FORMAT},
translate("VCommandLine", "<Time> in minutes given for the algorithm to find best " translate("VCommandLine", "Number corresponding to output format (default = 0, export mode):") +
"layout. Time must be in range from 1 minute to 60 " DialogSaveLayout::MakeHelpFormatList(),
"minutes. Default value 1 minute."), translate("VCommandLine", "Format number"), QChar('0')},
translate("VCommandLine", "Time")); {LONG_OPTION_BINARYDXF, translate("VCommandLine", "Export dxf in binary form.")},
optionsUsed.insert(LONG_OPTION_NESTING_TIME, option); {LONG_OPTION_TEXT2PATHS, translate("VCommandLine", "Export text as paths.")},
parser.addOption(option); {LONG_OPTION_EXPORTONLYDETAILS,
translate("VCommandLine", "Export only details. Export details as they positioned in the details mode. Any "
option = VCommandLineOption(LONG_OPTION_EFFICIENCY_COEFFICIENT, "layout related options will be ignored.")},
translate("VCommandLine", "Set layout efficiency <coefficient>. Layout efficiency " {LONG_OPTION_EXPORTSUCHDETAILS,
"coefficient is the ratio of the area occupied by the pieces " translate("VCommandLine", "Export only details that match a piece name regex."),
"to the bounding rect of all pieces. If nesting reaches " translate("VCommandLine", "The name regex")},
"required level the process stops. If value is 0 no check " {{SINGLE_OPTION_GRADATIONSIZE, LONG_OPTION_GRADATIONSIZE},
"will be made. Сoefficient must be in range from 0 to 100. " translate("VCommandLine", "Set size value for pattern file, that was opened with multisize measurements "
"Default value 0."), "(export mode). Valid values: %1cm.").arg(VMeasurement::WholeListSizes(Unit::Cm) .join(QStringLiteral(", "))),
translate("VCommandLine", "Coefficient")); translate("VCommandLine", "The size value")},
optionsUsed.insert(LONG_OPTION_EFFICIENCY_COEFFICIENT, option); {{SINGLE_OPTION_GRADATIONHEIGHT, LONG_OPTION_GRADATIONHEIGHT},
parser.addOption(option); translate("VCommandLine", "Set height value for pattern file, that was opened with multisize measurements "
"(export mode). Valid values: %1cm.").arg(VMeasurement::WholeListHeights(Unit::Cm).join(QStringLiteral(", "))),
option = VCommandLineOption(QStringList({SINGLE_OPTION_EXP2FORMAT, LONG_OPTION_EXP2FORMAT}), translate("VCommandLine", "The height value")},
translate("VCommandLine", "Number corresponding to output format (default = 0, " {LONG_OPTION_USER_MATERIAL,
"export mode):") + translate("VCommandLine", "Use this option to override user material defined in pattern. The value must be in "
DialogSaveLayout::MakeHelpFormatList(), "form <number>@<user matrial name>. The number should be in range from 1 to %1. For example, 1@Fabric2. The "
translate("VCommandLine", "Format number"), QChar('0')); "key can be used multiple times. Has no effect in GUI mode.").arg(userMaterialPlaceholdersQuantity),
optionsUsed.insert(LONG_OPTION_EXP2FORMAT, option); translate("VCommandLine", "User material")},
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_BINARYDXF, translate("VCommandLine", "Export dxf in binary form."));
optionsUsed.insert(LONG_OPTION_BINARYDXF, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_TEXT2PATHS, translate("VCommandLine", "Export text as paths."));
optionsUsed.insert(LONG_OPTION_TEXT2PATHS, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_EXPORTONLYDETAILS,
translate("VCommandLine", "Export only details. Export details as they positioned in "
"the details mode. Any layout related options will be "
"ignored."));
optionsUsed.insert(LONG_OPTION_EXPORTONLYDETAILS, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_EXPORTSUCHDETAILS,
translate("VCommandLine", "Export only details that match a piece name regex."),
translate("VCommandLine", "The name regex"));
optionsUsed.insert(LONG_OPTION_EXPORTSUCHDETAILS, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_GRADATIONSIZE, LONG_OPTION_GRADATIONSIZE}),
translate("VCommandLine", "Set size value for pattern file, that was opened "
"with multisize measurements (export mode). Valid "
"values: %1cm.")
.arg(VMeasurement::WholeListSizes(Unit::Cm)
.join(QStringLiteral(", "))),
translate("VCommandLine", "The size value"));
optionsUsed.insert(LONG_OPTION_GRADATIONSIZE, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_GRADATIONHEIGHT, LONG_OPTION_GRADATIONHEIGHT}),
translate("VCommandLine", "Set height value for pattern file, that was opened"
" with multisize measurements (export mode). Valid "
"values: %1cm.")
.arg(VMeasurement::WholeListHeights(Unit::Cm).join(QStringLiteral(", "))),
translate("VCommandLine", "The height value"));
optionsUsed.insert(LONG_OPTION_GRADATIONHEIGHT, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_USER_MATERIAL,
translate("VCommandLine", "Use this option to override user material defined in "
"pattern. The value must be in form <number>@<user "
"matrial name>. The number should be in range from 1 "
"to %1. For example, 1@Fabric2. The key can be used "
"multiple times. Has no effect in GUI mode.")
.arg(userMaterialPlaceholdersQuantity),
translate("VCommandLine", "User material"));
optionsUsed.insert(LONG_OPTION_USER_MATERIAL, option);
parser.addOption(option);
//================================================================================================================= //=================================================================================================================
option = VCommandLineOption(QStringList({SINGLE_OPTION_PAGETEMPLATE, LONG_OPTION_PAGETEMPLATE}), {{SINGLE_OPTION_PAGETEMPLATE, LONG_OPTION_PAGETEMPLATE},
translate("VCommandLine", "Number corresponding to layout page template " translate("VCommandLine", "Number corresponding to layout page template (default = 0, export mode):") +
"(default = 0, export mode):") + DialogLayoutSettings::MakeHelpTemplateList(),
DialogLayoutSettings::MakeHelpTemplateList(), translate("VCommandLine", "Template number"), QChar('0')},
translate("VCommandLine", "Template number"), QChar('0')); {LONG_OPTION_LANDSCAPE_ORIENTATION,
optionsUsed.insert(LONG_OPTION_PAGETEMPLATE, option); translate("VCommandLine", "Switch page template orientation to landscape (export mode). This option has "
parser.addOption(option); "effect only for one of predefined page templates.")},
{{SINGLE_OPTION_PAGEW, LONG_OPTION_PAGEW},
option = VCommandLineOption(LONG_OPTION_LANDSCAPE_ORIENTATION, translate("VCommandLine", "Page width in current units like 12.0 (cannot be used with \"%1\", export mode).")
translate("VCommandLine", "Switch page template orientation to landscape " .arg(LONG_OPTION_PAGETEMPLATE),
"(export mode). This option has effect only for one of " translate("VCommandLine", "The page width")},
"predefined page templates.")); {{SINGLE_OPTION_PAGEH, LONG_OPTION_PAGEH},
optionsUsed.insert(LONG_OPTION_LANDSCAPE_ORIENTATION, option); translate("VCommandLine", "Page height in current units like 12.0 (cannot be used with \"%1\", export mode).")
parser.addOption(option); .arg(LONG_OPTION_PAGETEMPLATE),
translate("VCommandLine", "The page height")},
option = VCommandLineOption(QStringList({SINGLE_OPTION_PAGEW, LONG_OPTION_PAGEW}), {{SINGLE_OPTION_PAGEUNITS, LONG_OPTION_PAGEUNITS},
translate("VCommandLine", "Page width in current units like 12.0 (cannot be used " translate("VCommandLine", "Page measure units (export mode). Valid values: %1.")
"with \"%1\", export mode).") .arg(VDomDocument::UnitsHelpString()),
.arg(LONG_OPTION_PAGETEMPLATE), translate("VCommandLine", "The measure unit")},
translate("VCommandLine", "The page width")); {{SINGLE_OPTION_IGNORE_MARGINS, LONG_OPTION_IGNORE_MARGINS},
optionsUsed.insert(LONG_OPTION_PAGEW, option); translate("VCommandLine", "Ignore printer margins (export mode). Use if need full paper space. In case of "
parser.addOption(option); "later printing you must account for the margins himself.")},
{{SINGLE_OPTION_LEFT_MARGIN, LONG_OPTION_LEFT_MARGIN},
option = VCommandLineOption(QStringList({SINGLE_OPTION_PAGEH, LONG_OPTION_PAGEH}), translate("VCommandLine", "Page left margin in current units like 3.0 (export mode). If not set will be used "
translate("VCommandLine", "Page height in current units like 12.0 (cannot be " "value from default printer. Or 0 if none printers was found."),
"used with \"%1\", export mode).") translate("VCommandLine", "The left margin")},
.arg(LONG_OPTION_PAGETEMPLATE), {{SINGLE_OPTION_RIGHT_MARGIN, LONG_OPTION_RIGHT_MARGIN},
translate("VCommandLine", "The page height")); translate("VCommandLine", "Page right margin in current units like 3.0 (export mode). If not set will be used "
optionsUsed.insert(LONG_OPTION_PAGEH, option); "value from default printer. Or 0 if none printers was found."),
parser.addOption(option); translate("VCommandLine", "The right margin")},
{{SINGLE_OPTION_TOP_MARGIN, LONG_OPTION_TOP_MARGIN},
option = VCommandLineOption(QStringList({SINGLE_OPTION_PAGEUNITS, LONG_OPTION_PAGEUNITS}), translate("VCommandLine", "Page top margin in current units like 3.0 (export mode). If not set will be used "
translate("VCommandLine", "Page measure units (export mode). Valid values: %1.") "value from default printer. Or 0 if none printers was found."),
.arg(VDomDocument::UnitsHelpString()), translate("VCommandLine", "The top margin")},
translate("VCommandLine", "The measure unit")); {{SINGLE_OPTION_BOTTOM_MARGIN, LONG_OPTION_BOTTOM_MARGIN},
optionsUsed.insert(LONG_OPTION_PAGEUNITS, option); translate("VCommandLine", "Page bottom margin in current units like 3.0 (export mode). If not set will be "
parser.addOption(option); "used value from default printer. Or 0 if none printers was found."),
translate("VCommandLine", "The bottom margin")},
option = VCommandLineOption(QStringList({SINGLE_OPTION_IGNORE_MARGINS, LONG_OPTION_IGNORE_MARGINS}),
translate("VCommandLine", "Ignore printer margins (export mode). Use if need "
"full paper space. In case of later printing you must "
"account for the margins himself."));
optionsUsed.insert(LONG_OPTION_IGNORE_MARGINS, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_LEFT_MARGIN, LONG_OPTION_LEFT_MARGIN}),
translate("VCommandLine", "Page left margin in current units like 3.0 (export "
"mode). If not set will be used value from default "
"printer. Or 0 if none printers was found."),
translate("VCommandLine", "The left margin"));
optionsUsed.insert(LONG_OPTION_LEFT_MARGIN, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_RIGHT_MARGIN, LONG_OPTION_RIGHT_MARGIN}),
translate("VCommandLine", "Page right margin in current units like 3.0 (export "
"mode). If not set will be used value from default "
"printer. Or 0 if none printers was found."),
translate("VCommandLine", "The right margin"));
optionsUsed.insert(LONG_OPTION_RIGHT_MARGIN, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_TOP_MARGIN, LONG_OPTION_TOP_MARGIN}),
translate("VCommandLine", "Page top margin in current units like 3.0 (export "
"mode). If not set will be used value from default "
"printer. Or 0 if none printers was found."),
translate("VCommandLine", "The top margin"));
optionsUsed.insert(LONG_OPTION_TOP_MARGIN, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_BOTTOM_MARGIN, LONG_OPTION_BOTTOM_MARGIN}),
translate("VCommandLine", "Page bottom margin in current units like 3.0 (export "
"mode). If not set will be used value from default "
"printer. Or 0 if none printers was found."),
translate("VCommandLine", "The bottom margin"));
optionsUsed.insert(LONG_OPTION_BOTTOM_MARGIN, option);
parser.addOption(option);
//================================================================================================================= //=================================================================================================================
option = VCommandLineOption(LONG_OPTION_FOLLOW_GRAINLINE, {LONG_OPTION_FOLLOW_GRAINLINE,
translate("VCommandLine", "Order detail to follow grainline direction (export mode).")); translate("VCommandLine", "Order detail to follow grainline direction (export mode).")},
optionsUsed.insert(LONG_OPTION_FOLLOW_GRAINLINE, option); {{SINGLE_OPTION_CROP, LONG_OPTION_CROP},
parser.addOption(option); translate("VCommandLine", "Auto crop unused length (export mode).")},
{{SINGLE_OPTION_UNITE, LONG_OPTION_UNITE},
option = VCommandLineOption(QStringList({SINGLE_OPTION_CROP, LONG_OPTION_CROP}), translate("VCommandLine", "Unite pages if possible (export mode). Maximum value limited by QImage that "
translate("VCommandLine", "Auto crop unused length (export mode).")); "supports only a maximum of 32768x32768 px images.")},
optionsUsed.insert(LONG_OPTION_CROP, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_UNITE, LONG_OPTION_UNITE}),
translate("VCommandLine", "Unite pages if possible (export mode). Maximum value "
"limited by QImage that supports only a maximum of "
"32768x32768 px images."));
optionsUsed.insert(LONG_OPTION_UNITE, option);
parser.addOption(option);
//================================================================================================================= //=================================================================================================================
option = VCommandLineOption(QStringList({SINGLE_OPTION_SAVELENGTH, LONG_OPTION_SAVELENGTH}), {{SINGLE_OPTION_SAVELENGTH, LONG_OPTION_SAVELENGTH},
translate("VCommandLine", "Save length of the sheet if set (export mode). The " translate("VCommandLine", "Save length of the sheet if set (export mode). The option tells the program to use "
"option tells the program to use as much as possible " "as much as possible width of sheet. Quality of a layout can be worse when this option was used.")},
"width of sheet. Quality of a layout can be worse when " {{SINGLE_OPTION_SHIFTUNITS, LONG_OPTION_SHIFTUNITS},
"this option was used.")); translate("VCommandLine", "Layout units (as paper's one except px, export mode)."),
optionsUsed.insert(LONG_OPTION_SAVELENGTH, option); translate("VCommandLine", "The unit")},
parser.addOption(option); {{SINGLE_OPTION_GAPWIDTH, LONG_OPTION_GAPWIDTH},
translate("VCommandLine", "The layout gap width x2, measured in layout units (export mode). Set distance "
option = VCommandLineOption(QStringList({SINGLE_OPTION_SHIFTUNITS, LONG_OPTION_SHIFTUNITS}), "between details and a detail and a sheet."),
translate("VCommandLine", "Layout units (as paper's one except px, export mode)."), translate("VCommandLine", "The gap width")},
translate("VCommandLine", "The unit")); {{SINGLE_OPTION_GROUPPING, LONG_OPTION_GROUPPING},
optionsUsed.insert(LONG_OPTION_SHIFTUNITS, option); translate("VCommandLine", "Sets layout groupping cases (export mode): %1.")
parser.addOption(option); .arg(DialogLayoutSettings::MakeGroupsHelp()),
translate("VCommandLine", "Grouping type"), QChar('2')},
option = VCommandLineOption(QStringList({SINGLE_OPTION_GAPWIDTH, LONG_OPTION_GAPWIDTH}), {{SINGLE_OPTION_TEST, LONG_OPTION_TEST},
translate("VCommandLine", "The layout gap width x2, measured in layout units " translate("VCommandLine", "Run the program in a test mode. The program in this mode loads a single pattern "
"(export mode). Set distance between details and a " "file and silently quit without showing the main window. The key have priority before key '%1'.")
"detail and a sheet."), .arg(LONG_OPTION_BASENAME)},
translate("VCommandLine", "The gap width")); {LONG_OPTION_PENDANTIC,
optionsUsed.insert(LONG_OPTION_GAPWIDTH, option); translate("VCommandLine", "Make all parsing warnings into errors. Have effect only in console mode. Use to "
parser.addOption(option); "force Valentina to immediately terminate if a pattern contains a parsing warning.")},
{LONG_OPTION_NO_HDPI_SCALING,
option = VCommandLineOption(QStringList({SINGLE_OPTION_GROUPPING, LONG_OPTION_GROUPPING}), translate("VCommandLine", "Disable high dpi scaling. Call this option if has problem with scaling (by default "
translate("VCommandLine", "Sets layout groupping cases (export mode): %1.") "scaling enabled). Alternatively you can use the %1 environment variable.")
.arg(DialogLayoutSettings::MakeGroupsHelp()), .arg(QStringLiteral("QT_AUTO_SCREEN_SCALE_FACTOR=0"))},
translate("VCommandLine", "Grouping type"), QChar('2'));
optionsUsed.insert(LONG_OPTION_GROUPPING, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_TEST, LONG_OPTION_TEST}),
translate("VCommandLine", "Run the program in a test mode. The program in this "
"mode loads a single pattern file and silently quit "
"without showing the main window. The key have "
"priority before key '%1'.")
.arg(LONG_OPTION_BASENAME));
optionsUsed.insert(LONG_OPTION_TEST, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_PENDANTIC,
translate("VCommandLine", "Make all parsing warnings into errors. Have effect "
"only in console mode. Use to force Valentina to "
"immediately terminate if a pattern contains a parsing "
"warning."));
optionsUsed.insert(LONG_OPTION_PENDANTIC, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_NO_HDPI_SCALING,
translate("VCommandLine", "Disable high dpi scaling. Call this option if has "
"problem with scaling (by default scaling enabled). "
"Alternatively you can use the %1 environment "
"variable.")
.arg(QStringLiteral("QT_AUTO_SCREEN_SCALE_FACTOR=0")));
optionsUsed.insert(LONG_OPTION_NO_HDPI_SCALING, option);
parser.addOption(option);
//================================================================================================================= //=================================================================================================================
option = VCommandLineOption(LONG_OPTION_CSVWITHHEADER, {LONG_OPTION_CSVWITHHEADER,
translate("VCommandLine", "Export to csv with header. By default disabled.")); translate("VCommandLine", "Export to csv with header. By default disabled.")},
optionsUsed.insert(LONG_OPTION_CSVWITHHEADER, option); {LONG_OPTION_CSVCODEC,
parser.addOption(option); translate("VCommandLine", "Specify codec that will be used to save data. List of supported codecs provided by "
"Qt. Default value depend from system. On Windows, the codec will be based on a system locale. On Unix "
option = VCommandLineOption(LONG_OPTION_CSVCODEC, "systems, the codec will might fall back to using the iconv library if no builtin codec for the locale can be "
translate("VCommandLine", "Specify codec that will be used to save data. List of " "found. Valid values for this installation:") + DialogExportToCSV::MakeHelpCodecsList(),
"supported codecs provided by Qt. Default value depend " translate("VCommandLine", "Codec name"), QString(QTextCodec::codecForLocale()->name())},
"from system. On Windows, the codec will be based on a " {LONG_OPTION_CSVSEPARATOR,
"system locale. On Unix systems, the codec will might " translate("VCommandLine", "Specify csv separator character. Default value is '%1'. Valid characters:")
"fall back to using the iconv library if no builtin " .arg(VCommonSettings::GetDefCSVSeparator()) + DialogExportToCSV::MakeHelpSeparatorList(),
"codec for the locale can be found. Valid values for " translate("VCommandLine", "Separator character"), QString(VCommonSettings::GetDefCSVSeparator())},
"this installation:") {LONG_OPTION_CSVEXPORTFM,
+ DialogExportToCSV::MakeHelpCodecsList(), translate("VCommandLine", "Calling this command enable exporting final measurements. Specify path to csv file "
translate("VCommandLine", "Codec name"), "with final measurements. The path must contain path to directory and name of file. It can be absolute or "
QString(QTextCodec::codecForLocale()->name())); "relatetive. In case of relative path will be used current working directory to calc a destination path."),
optionsUsed.insert(LONG_OPTION_CSVCODEC, option); translate("VCommandLine", "Path to csv file")},
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_CSVSEPARATOR,
translate("VCommandLine", "Specify csv separator character. Default value is "
"'%1'. Valid characters:")
.arg(VCommonSettings::GetDefCSVSeparator()) +
DialogExportToCSV::MakeHelpSeparatorList(),
translate("VCommandLine", "Separator character"),
QString(VCommonSettings::GetDefCSVSeparator()));
optionsUsed.insert(LONG_OPTION_CSVSEPARATOR, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_CSVEXPORTFM,
translate("VCommandLine", "Calling this command enable exporting final "
"measurements. Specify path to csv file with final "
"measurements. The path must contain path to directory "
"and name of file. It can be absolute or relatetive. "
"In case of relative path will be used current working "
"directory to calc a destination path."),
translate("VCommandLine", "Path to csv file"));
optionsUsed.insert(LONG_OPTION_CSVEXPORTFM, option);
parser.addOption(option);
//================================================================================================================= //=================================================================================================================
option = VCommandLineOption(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE, {LONG_OPTION_TILED_PDF_PAGE_TEMPLATE,
translate("VCommandLine", "Number corresponding to tiled pdf page template " translate("VCommandLine", "Number corresponding to tiled pdf page template (default = 0, export mode with "
"(default = 0, export mode with tiled pdf format):") + "tiled pdf format):") + DialogLayoutSettings::MakeHelpTiledPdfTemplateList(),
DialogLayoutSettings::MakeHelpTiledPdfTemplateList(), translate("VCommandLine", "Template number"), QChar('0')},
translate("VCommandLine", "Template number"), QChar('0')); {LONG_OPTION_TILED_PDF_LEFT_MARGIN,
optionsUsed.insert(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE, option); translate("VCommandLine","Tiled page left margin in current units like 3.0 (export mode). If not set will be "
parser.addOption(option); "used default value 1 cm."),
translate("VCommandLine", "The left margin")},
option = VCommandLineOption(LONG_OPTION_TILED_PDF_LEFT_MARGIN, {LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
translate("VCommandLine","Tiled page left margin in current units like 3.0 " translate("VCommandLine", "Tiled page right margin in current units like 3.0 (export mode). If not set will "
"(export mode). If not set will be used default value 1 " "be used default value 1 cm."),
"cm."), translate("VCommandLine", "The right margin")},
translate("VCommandLine", "The left margin")); {LONG_OPTION_TILED_PDF_TOP_MARGIN,
optionsUsed.insert(LONG_OPTION_TILED_PDF_LEFT_MARGIN, option); translate("VCommandLine", "Tiled page top margin in current units like 3.0 (export mode). If not set will be "
parser.addOption(option); "used value default value 1 cm."),
translate("VCommandLine", "The top margin")},
option = VCommandLineOption(LONG_OPTION_TILED_PDF_RIGHT_MARGIN, {LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine", "Tiled page right margin in current units like 3.0 " translate("VCommandLine", "Tiled page bottom margin in current units like 3.0 (export mode). If not set will "
"(export mode). If not set will be used default value " "be used value default value 1 cm."),
"1 cm."), translate("VCommandLine", "The bottom margin")},
translate("VCommandLine", "The right margin")); {LONG_OPTION_TILED_PDF_LANDSCAPE,
optionsUsed.insert(LONG_OPTION_TILED_PDF_RIGHT_MARGIN, option); translate("VCommandLine", "Set tiled page orienatation to landscape (export mode). Default value if not set "
parser.addOption(option); "portrait.")}
});
option = VCommandLineOption(LONG_OPTION_TILED_PDF_TOP_MARGIN,
translate("VCommandLine", "Tiled page top margin in current units like 3.0 "
"(export mode). If not set will be used value default "
"value 1 cm."),
translate("VCommandLine", "The top margin"));
optionsUsed.insert(LONG_OPTION_TILED_PDF_TOP_MARGIN, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine", "Tiled page bottom margin in current units like 3.0 "
"(export mode). If not set will be used value default "
"value 1 cm."),
translate("VCommandLine", "The bottom margin"));
optionsUsed.insert(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_TILED_PDF_LANDSCAPE,
translate("VCommandLine", "Set tiled page orienatation to landscape (export "
"mode). Default value if not set portrait."));
optionsUsed.insert(LONG_OPTION_TILED_PDF_LANDSCAPE, option);
parser.addOption(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsOptionSet(const QString &option) const bool VCommandLine::IsOptionSet(const QString &option) const
{ {
return parser.isSet(optionsUsed.value(option)); return parser.isSet(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptionValue(const QString &option) const QString VCommandLine::OptionValue(const QString &option) const
{ {
return parser.value(optionsUsed.value(option)); return parser.value(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptionValues(const QString &option) const QStringList VCommandLine::OptionValues(const QString &option) const
{ {
return parser.values(optionsUsed.value(option)); return parser.values(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -42,29 +42,6 @@ class VCommandLine;
using VCommandLinePtr = std::shared_ptr<VCommandLine>; using VCommandLinePtr = std::shared_ptr<VCommandLine>;
using VLayoutGeneratorPtr = std::shared_ptr<VLayoutGenerator>; using VLayoutGeneratorPtr = std::shared_ptr<VLayoutGenerator>;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
/**
* @brief The VCommandLineOption class wrapper for class QCommandLineOption. Add support for containers.
*/
class VCommandLineOption : public QCommandLineOption
{
public:
VCommandLineOption()
: QCommandLineOption(QStringLiteral("fakeOption")) {}
VCommandLineOption(const QString &name, const QString &description, const QString &valueName = QString(),
const QString &defaultValue = QString())
: QCommandLineOption(name, description, valueName, defaultValue) {}
VCommandLineOption(const QStringList &names, const QString &description, const QString &valueName = QString(),
const QString &defaultValue = QString())
: QCommandLineOption(names, description, valueName, defaultValue) {}
};
QT_WARNING_POP
//@brief: class used to install export command line options and parse their values //@brief: class used to install export command line options and parse their values
//QCommandLineParser* object must exists until this object alive //QCommandLineParser* object must exists until this object alive
class VCommandLine class VCommandLine
@ -163,7 +140,6 @@ private:
Q_DISABLE_COPY(VCommandLine) Q_DISABLE_COPY(VCommandLine)
static VCommandLinePtr instance; static VCommandLinePtr instance;
QCommandLineParser parser; QCommandLineParser parser;
QMap<QString, VCommandLineOption> optionsUsed;
bool isGuiEnabled; bool isGuiEnabled;
friend class VApplication; friend class VApplication;