Resolved issue #756. New feature. Select pieces from command line.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-09-22 19:16:16 +03:00
parent a5c9ba6c4d
commit bdc8840184
9 changed files with 64 additions and 13 deletions

View File

@ -19,6 +19,7 @@
- Added new language Polish (Poland). - Added new language Polish (Poland).
- [#755] New feature. Toggle point label. - [#755] New feature. Toggle point label.
- Fixed bug. After full parse undocommand Move labe losts connection to tool. - Fixed bug. After full parse undocommand Move labe losts connection to tool.
- [#756] New feature. Select pieces from command line.
# Version 0.5.1 # Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions. - [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina. .\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors. .\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "10 March, 2017" "valentina man page" .TH valentina 1 "22 September, 2017" "valentina man page"
.SH NAME .SH NAME
Valentina \- Pattern making program. Valentina \- Pattern making program.
.SH SYNOPSIS .SH SYNOPSIS
@ -106,6 +106,8 @@ The path to output destination folder. By default the directory at which the app
.RB "Export text as paths." .RB "Export text as paths."
.IP "--exportOnlyDetails" .IP "--exportOnlyDetails"
.RB "Export only details. Export details as they positioned in the details mode. Any layout related options will be ignored." .RB "Export only details. Export details as they positioned in the details mode. Any layout related options will be ignored."
.IP "--exportSuchDetails <The name regex>"
.RB "Export only details that match a piece name regex."
.IP "-x, --gsize <The size value>" .IP "-x, --gsize <The size value>"
.RB "Set size value a pattern file, that was opened with multisize measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm." .RB "Set size value a pattern file, that was opened with multisize measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
.IP "-e, --gheight <The height value>" .IP "-e, --gheight <The height value>"
@ -199,8 +201,4 @@ Run the program in a test mode. The program in this mode loads a single pattern
.SH AUTHOR .SH AUTHOR
.RI "This manual page was written by Roman Telezhynskyi <" dismine@gmail.com ">" .RI "This manual page was written by Roman Telezhynskyi <" dismine@gmail.com ">"
.SH "SEE ALSO" .SH "SEE ALSO"
.RB "Full " "User Manual" " is availiable in"
.UR https://bitbucket.org/dismine/valentina/wiki/manual/Content
.UE
.BR tape (1) .BR tape (1)

View File

@ -504,6 +504,7 @@ void VApplication::BeginLogging()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VApplication::ClearOldLogs() const void VApplication::ClearOldLogs() const
{ {
const QString workingDirectory = QDir::currentPath();// Save the app working directory
QDir logsDir(LogDirPath()); QDir logsDir(LogDirPath());
logsDir.setNameFilters(QStringList("*.log")); logsDir.setNameFilters(QStringList("*.log"));
logsDir.setCurrent(LogDirPath()); logsDir.setCurrent(LogDirPath());
@ -541,6 +542,8 @@ void VApplication::ClearOldLogs() const
{ {
qCDebug(vApp, "There are no old logs."); qCDebug(vApp, "There are no old logs.");
} }
QDir::setCurrent(workingDirectory); // Restore working directory
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -114,6 +114,12 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
"positioned in the details mode. Any layout related" "positioned in the details mode. Any layout related"
" options will be ignored."))); " options will be ignored.")));
optionsIndex.insert(LONG_OPTION_EXPORTSUCHDETAILS, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_EXPORTSUCHDETAILS,
translate("VCommandLine", "Export only details that match a piece name "
"regex."),
translate("VCommandLine", "The name regex")));
optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++); optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE, options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
translate("VCommandLine", "Set size value a pattern file, that was opened " translate("VCommandLine", "Set size value a pattern file, that was opened "
@ -649,6 +655,18 @@ int VCommandLine::IsExportOnlyDetails() const
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_EXPORTONLYDETAILS))); return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_EXPORTONLYDETAILS)));
} }
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportSuchDetails() const
{
QString path;
if (IsExportEnabled())
{
path = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_EXPORTSUCHDETAILS)));
}
return path;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptInputFileNames() const QStringList VCommandLine::OptInputFileNames() const
{ {

View File

@ -79,6 +79,9 @@ public:
int IsTextAsPaths() const; int IsTextAsPaths() const;
int IsExportOnlyDetails() const; int IsExportOnlyDetails() const;
//@brief returns the piece name regex or empty string if not set
QString OptExportSuchDetails() const;
//generator creation is moved here ... because most options are for it only, so no need to create extra getters... //generator creation is moved here ... because most options are for it only, so no need to create extra getters...
//@brief creates VLayoutGenerator //@brief creates VLayoutGenerator
VLayoutGeneratorPtr DefaultGenerator() const; VLayoutGeneratorPtr DefaultGenerator() const;

View File

@ -4168,10 +4168,18 @@ MainWindow::~MainWindow()
* @brief LoadPattern open pattern file. * @brief LoadPattern open pattern file.
* @param fileName name of file. * @param fileName name of file.
*/ */
bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasureFile) bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
{ {
qCDebug(vMainWindow, "Loading new file %s.", qUtf8Printable(fileName)); qCDebug(vMainWindow, "Loading new file %s.", qUtf8Printable(fileName));
{ // Convert to absolute path is need
QFileInfo info(fileName);
if (info.isRelative())
{
fileName = QDir::currentPath() + QLatin1Char('/') + fileName;
}
}
//We have unsaved changes or load more then one file per time //We have unsaved changes or load more then one file per time
if (OpenNewValentina(fileName)) if (OpenNewValentina(fileName))
{ {
@ -4810,6 +4818,9 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
return; return;
} }
else else
{
const QString nameRegex = expParams->OptExportSuchDetails();
if (nameRegex.isEmpty())
{ {
QHash<quint32, VPiece>::const_iterator i = allDetails->constBegin(); QHash<quint32, VPiece>::const_iterator i = allDetails->constBegin();
while (i != allDetails->constEnd()) while (i != allDetails->constEnd())
@ -4820,6 +4831,20 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
} }
++i; ++i;
} }
}
else
{
const QRegularExpression nameRe(nameRegex);
QHash<quint32, VPiece>::const_iterator i = allDetails->constBegin();
while (i != allDetails->constEnd())
{
if (nameRe.match(i.value().GetName()).hasMatch())
{
details.insert(i.key(), i.value());
}
++i;
}
}
if (details.count() == 0) if (details.count() == 0)
{ {
@ -4870,7 +4895,8 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
} }
catch (const VException &e) catch (const VException &e)
{ {
qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage())); qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")),
qUtf8Printable(e.ErrorMessage()));
qApp->exit(V_EX_DATAERR); qApp->exit(V_EX_DATAERR);
return; return;
} }

