diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index d09417198..713b7e586 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -48,7 +48,6 @@ //--------------------------------------------------------------------------------------------------------------------- VTranslateVars::VTranslateVars() - :VTranslateMeasurements() { InitPatternMakingSystems(); InitVariables(); @@ -545,8 +544,8 @@ void VTranslateVars::InitFunctions() functions.insert(csrInch_F, translate("VTranslateVars", "csrInch", "cut, split and rotate modeling operation. Takes" " inch units.")); - functionsDescriptions.insert(csrInch_F, translate("VTranslateVars", "cut, split and rotate modeling operation. Takes" - " inch units.", "function csrInch")); + functionsDescriptions.insert(csrInch_F, translate("VTranslateVars", "cut, split and rotate modeling operation. " + "Takes inch units.", "function csrInch")); functionsArguments.insert(csrInch_F, threeArguments); functions.insert(abs_F, translate("VTranslateVars", "abs", "absolute value")); @@ -622,7 +621,7 @@ void VTranslateVars::InitSystem(const QString &code, const qmu::QmuTranslation & * @param numbers all numbers */ void VTranslateVars::CorrectionsPositions(int position, int bias, QMap &tokens, - QMap &numbers) const + QMap &numbers) { if (bias == 0) { @@ -633,6 +632,188 @@ void VTranslateVars::CorrectionsPositions(int position, int bias, QMap &tokens, + QMap &numbers) const +{ + QList tKeys = tokens.keys();// Take all tokens positions + QList tValues = tokens.values(); + for (int i = 0; i < tKeys.size(); ++i) + { + int bias = 0; + if (MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + {// Translated token has different length than original. Position of next tokens need to be corrected. + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + {// Translated token has different length than original. Position of next tokens need to be corrected. + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + {// Translated token has different length than original. Position of next tokens need to be corrected. + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (tValues.at(i) == QLocale().negativeSign()) + {// unary minus + newFormula.replace(tKeys.at(i), 1, '-'); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VTranslateVars::TranslateNumbersFromUser(QString &newFormula, QMap &tokens, + QMap &numbers, bool osSeparator) +{ + QLocale loc = QLocale(); // User locale + if (loc != QLocale::c() && osSeparator) + {// User want use Os separator + QList nKeys = numbers.keys();// Positions for all numbers in expression + QList nValues = numbers.values(); + for (int i = 0; i < nKeys.size(); ++i) + { + loc = QLocale();// From system locale + bool ok = false; + const qreal d = loc.toDouble(nValues.at(i), &ok); + if (not ok) + { + qDebug()<<"Can't convert to double token"< &tokens, + QMap &numbers) const +{ + QList tKeys = tokens.keys(); + QList tValues = tokens.values(); + for (int i = 0; i < tKeys.size(); ++i) + { + if (measurements.contains(tValues.at(i))) + { + newFormula.replace(tKeys.at(i), tValues.at(i).length(), + measurements.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); + int bias = tValues.at(i).length() - + measurements.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); + if (bias != 0) + {// Translated token has different length than original. Position next tokens need to be corrected. + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (functions.contains(tValues.at(i))) + { + newFormula.replace(tKeys.at(i), tValues.at(i).length(), + functions.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); + int bias = tValues.at(i).length() - + functions.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); + if (bias != 0) + {// Translated token has different length than original. Position next tokens need to be corrected. + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + int bias = 0; + if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + {// Translated token has different length than original. Position next tokens need to be corrected. + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (tValues.at(i) == QChar('-')) + {// unary minus + newFormula.replace(tKeys.at(i), 1, QLocale().negativeSign()); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap &tokens, + QMap &numbers, bool osSeparator) +{ + QLocale loc = QLocale();// User locale + if (loc != QLocale::C && osSeparator) + {// User want use Os separator + QList nKeys = numbers.keys();// Positions for all numbers in expression + QList nValues = numbers.values(); + for (int i = 0; i < nKeys.size(); ++i) + { + loc = QLocale::c();// From pattern locale + bool ok = false; + const qreal d = loc.toDouble(nValues.at(i), &ok); + if (not ok) + { + qDebug()<<"Can't convert to double token"< &toke * @param bias hold change of length between translated and origin token string * @return true if was found variable with same name. */ -bool VTranslateVars::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const +auto VTranslateVars::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool { const QString currentLengthTr = variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); @@ -711,7 +892,7 @@ bool VTranslateVars::VariablesFromUser(QString &newFormula, int position, const * @param bias hold change of length between translated and origin token string * @return true if was found function with same name. */ -bool VTranslateVars::FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const +auto VTranslateVars::FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool { QMap::const_iterator i = functions.constBegin(); while (i != functions.constEnd()) @@ -736,7 +917,7 @@ bool VTranslateVars::FunctionsFromUser(QString &newFormula, int position, const * @param bias hold change of length between translated and origin token string * @return true if was found variable with same name. */ -bool VTranslateVars::VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const +auto VTranslateVars::VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool { QMap::const_iterator i = variables.constBegin(); while (i != variables.constEnd()) @@ -764,7 +945,7 @@ bool VTranslateVars::VariablesToUser(QString &newFormula, int position, const QS } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::InternalVarToUser(const QString &var) const +auto VTranslateVars::InternalVarToUser(const QString &var) const -> QString { QString newVar = var; int bias = 0; @@ -772,14 +953,12 @@ QString VTranslateVars::InternalVarToUser(const QString &var) const { return newVar; } - else - { - return var; - } + + return var; } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::VarToUser(const QString &var) const +auto VTranslateVars::VarToUser(const QString &var) const -> QString { if (VAbstractApplication::VApp()->Settings()->GetLocale() == QStringLiteral("zh_CN")) { @@ -800,7 +979,7 @@ QString VTranslateVars::VarToUser(const QString &var) const } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::VarFromUser(const QString &var) const +auto VTranslateVars::VarFromUser(const QString &var) const -> QString { if (VAbstractApplication::VApp()->Settings()->GetLocale() == QStringLiteral("zh_CN")) { @@ -827,19 +1006,19 @@ QString VTranslateVars::VarFromUser(const QString &var) const } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::PMSystemName(const QString &code) const +auto VTranslateVars::PMSystemName(const QString &code) const -> QString { return PMSystemNames.value(code).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::PMSystemAuthor(const QString &code) const +auto VTranslateVars::PMSystemAuthor(const QString &code) const -> QString { return PMSystemAuthors.value(code).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } //--------------------------------------------------------------------------------------------------------------------- -QString VTranslateVars::PMSystemBook(const QString &code) const +auto VTranslateVars::PMSystemBook(const QString &code) const -> QString { return PMSystemBooks.value(code).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } @@ -852,98 +1031,30 @@ QString VTranslateVars::PMSystemBook(const QString &code) const * @throw qmu::QmuParserError in case of a wrong expression * @return translated expression */ -QString VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator) const +auto VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator) const -> QString { if (formula.isEmpty()) { return formula; } - QString newFormula = formula;// Local copy for making changes // Eval formula - QScopedPointer cal(new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions())); + QScopedPointer cal( + new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions())); QMap tokens = cal->GetTokens();// Tokens (variables, measurements) QMap numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator delete cal.take(); - QList tKeys = tokens.keys();// Take all tokens positions - QList tValues = tokens.values(); - for (int i = 0; i < tKeys.size(); ++i) - { - int bias = 0; - if (MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) - { - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } + QString newFormula = formula;// Local copy for making changes - if (VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) - { - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - - if (FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) - { - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - - if (tValues.at(i) == QLocale().negativeSign()) - {// unary minus - newFormula.replace(tKeys.at(i), 1, '-'); - } - } - - QLocale loc = QLocale(); // User locale - if (loc != QLocale::c() && osSeparator) - {// User want use Os separator - QList nKeys = numbers.keys();// Positions for all numbers in expression - QList nValues = numbers.values(); - for (int i = 0; i < nKeys.size(); ++i) - { - loc = QLocale();// From system locale - bool ok = false; - const qreal d = loc.toDouble(nValues.at(i), &ok); - if (ok == false) - { - qDebug()<<"Can't convert to double token"< QString { try { @@ -964,7 +1075,7 @@ QString VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSepara * @param formula expression that need translate * @return translated expression */ -QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) const +auto VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) const -> QString { if (formula.isEmpty()) { @@ -991,98 +1102,14 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) return newFormula; } - QList tKeys = tokens.keys(); - QList tValues = tokens.values(); - for (int i = 0; i < tKeys.size(); ++i) - { - if (measurements.contains(tValues.at(i))) - { - newFormula.replace(tKeys.at(i), tValues.at(i).length(), - measurements.value(tValues.at(i)) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); - int bias = tValues.at(i).length() - measurements.value(tValues.at(i)) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - - if (functions.contains(tValues.at(i))) - { - newFormula.replace(tKeys.at(i), tValues.at(i).length(), - functions.value(tValues.at(i)) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); - int bias = tValues.at(i).length() - functions.value(tValues.at(i)) - .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - - int bias = 0; - if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) - { - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - - if (tValues.at(i) == QChar('-')) - {// unary minus - newFormula.replace(tKeys.at(i), 1, QLocale().negativeSign()); - } - } - - QLocale loc = QLocale();// User locale - if (loc != QLocale::C && osSeparator) - {// User want use Os separator - QList nKeys = numbers.keys();// Positions for all numbers in expression - QList nValues = numbers.values(); - for (int i = 0; i < nKeys.size(); ++i) - { - loc = QLocale::c();// From pattern locale - bool ok = false; - const qreal d = loc.toDouble(nValues.at(i), &ok); - if (ok == false) - { - qDebug()<<"Can't convert to double token"< QString { try { @@ -1116,25 +1143,25 @@ void VTranslateVars::Retranslate() } //--------------------------------------------------------------------------------------------------------------------- -QMap VTranslateVars::GetTranslatedFunctions() const +auto VTranslateVars::GetTranslatedFunctions() const -> QMap { return translatedFunctions; } //--------------------------------------------------------------------------------------------------------------------- -QMap VTranslateVars::GetFunctions() const +auto VTranslateVars::GetFunctions() const -> QMap { return functions; } //--------------------------------------------------------------------------------------------------------------------- -QMap VTranslateVars::GetFunctionsDescriptions() const +auto VTranslateVars::GetFunctionsDescriptions() const -> QMap { return functionsDescriptions; } //--------------------------------------------------------------------------------------------------------------------- -QMap VTranslateVars::GetFunctionsArguments() const +auto VTranslateVars::GetFunctionsArguments() const -> QMap { return functionsArguments; } diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index d86f123a7..ef815209a 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -33,43 +33,44 @@ #include #include "vtranslatemeasurements.h" +#include "../vmisc/defglobal.h" class VTranslateVars : public VTranslateMeasurements { public: explicit VTranslateVars(); - virtual ~VTranslateVars() = default; + ~VTranslateVars() override = default; - bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const; - bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; - bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const; + auto VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool; + auto FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool; + auto VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const -> bool; - QString InternalVarToUser(const QString &var) const; + auto InternalVarToUser(const QString &var) const -> QString; - QString VarToUser(const QString &var) const; - QString VarFromUser(const QString &var) const; + auto VarToUser(const QString &var) const -> QString; + auto VarFromUser(const QString &var) const -> QString; - QString PMSystemName(const QString &code) const; - QString PMSystemAuthor(const QString &code) const; - QString PMSystemBook(const QString &code) const; + auto PMSystemName(const QString &code) const -> QString; + auto PMSystemAuthor(const QString &code) const -> QString; + auto PMSystemBook(const QString &code) const -> QString; - QString FormulaFromUser(const QString &formula, bool osSeparator) const; - static QString TryFormulaFromUser(const QString &formula, bool osSeparator); + auto FormulaFromUser(const QString &formula, bool osSeparator) const -> QString; + static auto TryFormulaFromUser(const QString &formula, bool osSeparator) -> QString; - QString FormulaToUser(const QString &formula, bool osSeparator) const; - static QString TryFormulaToUser(const QString &formula, bool osSeparator); + auto FormulaToUser(const QString &formula, bool osSeparator) const -> QString; + static auto TryFormulaToUser(const QString &formula, bool osSeparator) -> QString; - virtual void Retranslate() override; + void Retranslate() override; - QMap GetTranslatedFunctions() const; - QMap GetFunctions() const; - QMap GetFunctionsDescriptions() const; - QMap GetFunctionsArguments() const; + auto GetTranslatedFunctions() const -> QMap; + auto GetFunctions() const -> QMap; + auto GetFunctionsDescriptions() const -> QMap; + auto GetFunctionsArguments() const -> QMap; static void BiasTokens(int position, int bias, QMap &tokens); private: - Q_DISABLE_COPY(VTranslateVars) + Q_DISABLE_COPY_MOVE(VTranslateVars) //NOLINT QMap PMSystemNames{}; QMap PMSystemAuthors{}; QMap PMSystemBooks{}; @@ -89,8 +90,15 @@ private: void InitSystem(const QString &code, const qmu::QmuTranslation &name, const qmu::QmuTranslation &author, const qmu::QmuTranslation &book); - void CorrectionsPositions(int position, int bias, QMap &tokens, QMap &numbers) const; + static void CorrectionsPositions(int position, int bias, QMap &tokens, QMap &numbers); + void TranslateVarsFromUser(QString &newFormula, QMap &tokens, QMap &numbers) const; + static void TranslateNumbersFromUser(QString &newFormula, QMap &tokens, QMap &numbers, + bool osSeparator); + + void TranslateVarsToUser(QString &newFormula, QMap &tokens, QMap &numbers) const; + static void TranslateNumbersToUser(QString &newFormula, QMap &tokens, QMap &numbers, + bool osSeparator); }; #endif // VTRANSLATEVARS_H diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index 8a771939f..f56855fad 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -62,7 +62,6 @@ #include "../vpatterndb/variables/vlineangle.h" #include "../vpatterndb/variables/vlinelength.h" #include "../vpatterndb/variables/vmeasurement.h" -#include "../ifc/xml/vdomdocument.h" #include "../vmisc/def.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" @@ -79,14 +78,7 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 t ui(new Ui::DialogEditWrongFormula), m_data(data), m_toolId(toolId), - formula(), - formulaBaseHeight(0), - checkZero(false), - checkLessThanZero(false), - postfix(), - restoreCursor(false), - timerFormula(new QTimer(this)), - flagFormula(false) + timerFormula(new QTimer(this)) { SCASSERT(data != nullptr) @@ -494,10 +486,9 @@ void DialogEditWrongFormula::SetPreviewCalculationsMode() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogEditWrongFormula::GetFormula() const +auto DialogEditWrongFormula::GetFormula() const -> QString { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -554,7 +545,7 @@ void DialogEditWrongFormula::SetDescription(const QString &name, qreal value, bo } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogEditWrongFormula::Eval(const FormulaData &formulaData, bool &flag) +auto DialogEditWrongFormula::Eval(const FormulaData &formulaData, bool &flag) -> qreal { const qreal result = EvalToolFormula(this, formulaData, flag); CheckState(); // Disable Ok and Apply buttons if something wrong. @@ -586,7 +577,7 @@ void DialogEditWrongFormula::ShowVariable(const QMap &var) if (iMap.value()->Filter(m_toolId) == false) {// If we create this variable don't show ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); - QTableWidgetItem *item = new QTableWidgetItem(iMap.key()); + auto *item = new QTableWidgetItem(iMap.key()); QFont font = item->font(); font.setBold(true); item->setFont(font); @@ -619,16 +610,16 @@ void DialogEditWrongFormula::ShowMeasurements(const QMapFilter(m_toolId) == false) + if (not iMap.value()->Filter(m_toolId)) {// If we create this variable don't show ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); - QTableWidgetItem *itemName = new QTableWidgetItem(iMap.key()); + auto *itemName = new QTableWidgetItem(iMap.key()); QFont fontName = itemName->font(); fontName.setBold(true); itemName->setFont(fontName); itemName->setToolTip(itemName->text()); - QTableWidgetItem *itemFullName = new QTableWidgetItem(); + auto *itemFullName = new QTableWidgetItem(); QFont fontFullName = itemName->font(); fontFullName.setBold(true); itemFullName->setFont(fontFullName); @@ -735,7 +726,7 @@ void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter) // show rows with matched filter const QList items = ui->tableWidget->findItems(filter, Qt::MatchContains); - for (auto item : items) + for (auto *item : items) { // If filter is empty findItems() for unknown reason returns nullptr items. if (item) diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index 1d3e33bb2..f5cefa6d6 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -38,6 +38,8 @@ #include #include +#include "../vmisc/defglobal.h" + class VMeasurement; struct FormulaData; class VContainer; @@ -57,37 +59,38 @@ class DialogEditWrongFormula; */ class DialogEditWrongFormula final : public QDialog { - Q_OBJECT + Q_OBJECT //NOLINT public: DialogEditWrongFormula(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); - virtual ~DialogEditWrongFormula() override; + ~DialogEditWrongFormula() override; - QString GetFormula() const; - void SetFormula(const QString &value); - void setCheckZero(bool value); - void setCheckLessThanZero(bool value); - void setPostfix(const QString &value); - void SetMeasurementsMode(); - void SetIncrementsMode(); - void SetPreviewCalculationsMode(); + auto GetFormula() const -> QString; + void SetFormula(const QString &value); + void setCheckZero(bool value); + void setCheckLessThanZero(bool value); + void setPostfix(const QString &value); + void SetMeasurementsMode(); + void SetIncrementsMode(); + void SetPreviewCalculationsMode(); public slots: virtual void DialogAccepted(); virtual void DialogRejected(); - void EvalFormula(); - void ValChanged(int row); - void PutHere(); - void PutVal(QTableWidgetItem * item); - void Measurements(); - void LengthLines(); - void RadiusArcs(); - void AnglesCurves(); - void LengthCurves(); - void CurvesCLength(); - void AngleLines(); - void Increments(); - void PreviewCalculations(); - void Functions(); + void EvalFormula(); + void ValChanged(int row); + void PutHere(); + void PutVal(QTableWidgetItem * item); + + void Measurements(); + void LengthLines(); + void RadiusArcs(); + void AnglesCurves(); + void LengthCurves(); + void CurvesCLength(); + void AngleLines(); + void Increments(); + void PreviewCalculations(); + void Functions(); signals: /** * @brief DialogClosed signal dialog closed @@ -99,15 +102,15 @@ signals: */ void DialogApplied(); protected: - virtual bool IsValid() const final; - virtual void closeEvent(QCloseEvent *event) override; - virtual void showEvent( QShowEvent *event ) override; - virtual void resizeEvent(QResizeEvent *event) override; + virtual auto IsValid() const -> bool final; + void closeEvent(QCloseEvent *event) override; + void showEvent( QShowEvent *event ) override; + void resizeEvent(QResizeEvent *event) override; virtual void CheckState(); private slots: void FilterVariablesEdited(const QString &filter); private: - Q_DISABLE_COPY(DialogEditWrongFormula) + Q_DISABLE_COPY_MOVE(DialogEditWrongFormula) //NOLINT Ui::DialogEditWrongFormula *ui; const VContainer *m_data; @@ -115,19 +118,19 @@ private: quint32 m_toolId; /** @brief formula string with formula */ - QString formula; + QString formula{}; /** @brief formulaBaseHeight base height defined by dialogui */ - int formulaBaseHeight; + int formulaBaseHeight{0}; - bool checkZero; - bool checkLessThanZero; - QString postfix; - bool restoreCursor; + bool checkZero{false}; + bool checkLessThanZero{false}; + QString postfix{}; + bool restoreCursor{false}; QTimer *timerFormula; - bool flagFormula; + bool flagFormula{false}; /** @brief m_isInitialized true if window is initialized */ bool m_isInitialized{false}; @@ -142,11 +145,11 @@ private: void SetDescription(const QString &name, qreal value, bool specialUnits, const QString &description); - qreal Eval(const FormulaData &formulaData, bool &flag); + auto Eval(const FormulaData &formulaData, bool &flag) -> qreal; }; //--------------------------------------------------------------------------------------------------------------------- -inline bool DialogEditWrongFormula::IsValid() const +inline auto DialogEditWrongFormula::IsValid() const -> bool { return flagFormula; }