From f3d24856bef9d92029696215bf7be6af42c1de67 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 18 Aug 2015 10:24:51 +0300 Subject: [PATCH] Check Measurement file unit. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 17 ++++++++++++++++- src/libs/vformat/vmeasurements.cpp | 14 ++++++++++++++ src/libs/vformat/vmeasurements.h | 3 +++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index fecf15ce5..a6276cd55 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -273,6 +273,21 @@ void MainWindow::LoadMeasurements(const QString &path) throw e; } + if (m->Type() == MeasurementsType::Standard) + { + if (m->MUnit() == Unit::Inch) + { + QMessageBox::critical(this, tr("Wrong units."), + tr("Application doesn't support standard table with inches.")); + qCDebug(vMainWindow, "Application doesn't support standard table with inches."); + return; + } + m->SetDataSize(); + m->SetDataHeight(); + } + + qApp->setPatternType(m->Type()); + ToolBarOption(); pattern->ClearVariables(VarType::Measurement); m->ReadMeasurements(); delete m; @@ -992,6 +1007,7 @@ void MainWindow::LoadStandard() */ void MainWindow::ToolBarOption() { + ui->toolBarOption->clear(); if (qApp->patternType() == MeasurementsType::Standard) { const QStringList listHeights = VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit()); @@ -2127,7 +2143,6 @@ void MainWindow::New() //Set scene size to size scene view VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); - ToolBarOption(); AddPP(patternPieceName); } diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index aba0cfa6d..eef452997 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -533,6 +533,20 @@ QStringList VMeasurements::ListKnown() const return listNames; } +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurements::SetDataSize() +{ + data->SetSize(UnitConvertor(BaseSize(), MUnit(), *data->GetPatternUnit())); + data->SetSizeName(size_M); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurements::SetDataHeight() +{ + data->SetHeight(UnitConvertor(BaseHeight(), MUnit(), *data->GetPatternUnit())); + data->SetHeightName(height_M); +} + //--------------------------------------------------------------------------------------------------------------------- void VMeasurements::CreateEmptyStandardFile(Unit unit, int baseSize, int baseHeight) { diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 6a91305c1..62ee53022 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -121,6 +121,9 @@ public: QStringList ListAll() const; QStringList ListKnown() const; + void SetDataSize(); + void SetDataHeight(); + private: Q_DISABLE_COPY(VMeasurements)