From 2f34e863222c6a9df5ec739db6e14322d0a3ce66 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 26 Aug 2015 17:31:45 +0300 Subject: [PATCH] Convert to absolute path and show measurements. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 29 +++++++++++++++++++++-------- src/app/valentina/mainwindow.h | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index d5143816d..5be432f5b 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -336,6 +336,19 @@ QString MainWindow::RelativeMPath(const QString &patternPath, const QString &abs return dir.relativeFilePath(absoluteMPath); } +//--------------------------------------------------------------------------------------------------------------------- +QString MainWindow::AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) const +{ + if (patternPath.isEmpty()) + { + return relativeMPath; + } + else + { + return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath(); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief OptionDraw help change name of pattern piece. @@ -1020,7 +1033,7 @@ void MainWindow::LoadIndividual() { if (not doc->MPath().isEmpty()) { - watcher->removePath(QFileInfo(QFileInfo(curFile).absoluteDir(), doc->MPath()).absoluteFilePath()); + watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); } doc->SetPath(RelativeMPath(curFile, mPath)); watcher->addPath(mPath); @@ -1046,7 +1059,7 @@ void MainWindow::LoadStandard() { if (not doc->MPath().isEmpty()) { - watcher->removePath(QFileInfo(QFileInfo(curFile).absoluteDir(), doc->MPath()).absoluteFilePath()); + watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); } doc->SetPath(RelativeMPath(curFile, mPath)); watcher->addPath(mPath); @@ -1069,17 +1082,19 @@ void MainWindow::ShowMeasurements() { if (not doc->MPath().isEmpty()) { + const QString absoluteMPath = AbsoluteMPath(curFile, doc->MPath()); + QString run; if (qApp->patternType() == MeasurementsType::Standard) { - run = QString("\"%1\" \"%2\" -u %3 -h %4 -s %5").arg(qApp->TapeFilePath()).arg(doc->MPath()) + run = QString("\"%1\" \"%2\" -u %3 -h %4 -s %5").arg(qApp->TapeFilePath()).arg(absoluteMPath) .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()) + run = QString("\"%1\" \"%2\" -u %3").arg(qApp->TapeFilePath()).arg(absoluteMPath) .arg(VDomDocument::UnitsToStr(qApp->patternUnit())); } QProcess::startDetached(run); @@ -1933,7 +1948,7 @@ void MainWindow::Clear() qCDebug(vMainWindow, "Returned to Draw mode."); pattern->Clear(); qCDebug(vMainWindow, "Clearing pattern."); - watcher->removePath(QFileInfo(QFileInfo(curFile).absoluteDir(), doc->MPath()).absoluteFilePath()); + watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); doc->clear(); setCurrentFile(QString()); qCDebug(vMainWindow, "Clearing scenes."); @@ -3065,10 +3080,8 @@ void MainWindow::LoadPattern(const QString &fileName) if (not path.isEmpty()) { - //Search absolute path - path = QFileInfo(QFileInfo(fileName).absoluteDir(), path).absoluteFilePath(); // Check if exist - path = CheckPathToMeasurements(fileName, path); + path = CheckPathToMeasurements(fileName, AbsoluteMPath(fileName, path)); if (path.isEmpty()) { Clear(); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 4da273ad6..259cd27f1 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -300,6 +300,7 @@ private: void ToggleMSync(bool toggle); QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const; + QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) const; }; #endif // MAINWINDOW_H