View File

@ -61,7 +61,7 @@ public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
virtual ~MainWindow() Q_DECL_OVERRIDE; virtual ~MainWindow() Q_DECL_OVERRIDE;
bool LoadPattern(const QString &fileName, const QString &customMeasureFile = QString()); bool LoadPattern(QString fileName, const QString &customMeasureFile = QString());
public slots: public slots:
void ProcessCMD(); void ProcessCMD();

View File

@ -52,6 +52,7 @@ const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f");
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf");
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths");
const QString LONG_OPTION_EXPORTONLYDETAILS = QStringLiteral("exportOnlyDetails"); const QString LONG_OPTION_EXPORTONLYDETAILS = QStringLiteral("exportOnlyDetails");
const QString LONG_OPTION_EXPORTSUCHDETAILS = QStringLiteral("exportSuchDetails");
const QString LONG_OPTION_ROTATE = QStringLiteral("rotate"); const QString LONG_OPTION_ROTATE = QStringLiteral("rotate");
const QString SINGLE_OPTION_ROTATE = QStringLiteral("r"); const QString SINGLE_OPTION_ROTATE = QStringLiteral("r");

View File

@ -49,6 +49,7 @@ extern const QString SINGLE_OPTION_EXP2FORMAT;
extern const QString LONG_OPTION_BINARYDXF; extern const QString LONG_OPTION_BINARYDXF;
extern const QString LONG_OPTION_TEXT2PATHS; extern const QString LONG_OPTION_TEXT2PATHS;
extern const QString LONG_OPTION_EXPORTONLYDETAILS; extern const QString LONG_OPTION_EXPORTONLYDETAILS;
extern const QString LONG_OPTION_EXPORTSUCHDETAILS;
extern const QString LONG_OPTION_ROTATE; extern const QString LONG_OPTION_ROTATE;
extern const QString SINGLE_OPTION_ROTATE; extern const QString SINGLE_OPTION_ROTATE;