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).
- [#755] New feature. Toggle point label.
- Fixed bug. After full parse undocommand Move labe losts connection to tool.
- [#756] New feature. Select pieces from command line.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina.
.\" 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
Valentina \- Pattern making program.
.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."
.IP "--exportOnlyDetails"
.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>"
.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>"
@ -199,8 +201,4 @@ Run the program in a test mode. The program in this mode loads a single pattern
.SH AUTHOR
.RI "This manual page was written by Roman Telezhynskyi <" dismine@gmail.com ">"
.SH "SEE ALSO"
.RB "Full " "User Manual" " is availiable in"
.UR https://bitbucket.org/dismine/valentina/wiki/manual/Content
.UE
.BR tape (1)

View File

@ -504,6 +504,7 @@ void VApplication::BeginLogging()
//---------------------------------------------------------------------------------------------------------------------
void VApplication::ClearOldLogs() const
{
const QString workingDirectory = QDir::currentPath();// Save the app working directory
QDir logsDir(LogDirPath());
logsDir.setNameFilters(QStringList("*.log"));
logsDir.setCurrent(LogDirPath());
@ -541,6 +542,8 @@ void VApplication::ClearOldLogs() const
{
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"
" 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++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
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)));
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportSuchDetails() const
{
QString path;
if (IsExportEnabled())
{
path = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_EXPORTSUCHDETAILS)));
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptInputFileNames() const
{

View File

@ -79,6 +79,9 @@ public:
int IsTextAsPaths() 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...
//@brief creates VLayoutGenerator
VLayoutGeneratorPtr DefaultGenerator() const;

View File

@ -4168,10 +4168,18 @@ MainWindow::~MainWindow()
* @brief LoadPattern open pattern 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));
{ // 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
if (OpenNewValentina(fileName))
{
@ -4810,6 +4818,9 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
return;
}
else
{
const QString nameRegex = expParams->OptExportSuchDetails();
if (nameRegex.isEmpty())
{
QHash<quint32, VPiece>::const_iterator i = allDetails->constBegin();
while (i != allDetails->constEnd())
@ -4820,6 +4831,20 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
}
++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)
{
@ -4870,7 +4895,8 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
}
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);
return;
}

View File

@ -61,7 +61,7 @@ public:
explicit MainWindow(QWidget *parent = nullptr);
virtual ~MainWindow() Q_DECL_OVERRIDE;
bool LoadPattern(const QString &fileName, const QString &customMeasureFile = QString());
bool LoadPattern(QString fileName, const QString &customMeasureFile = QString());
public slots:
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_TEXT2PATHS = QStringLiteral("text2paths");
const QString LONG_OPTION_EXPORTONLYDETAILS = QStringLiteral("exportOnlyDetails");
const QString LONG_OPTION_EXPORTSUCHDETAILS = QStringLiteral("exportSuchDetails");
const QString LONG_OPTION_ROTATE = QStringLiteral("rotate");
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_TEXT2PATHS;
extern const QString LONG_OPTION_EXPORTONLYDETAILS;
extern const QString LONG_OPTION_EXPORTSUCHDETAILS;
extern const QString LONG_OPTION_ROTATE;
extern const QString SINGLE_OPTION_ROTATE;