From 6c2c36a11def36328691f608c973674cf49fbf25 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 18 Aug 2015 17:53:33 +0300 Subject: [PATCH] Show current measurements in Tape. --HG-- branch : feature --- src/app/tape/main.cpp | 2 +- src/app/tape/tmainwindow.cpp | 6 +++++ src/app/valentina/mainwindow.cpp | 32 ++++++++++++++++++++++++++- src/app/valentina/mainwindow.h | 1 + src/app/valentina/mainwindow.ui | 20 +++++++++++++---- src/libs/ifc/xml/vabstractpattern.cpp | 2 +- 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index e1f674c0e..82e70d372 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) } const QStringList args = parser.positionalArguments(); - if (args.count() > 1) + if (args.count() > 0) { for (int i = 0; i < args.size(); ++i) { diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index caf562073..c29b10757 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -161,6 +161,12 @@ void TMainWindow::LoadFile(const QString &path) { if (m == nullptr) { + if (not QFileInfo(path).exists()) + { + qCritical() << "File " << path << " doesn't exist"; + return; + } + // Check if file already opened QListlist = qApp->MainWindows(); for (int i = 0; i < list.size(); ++i) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 30234806a..02c74aecd 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -293,7 +293,7 @@ void MainWindow::LoadMeasurements(const QString &path) delete m; doc->SetPath(path); PatternWasModified(false); - doc->LiteParseTree(Document::LiteParse); + ui->actionShowM->setEnabled(true); } catch (VException &e) { @@ -985,6 +985,7 @@ void MainWindow::LoadIndividual() if (not mPath.isEmpty()) { LoadMeasurements(mPath); + doc->LiteParseTree(Document::LiteParse); } } @@ -999,6 +1000,7 @@ void MainWindow::LoadStandard() if (not mPath.isEmpty()) { LoadMeasurements(mPath); + doc->LiteParseTree(Document::LiteParse); } } @@ -1008,6 +1010,32 @@ void MainWindow::CreateMeasurements() QProcess::startDetached(qApp->TapeFilePath()); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ShowMeasurements() +{ + if (not doc->MPath().isEmpty()) + { + QString run; + if (qApp->patternType() == MeasurementsType::Standard) + { + run = QString("\"%1\" \"%2\" -u %3 -h %4 -s %5").arg(qApp->TapeFilePath()).arg(doc->MPath()) + .arg(VDomDocument::UnitsToStr(qApp->patternUnit())) + .arg(static_cast(pattern->height())) + .arg(static_cast(pattern->size())); + } + else + { + run = QString("\"%1\" \"%2\" -u %3").arg(qApp->TapeFilePath()).arg(doc->MPath()) + .arg(VDomDocument::UnitsToStr(qApp->patternUnit())); + } + QProcess::startDetached(run); + } + else + { + ui->actionShowM->setEnabled(false); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolBarOption enable option toolbar. @@ -1825,6 +1853,7 @@ void MainWindow::Clear() ui->actionShowCurveDetails->setEnabled(false); ui->actionLoadIndividual->setEnabled(false); ui->actionLoadStandard->setEnabled(false); + ui->actionShowM->setEnabled(false); SetEnableTool(false); qApp->setPatternUnit(Unit::Cm); qApp->setPatternType(MeasurementsType::Individual); @@ -2774,6 +2803,7 @@ void MainWindow::CreateActions() connect(ui->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual); connect(ui->actionLoadStandard, &QAction::triggered, this, &MainWindow::LoadStandard); connect(ui->actionCreateNew, &QAction::triggered, this, &MainWindow::CreateMeasurements); + connect(ui->actionShowM, &QAction::triggered, this, &MainWindow::ShowMeasurements); connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs); connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin); connect(ui->actionPrintPreviewTailed, &QAction::triggered, this, &MainWindow::PrintPreviewTiled); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 2a36866dd..1dda13336 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -163,6 +163,7 @@ private slots: void LoadIndividual(); void LoadStandard(); void CreateMeasurements(); + void ShowMeasurements(); private: Q_DISABLE_COPY(MainWindow) /** @brief ui keeps information about user interface */ diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index a2b105a24..683994f8a 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -372,7 +372,7 @@ 0 0 - 130 + 117 58 @@ -458,7 +458,7 @@ 0 0 - 130 + 117 156 @@ -622,7 +622,7 @@ 0 0 - 130 + 117 196 @@ -864,7 +864,7 @@ 0 0 - 130 + 117 58 @@ -1088,6 +1088,7 @@ + @@ -1881,6 +1882,17 @@ Create new measurements + + + false + + + Show ... + + + Show measurements + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 88715edb1..68194b544 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -453,7 +453,7 @@ QVector VAbstractPattern::getLocalHistory() const //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::MPath() const { - return UniqueTagText(TagUnit); + return UniqueTagText(TagMeasurements); } //---------------------------------------------------------------------------------------------------------------------