From 3bc3c4bec3264b0a15030ef7172e754f3a49a4aa Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Tue, 4 Oct 2016 02:07:58 +0200 Subject: [PATCH] Fixed the grainline formulas editing --HG-- branch : feature --- src/libs/vpatterndb/vgrainlinegeometry.cpp | 2 +- .../vtools/dialogs/tools/dialogdetail.cpp | 56 ++-- src/libs/vtools/dialogs/tools/dialogdetail.h | 6 +- src/libs/vtools/dialogs/tools/dialogdetail.ui | 293 ++++++++++++------ 4 files changed, 237 insertions(+), 120 deletions(-) diff --git a/src/libs/vpatterndb/vgrainlinegeometry.cpp b/src/libs/vpatterndb/vgrainlinegeometry.cpp index 860ee5321..336d5da76 100644 --- a/src/libs/vpatterndb/vgrainlinegeometry.cpp +++ b/src/libs/vpatterndb/vgrainlinegeometry.cpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------------------------------------- VGrainlineGeometry::VGrainlineGeometry() - :m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(true) + :m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 6240d5545..d6cc233ce 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -79,7 +79,8 @@ class QWidget; */ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true), - m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom(), m_oldGrainline() + m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom(), m_oldGrainline(), + m_iRotBaseHeight(0), m_iLenBaseHeight(0) { ui.setupUi(this); @@ -158,13 +159,19 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge connect(ui.checkBoxGrainline, &QCheckBox::toggled, this, &DialogDetail::EnableGrainlineRotation); connect(ui.pushButtonRot, &QPushButton::clicked, this, &DialogDetail::EditFormula); connect(ui.pushButtonLen, &QPushButton::clicked, this, &DialogDetail::EditFormula); - connect(ui.lineEditLenFormula, &QLineEdit::textChanged, this, &DialogDetail::UpdateValue); - connect(ui.lineEditRotFormula, &QLineEdit::textChanged, this, &DialogDetail::UpdateValue); + connect(ui.lineEditLenFormula, &QPlainTextEdit::textChanged, this, &DialogDetail::UpdateValue); + connect(ui.lineEditRotFormula, &QPlainTextEdit::textChanged, this, &DialogDetail::UpdateValue); + + connect(ui.pushButtonShowRot, &QPushButton::clicked, this, &DialogDetail::DeployRotation); + connect(ui.pushButtonShowLen, &QPushButton::clicked, this, &DialogDetail::DeployLength); SetAddMode(); EnableGrainlineRotation(); ui.tabWidget->setCurrentIndex(0); + + m_iRotBaseHeight = ui.lineEditRotFormula->height(); + m_iLenBaseHeight = ui.lineEditLenFormula->height(); } //--------------------------------------------------------------------------------------------------------------------- @@ -479,8 +486,8 @@ VDetail DialogDetail::CreateDetail() const detail.GetGrainlineGeometry().SetVisible(ui.checkBoxGrainline->isChecked()); if (ui.checkBoxGrainline->isChecked() == true) { - detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->text()); - detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->text()); + detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->toPlainText()); + detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->toPlainText()); } return detail; } @@ -553,8 +560,8 @@ void DialogDetail::setDetail(const VDetail &value) UpdateList(); ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible()); - ui.lineEditRotFormula->setText(detail.GetGrainlineGeometry().GetRotation()); - ui.lineEditLenFormula->setText(detail.GetGrainlineGeometry().GetLength()); + ui.lineEditRotFormula->setPlainText(detail.GetGrainlineGeometry().GetRotation()); + ui.lineEditLenFormula->setPlainText(detail.GetGrainlineGeometry().GetLength()); m_oldData = detail.GetPatternPieceData(); m_oldGeom = detail.GetPatternInfo(); @@ -830,10 +837,10 @@ void DialogDetail::ClearFields() //--------------------------------------------------------------------------------------------------------------------- void DialogDetail::SetValue(QObject *pobjSender) { - QLineEdit* pleSender = qobject_cast(pobjSender); + QPlainTextEdit* pleSender = qobject_cast(pobjSender); SCASSERT(pleSender != 0); - QString qsFormula = pleSender->text().simplified(); + QString qsFormula = pleSender->toPlainText().simplified(); Calculator cal; QString qsVal; try @@ -856,18 +863,15 @@ void DialogDetail::SetValue(QObject *pobjSender) qsVal.clear(); } - QLineEdit* pleVal; QLabel* plbVal; QString qsUnit; if (pobjSender == ui.lineEditLenFormula) { - pleVal = ui.lineEditLenValue; plbVal = ui.labelLen; qsUnit = " " + VDomDocument::UnitsToStr(qApp->patternUnit()); } else if (pobjSender == ui.lineEditRotFormula) { - pleVal = ui.lineEditRotValue; plbVal = ui.labelRot; QChar ch(0x00b0); qsUnit = ch; @@ -882,7 +886,6 @@ void DialogDetail::SetValue(QObject *pobjSender) { qsVal += qsUnit; } - pleVal->setText(qsVal); plbVal->setText(qsVal); } @@ -936,18 +939,18 @@ void DialogDetail::SetEditMode() //--------------------------------------------------------------------------------------------------------------------- void DialogDetail::EnableGrainlineRotation() { - ui.lineEditRotValue->setEnabled(ui.checkBoxGrainline->isChecked()); ui.lineEditRotFormula->setEnabled(ui.checkBoxGrainline->isChecked()); - ui.lineEditLenValue->setEnabled(ui.checkBoxGrainline->isChecked()); ui.lineEditLenFormula->setEnabled(ui.checkBoxGrainline->isChecked()); ui.pushButtonRot->setEnabled(ui.checkBoxGrainline->isChecked()); ui.pushButtonLen->setEnabled(ui.checkBoxGrainline->isChecked()); + ui.pushButtonShowLen->setEnabled(ui.checkBoxGrainline->isChecked()); + ui.pushButtonShowRot->setEnabled(ui.checkBoxGrainline->isChecked()); } //--------------------------------------------------------------------------------------------------------------------- void DialogDetail::EditFormula() { - QLineEdit* pleFormula; + QPlainTextEdit* pleFormula; bool bCheckZero; if (sender() == ui.pushButtonLen) @@ -967,20 +970,33 @@ void DialogDetail::EditFormula() } DialogEditWrongFormula dlg(data, NULL_ID, this); - dlg.SetFormula(pleFormula->text()); + dlg.SetFormula(pleFormula->toPlainText()); dlg.setCheckZero(bCheckZero); if (dlg.exec() == true) { QString qsFormula = dlg.GetFormula(); qsFormula.replace("\n", " "); - pleFormula->setText(qsFormula); + pleFormula->setPlainText(qsFormula); SetValue(pleFormula); } } //--------------------------------------------------------------------------------------------------------------------- -void DialogDetail::UpdateValue(const QString& qsText) +void DialogDetail::UpdateValue() { - Q_UNUSED(qsText); SetValue(sender()); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::DeployRotation() +{ + DeployFormula(ui.lineEditRotFormula, ui.pushButtonShowRot, m_iRotBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::DeployLength() +{ + DeployFormula(ui.lineEditLenFormula, ui.pushButtonShowLen, m_iLenBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.h b/src/libs/vtools/dialogs/tools/dialogdetail.h index bb2cfd813..b96263334 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.h +++ b/src/libs/vtools/dialogs/tools/dialogdetail.h @@ -109,6 +109,8 @@ private: VPatternPieceData m_oldData; VPatternInfoGeometry m_oldGeom; VGrainlineGeometry m_oldGrainline; + int m_iRotBaseHeight; + int m_iLenBaseHeight; bool DetailIsValid() const; @@ -132,7 +134,9 @@ private slots: void SetEditMode(); void EnableGrainlineRotation(); void EditFormula(); - void UpdateValue(const QString& qsText); + void UpdateValue(); + void DeployRotation(); + void DeployLength(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index 555100038..ef696c8e6 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -535,65 +535,40 @@ Grainline - + - 10 - 10 - 361 - 201 + 20 + 20 + 351 + 41 - - + + Grainline visible - - - - - Liberation Sans - 10 - 75 - true - - - - Length - - - - - - - - - - - - - - Value - - - - - - - Value - - - - + + + + + + 20 + 70 + 351 + 41 + + + + - Liberation Sans - 10 + 11 75 true @@ -603,78 +578,201 @@ - - - - Formula + + + + Qt::Horizontal - - - - - - + + + 40 + 20 + - + - - - - Formula - - - - + - - - 0 - 0 - + + + + + + :/icon/24x24/fx.png:/icon/24x24/fx.png + + + + 24 + 24 + + + + + + + + + + + :/icon/24x24/equal.png + + + + + + + + 87 + 0 + - + + + + + + 20 + 120 + 351 + 41 + + + + + + + + 16777215 + 28 + + + + + + + + + + + + + + + + + + + + 20 + 180 + 351 + 41 + + + + + + + + 11 + 75 + true + + + + Length + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - 0 - 0 - + + + + + + :/icon/24x24/fx.png:/icon/24x24/fx.png + + + + 24 + 24 + + + + + + + + + + + :/icon/24x24/equal.png + + + + + + + + 87 + 0 + - - - - true + + + + + + 20 + 230 + 351 + 41 + + + + + + + + 16777215 + 28 + - - - - true + + + + - - - - - - true - - - - - - - true + + + + @@ -717,7 +815,6 @@ checkBoxDetail checkBoxPattern lineEditLetter - checkBoxGrainline