From 2afc195a87a897fb0a9bf0e2d83c17392d077c83 Mon Sep 17 00:00:00 2001 From: Patrick Proy Date: Mon, 26 May 2014 14:20:14 +0200 Subject: [PATCH] Backout changeset 38e907833133b065c72ba362fed040f608d4b66d --HG-- branch : XML Editor --- src/app/dialogs/tools/dialogendline.cpp | 36 +----- src/app/dialogs/tools/dialogendline.h | 12 -- src/app/dialogs/tools/dialogendline.ui | 73 ++--------- src/app/dialogs/tools/dialogtool.cpp | 117 ++---------------- src/app/dialogs/tools/dialogtool.h | 6 - src/app/share/resources/icon.qrc | 2 - .../share/resources/icon/16x16/go-down.png | Bin 756 -> 0 bytes .../share/resources/icon/16x16/go-next.png | Bin 829 -> 0 bytes 8 files changed, 28 insertions(+), 218 deletions(-) delete mode 100644 src/app/share/resources/icon/16x16/go-down.png delete mode 100644 src/app/share/resources/icon/16x16/go-next.png diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index cdc6aad14..b9b1b4279 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -39,13 +39,10 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) ui->setupUi(this); InitVariables(ui); labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; + lineEditFormula = ui->lineEditFormula; labelEditFormula = ui->labelEditFormula; labelEditNamePoint = ui->labelEditNamePoint; - // TODO : auto extend height on first value length. - this->formulaBaseHeight=ui->plainTextEditFormula->height(); - InitOkCansel(ui); flagFormula = false; flagName = false; @@ -60,29 +57,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEndLine::PutVal); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEndLine::EvalFormula); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged); - connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged); - connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogEndLine::FormulaTextChanged() -{ - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogEndLine::DeployFormulaTextEdit() -{ - if (ui->plainTextEditFormula->height() < 64) - { - ui->plainTextEditFormula->setFixedHeight(64); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - } + connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -115,10 +90,7 @@ void DialogEndLine::setTypeLine(const QString &value) void DialogEndLine::setFormula(const QString &value) { formula = value; - ui->plainTextEditFormula->setPlainText(value); - //QTextCursor cursor = ui->plainTextEditFormula->textCursor(); - //cursor.insertText(value); - //ui->plainTextEditFormula->setCursor(cursor); + ui->lineEditFormula->setText(formula); } //--------------------------------------------------------------------------------------------------------------------- @@ -139,7 +111,7 @@ void DialogEndLine::DialogAccepted() { pointName = ui->lineEditNamePoint->text(); typeLine = GetTypeLine(ui->comboBoxLineType); - formula = ui->plainTextEditFormula->toPlainText(); + formula = ui->lineEditFormula->text(); angle = ui->doubleSpinBoxAngle->value(); basePointId = getCurrentObjectId(ui->comboBoxBasePoint); emit DialogClosed(QDialog::Accepted); diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h index 9765d6cbb..7dfc82b03 100644 --- a/src/app/dialogs/tools/dialogendline.h +++ b/src/app/dialogs/tools/dialogendline.h @@ -112,14 +112,6 @@ public slots: * @brief DialogAccepted save data and emit signal about closed dialog. */ virtual void DialogAccepted(); - /** - * @brief DeployFormulaTextEdit grow or shrink formula input - */ - void DeployFormulaTextEdit(); - /** - * @brief FormulaTextChanged when formula text changes for validation and calc - */ - void FormulaTextChanged(); private: Q_DISABLE_COPY(DialogEndLine) /** @@ -146,10 +138,6 @@ private: * @brief basePointId id base point of line */ quint32 basePointId; - /** - * @brief formulaBaseHeight base height defined by dialogui - */ - int formulaBaseHeight; }; inline QString DialogEndLine::getPointName() const diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui index 797078a5a..1d6c59866 100644 --- a/src/app/dialogs/tools/dialogendline.ui +++ b/src/app/dialogs/tools/dialogendline.ui @@ -6,8 +6,8 @@ 0 0 - 486 - 522 + 539 + 559 @@ -74,17 +74,17 @@ - - - Qt::Horizontal + + + + 0 + 0 + - - - 40 - 20 - + + Formula for calculation of length of line - + @@ -147,56 +147,6 @@ - - - - - - - 16777215 - 24 - - - - - 4 - 0 - - - - - - - - - 16 - 16 - - - - <html><head/><body><p>Show full calculation in message box</p></body></html> - - - - - - - :/icon/16x16/go-down.png - :/icon/16x16/go-next.png:/icon/16x16/go-down.png - - - - 16 - 16 - - - - true - - - - - @@ -600,6 +550,7 @@ + lineEditFormula comboBoxBasePoint lineEditNamePoint doubleSpinBoxAngle diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index ada3d1e16..c10df30c0 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -33,15 +33,10 @@ #include -// TODO : for issue #79 -// replace lineEditFormula -> plainTextEditFormula -// delete lineEditFormala everywhrer -// delete PutValHere and eval overloaded functions - //--------------------------------------------------------------------------------------------------------------------- DialogTool::DialogTool(const VContainer *data, QWidget *parent) :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr), - bOk(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr), listWidget(nullptr), + bOk(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr), labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), @@ -288,42 +283,22 @@ void DialogTool::ChangeCurrentData(QComboBox *box, const quint32 &value) const } } +//--------------------------------------------------------------------------------------------------------------------- void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget) -{ // TODO issue #79 : erase this function after all tools updated to plainTextEdit +{ Q_CHECK_PTR(lineEdit); Q_CHECK_PTR(listWidget); QListWidgetItem *item = listWidget->currentItem(); Q_CHECK_PTR(item); - int pos = lineEdit->cursorPosition(); lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text())); lineEdit->setFocus(); lineEdit->setCursorPosition(pos + item->text().size()); - -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget) -{ - Q_CHECK_PTR(plainTextEdit); - Q_CHECK_PTR(listWidget); - QListWidgetItem *item = listWidget->currentItem(); - Q_CHECK_PTR(item); - - QTextCursor cursor = plainTextEdit->textCursor(); - cursor.insertText(item->text()); - plainTextEdit->setTextCursor(cursor); - /* - int pos = lineEdit->cursorPosition(); - lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text())); - lineEdit->setFocus(); - lineEdit->setCursorPosition(pos + item->text().size()); - */ } //--------------------------------------------------------------------------------------------------------------------- void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer) -{// TODO issue #79 : erase this function after all tools updated to plainTextEdit +{ Q_CHECK_PTR(edit); Q_CHECK_PTR(timer); Q_CHECK_PTR(labelEditFormula); @@ -338,26 +313,10 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer) } timer->start(1000); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *timer) -{ - Q_CHECK_PTR(edit); - Q_CHECK_PTR(timer); - Q_CHECK_PTR(labelEditFormula); - if (edit->toPlainText().isEmpty()) - { - flag = false; - CheckState(); - QPalette palette = labelEditFormula->palette(); - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - labelEditFormula->setPalette(palette); - return; - } - timer->start(1000); -} +//--------------------------------------------------------------------------------------------------------------------- void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) -{ // TODO issue #79 : erase this function after all tools updated to plainTextEdit +{ Q_CHECK_PTR(edit); Q_CHECK_PTR(timer); Q_CHECK_PTR(label); @@ -391,45 +350,6 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) labelEditFormula->setPalette(palette); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label) -{ - Q_CHECK_PTR(edit); - Q_CHECK_PTR(timer); - Q_CHECK_PTR(label); - Q_CHECK_PTR(labelEditFormula); - QPalette palette = labelEditFormula->palette(); - if (edit->toPlainText().isEmpty()) - { - flag = false; - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - } - else - { - Calculator cal(data); - QString errorMsg; - // Replace line return with spaces for calc - QString formula = edit->toPlainText(); - formula.replace("\n"," "); - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty() == false) - { - label->setText(tr("Error")); - flag = false; - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - } - else - { - label->setText(QString().setNum(result)); - flag = true; - palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); - } - } - CheckState(); - timer->stop(); - labelEditFormula->setPalette(palette); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogTool::setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id) const { @@ -569,17 +489,8 @@ void DialogTool::DialogRejected() //--------------------------------------------------------------------------------------------------------------------- void DialogTool::FormulaChanged() -{ // TODO issue #79 : erase after full update of tools. - QLineEdit* edit = qobject_cast(sender()); - if (edit) - { - ValFormulaChanged(flagFormula, edit, timerFormula); - } -} -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::FormulaChanged2() { - QPlainTextEdit* edit = qobject_cast(sender()); + QLineEdit* edit = qobject_cast(sender()); if (edit) { ValFormulaChanged(flagFormula, edit, timerFormula); @@ -645,9 +556,9 @@ void DialogTool::ArrowRightDown() //--------------------------------------------------------------------------------------------------------------------- void DialogTool::EvalFormula() { - Q_CHECK_PTR(plainTextEditFormula); + Q_CHECK_PTR(lineEditFormula); Q_CHECK_PTR(labelResultCalculation); - Eval(plainTextEditFormula, flagFormula, timerFormula, labelResultCalculation); + Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation); } //--------------------------------------------------------------------------------------------------------------------- @@ -704,23 +615,19 @@ void DialogTool::Increments() //--------------------------------------------------------------------------------------------------------------------- void DialogTool::PutHere() { - PutValHere(plainTextEditFormula, listWidget); + PutValHere(lineEditFormula, listWidget); } //--------------------------------------------------------------------------------------------------------------------- void DialogTool::PutVal(QListWidgetItem *item) { - Q_CHECK_PTR(plainTextEditFormula); + Q_CHECK_PTR(lineEditFormula); Q_CHECK_PTR(item); - QTextCursor cursor = plainTextEditFormula->textCursor(); - cursor.insertText(item->text()); - plainTextEditFormula->setTextCursor(cursor); - /*int pos = plainTextEditFormula->cursorPosition(); + int pos = lineEditFormula->cursorPosition(); lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(), item->text())); lineEditFormula->setFocus(); lineEditFormula->setCursorPosition(pos + item->text().size()); - */ } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index dc8eed65b..6def423d3 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -37,7 +37,6 @@ #include #include #include -#include #include "../../container/vcontainer.h" #include "../../widgets/vapplication.h" @@ -103,7 +102,6 @@ public slots: * @brief formula check formula */ void FormulaChanged(); - void FormulaChanged2(); /** * @brief ArrowUp set angle value 90 degree */ @@ -216,7 +214,6 @@ protected: * @brief lineEditFormula linEdit for formula */ QLineEdit *lineEditFormula; - QPlainTextEdit *plainTextEditFormula; /** * @brief listWidget listWidget with variables */ @@ -344,7 +341,6 @@ protected: * @param listWidget listWidget */ void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); - void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); /** * @brief ValFormulaChanged handle change formula * @param flag flag state of formula @@ -352,7 +348,6 @@ protected: * @param timer timer of formula */ void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); - void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); /** * @brief Eval evaluate formula and show result * @param edit lineEdit of formula @@ -360,7 +355,6 @@ protected: * @param timer timer of formula * @param label label for signal error */ - void Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label); void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label); /** * @brief setCurrentPointId set current point id in combobox diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index 75a714bc7..64d48ee8e 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -52,7 +52,5 @@ icon/flags/uk.png icon/Graduation.png icon/individual.png - icon/16x16/go-down.png - icon/16x16/go-next.png diff --git a/src/app/share/resources/icon/16x16/go-down.png b/src/app/share/resources/icon/16x16/go-down.png deleted file mode 100644 index a74287892e3a8b6135f8c7239530e962021fdb49..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 756 zcmVL}00NXrL_t(I%gvH&NYham#-Foklnb4= za@o|3Y!y0`O(L?SME#IxQR^aQMHY#sU?r(hlTnGLWr>%p6cbXzP$@5r{Lsz3q?1Y` z`(Wgibl#_%{@*@~t(N$`=hMqM&w0-8ea`{@kxx*HxlS)A3yMz2iXpONrZuOKe3UnR z!4jRleAiq{c3i2o_q#(_qav?EwRA4`BPA5HYGqMRB21p*7cBq)_IF4}UA{n>f{jcCNl{kPcsbde3wz4*)8PR0s_`5W7>AxOr@Rn&9TiU@b6{5eP$C z9s4mdgJ1m(lG`vvY61fx^m^K%F=cWd4bN~)GYIk$ zt!4p!uB^Fx0GaWDZUFGQq0&f@aV-|XCo=F=lV7}0k`pDGoMP5G5irkZ?ITVI-0sd~ zGIyvu2ioc?s~rI#DZ6^`gEJFZ~8kU=k=Mtl+)?0000Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy33hNnX8-^I5C8xG5CB}pt-}BS00v@9M??Ss00000`9r&Z00009 za7bBm000tn000tn0p4aGcmMzbQAtEWR5%f}!D&d-aU2KWZ&0s-mJ*Us1VO1U%rsXd zSSG_PgtW{uk143hQd?wRo9X6}_wr(DR?0S-W-}dgF{6cftY*h%g)bx`qx4Nez0jh5 zpY{)h>C|^U57DCP+r6|FiK3g<)nRx+&f+fDBm_h&r6*IGitZ@=HqxS8MIX87GQX!K z=d!hp(pxWCTG*6p#_7e(%Qkfp`Adu#LO!6A803~$iBZWEsQe=? zlsyE8GM|8QZ6IMk^NiBKVKX_~Cy)?lPm~h=kAYo1KiK}k1$gOZuv