From 8c0bdcc612cb63e78c1af70fcdce12fc58779633 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 13:39:31 +0200 Subject: [PATCH 01/10] Make parser static locale variable local for each parser instance. --HG-- branch : feature --- src/libs/qmuparser/qmuparser.cpp | 4 +-- src/libs/qmuparser/qmuparser.h | 2 +- src/libs/qmuparser/qmuparserbase.cpp | 27 +++++++++++++++------ src/libs/qmuparser/qmuparserbase.h | 5 +++- src/libs/qmuparser/qmuparserdef.h | 2 +- src/libs/qmuparser/qmuparsertest.cpp | 3 ++- src/libs/qmuparser/qmuparsertest.h | 2 +- src/libs/qmuparser/qmuparsertokenreader.cpp | 8 +++--- src/libs/qmuparser/qmuparsertokenreader.h | 4 +-- 9 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 799c6c8ca..bac0ecf00 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -199,14 +199,14 @@ qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc) * @param [out] a_fVal Pointer where the value should be stored in case one is found. * @return 1 if a value was found 0 otherwise. */ -int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal) +int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const std::locale &s_locale) { qreal fVal(0); std::wstring a_szExprStd = a_szExpr.toStdWString(); stringstream_type stream(a_szExprStd); stream.seekg(0); // todo: check if this really is necessary - stream.imbue(QmuParser::s_locale); + stream.imbue(s_locale); stream >> fVal; stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading diff --git a/src/libs/qmuparser/qmuparser.h b/src/libs/qmuparser/qmuparser.h index e65bdfa40..f35f545cc 100644 --- a/src/libs/qmuparser/qmuparser.h +++ b/src/libs/qmuparser/qmuparser.h @@ -54,7 +54,7 @@ namespace qmu virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd); qreal Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon = 0) const; protected: - static int IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal); + static int IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const std::locale &s_locale); // Trigonometric functions static qreal Tan2(qreal, qreal); // hyperbolic functions diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index c627e1f80..7455d3046 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -37,7 +37,6 @@ using namespace std; namespace qmu { -std::locale QmuParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep('.')); bool QmuParserBase::g_DbgDumpCmdCode = false; bool QmuParserBase::g_DbgDumpStack = false; @@ -57,7 +56,8 @@ const QStringList QmuParserBase::c_DefaultOprt = QStringList()<< "<=" << ">=" << * @brief Constructor. */ QmuParserBase::QmuParserBase() - :m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(), + :s_locale(std::locale(std::locale::classic(), new change_dec_sep('.'))), + m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(), m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), m_StrVarDef(), m_VarDef(), m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), m_nIfElseCounter(0), m_vStackBuffer(), m_nFinalResultIdx(0), m_Tokens(QMap()), m_Numbers(QMap()), allowSubexpressions(true) @@ -72,10 +72,11 @@ QmuParserBase::QmuParserBase() * Tha parser can be safely copy constructed but the bytecode is reset during copy construction. */ QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser) - :m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(), - m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), m_StrVarDef(), m_VarDef(), - m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), m_nIfElseCounter(0), m_vStackBuffer(), - m_nFinalResultIdx(0), m_Tokens(QMap()), m_Numbers(QMap()), allowSubexpressions(true) + :s_locale(a_Parser.getLocale()), m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), + m_vStringVarBuf(), m_pTokenReader(), m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), + m_StrVarDef(), m_VarDef(), m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), + m_nIfElseCounter(0), m_vStackBuffer(), m_nFinalResultIdx(0), m_Tokens(QMap()), + m_Numbers(QMap()), allowSubexpressions(true) { m_pTokenReader.reset(new token_reader_type(this)); Assign(a_Parser); @@ -220,6 +221,18 @@ void QmuParserBase::setAllowSubexpressions(bool value) allowSubexpressions = value; } +//--------------------------------------------------------------------------------------------------------------------- +std::locale QmuParserBase::getLocale() const +{ + return s_locale; +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserBase::setLocale(const std::locale &value) +{ + s_locale = value; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Returns the version of muparser. @@ -1300,7 +1313,7 @@ void QmuParserBase::CreateRPN() const for (;;) { - opt = m_pTokenReader->ReadNextToken(); + opt = m_pTokenReader->ReadNextToken(s_locale); switch (opt.GetCode()) { diff --git a/src/libs/qmuparser/qmuparserbase.h b/src/libs/qmuparser/qmuparserbase.h index 59d8b7c59..dc9a36385 100644 --- a/src/libs/qmuparser/qmuparserbase.h +++ b/src/libs/qmuparser/qmuparserbase.h @@ -122,9 +122,12 @@ public: } void setAllowSubexpressions(bool value); + std::locale getLocale() const; + void setLocale(const std::locale &value); + protected: static const QStringList c_DefaultOprt; - static std::locale s_locale; ///< The locale used by the parser + std::locale s_locale; ///< The locale used by the parser static bool g_DbgDumpCmdCode; static bool g_DbgDumpStack; void Init(); diff --git a/src/libs/qmuparser/qmuparserdef.h b/src/libs/qmuparser/qmuparserdef.h index cf6ce2652..a74d29d00 100644 --- a/src/libs/qmuparser/qmuparserdef.h +++ b/src/libs/qmuparser/qmuparserdef.h @@ -275,7 +275,7 @@ typedef qreal ( *strfun_type2 ) ( const QString &, qreal ); typedef qreal ( *strfun_type3 ) ( const QString &, qreal, qreal ); /** @brief Callback used for functions that identify values in a string. */ -typedef int ( *identfun_type ) ( const QString &sExpr, int *nPos, qreal *fVal ); +typedef int ( *identfun_type ) ( const QString &sExpr, int *nPos, qreal *fVal, const std::locale &s_locale ); /** @brief Callback used for variable creation factory functions. */ typedef qreal* ( *facfun_type ) ( const QString &, void* ); diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index 1d11cef83..a5ffb9dac 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -62,8 +62,9 @@ QmuParserTester::QmuParserTester() } //--------------------------------------------------------------------------------------------------------------------- -int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal ) +int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const std::locale &s_locale ) { + Q_UNUSED(s_locale) if ( a_szExpr.data()[1] == 0 || ( a_szExpr.data()[0] != '0' || a_szExpr.data()[1] != 'x' ) ) { return 0; diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index d2ae906ef..d1ffe91a8 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -276,7 +276,7 @@ private: } // Custom value recognition - static int IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal ); + static int IsHexVal (const QString &a_szExpr, int *a_iPos, qreal *a_fVal , const std::locale &s_locale); // cppcheck-suppress functionStatic int TestNames(); diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp index 9475308cc..d5515eb94 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.cpp +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -204,7 +204,7 @@ void QmuParserTokenReader::ReInit() /** * @brief Read the next token from the string. */ -QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken() +QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken(const std::locale &s_locale) { assert ( m_pParser ); @@ -236,7 +236,7 @@ QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken() { return SaveBeforeReturn ( tok ); // Check for function argument separators } - if ( IsValTok ( tok ) ) + if ( IsValTok ( tok, s_locale ) ) { return SaveBeforeReturn ( tok ); // Check for values / constant tokens } @@ -766,7 +766,7 @@ bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) * @param a_Tok [out] If a value token is found it will be placed here. * @return true if a value token has been found. */ -bool QmuParserTokenReader::IsValTok ( token_type &a_Tok ) +bool QmuParserTokenReader::IsValTok ( token_type &a_Tok, const std::locale &s_locale ) { assert ( m_pConstDef ); assert ( m_pParser ); @@ -802,7 +802,7 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok ) for ( item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item ) { int iStart = m_iPos; - if ( ( *item ) ( m_strFormula.mid ( m_iPos ), &m_iPos, &fVal ) == 1 ) + if ( ( *item ) ( m_strFormula.mid ( m_iPos ), &m_iPos, &fVal, s_locale ) == 1 ) { // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 strTok = m_strFormula.mid ( iStart, m_iPos-iStart ); diff --git a/src/libs/qmuparser/qmuparsertokenreader.h b/src/libs/qmuparser/qmuparsertokenreader.h index 43d08106e..5a28e5136 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.h +++ b/src/libs/qmuparser/qmuparsertokenreader.h @@ -58,7 +58,7 @@ public: QChar GetArgSep() const; void IgnoreUndefVar(bool bIgnore); void ReInit(); - token_type ReadNextToken(); + token_type ReadNextToken(const std::locale &s_locale); private: /** @@ -103,7 +103,7 @@ private: bool IsFunTok(token_type &a_Tok); bool IsPostOpTok(token_type &a_Tok); bool IsOprt(token_type &a_Tok); - bool IsValTok(token_type &a_Tok); + bool IsValTok(token_type &a_Tok, const std::locale &s_locale); bool IsVarTok(token_type &a_Tok); bool IsStrVarTok(token_type &a_Tok); bool IsUndefVarTok(token_type &a_Tok); From 7176bd0668f9fb0f7d3d81b1a757969639329fdf Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 13:51:51 +0200 Subject: [PATCH 02/10] Bug in VFormula class. SetFormula was broken. --HG-- branch : feature --- src/app/container/vformula.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp index fa345e4a5..247ed1ab7 100644 --- a/src/app/container/vformula.cpp +++ b/src/app/container/vformula.cpp @@ -113,11 +113,11 @@ void VFormula::SetFormula(const QString &value, FormulaType type) { if (type == FormulaType::ToUser) { - formula = value; + formula = qApp->FormulaToUser(value); } else { - formula = qApp->FormulaToUser(value); + formula = value; } formula.replace("\n", " ");// Replace line return with spaces for calc if exist Eval(); From 420f2e1da7a7a84f7e051ff53fc04d5c90ee6f46 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 14:46:11 +0200 Subject: [PATCH 03/10] "," can't be argument separator in C locale. Parser will return error for big numbers. --HG-- branch : feature --- src/app/container/calculator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index 0e984658b..dc0796c7d 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -245,7 +245,8 @@ qreal* Calculator::AddVariable(const QString &a_szName, void *a_pUserData) */ void Calculator::SetSepForEval() { - SetArgSep(','); + SetArgSep(';'); + SetThousandsSep(','); SetDecSep('.'); } From cfc2b187f6366672204f99811f613a6e562ed9cc Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 15:17:18 +0200 Subject: [PATCH 04/10] Dialogs don't return correct formulas. --HG-- branch : feature --- src/app/dialogs/tools/dialogarc.cpp | 8 ++++---- src/app/dialogs/tools/dialogpointofcontact.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 726a05d27..778f64c9e 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -191,7 +191,7 @@ void DialogArc::SetF1(const QString &value) */ void DialogArc::SetRadius(const QString &value) { - radius = value; + radius = qApp->FormulaToUser(value); // increase height if needed. if (radius.length() > 80) { @@ -443,7 +443,7 @@ quint32 DialogArc::GetCenter() const */ QString DialogArc::GetRadius() const { - return radius; + return qApp->FormulaFromUser(radius); } //--------------------------------------------------------------------------------------------------------------------- @@ -453,7 +453,7 @@ QString DialogArc::GetRadius() const */ QString DialogArc::GetF1() const { - return f1; + return qApp->FormulaFromUser(f1); } //--------------------------------------------------------------------------------------------------------------------- @@ -463,5 +463,5 @@ QString DialogArc::GetF1() const */ QString DialogArc::GetF2() const { - return f2; + return qApp->FormulaFromUser(f2); } diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index 94046df76..84328c2f3 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -271,7 +271,7 @@ void DialogPointOfContact::setCenter(const quint32 &value) */ void DialogPointOfContact::setRadius(const QString &value) { - radius = value; + radius = qApp->FormulaToUser(value); // increase height if needed. if (radius.length() > 80) { @@ -300,7 +300,7 @@ void DialogPointOfContact::SetPointName(const QString &value) */ QString DialogPointOfContact::getRadius() const { - return radius; + return qApp->FormulaFromUser(radius); } //--------------------------------------------------------------------------------------------------------------------- From a12eb73bece76440747c127b6ca92f609bb7410a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 19:50:47 +0200 Subject: [PATCH 05/10] Dynamic update tool property browser after applying options changes. --HG-- branch : feature --- src/app/dialogs/app/configdialog.cpp | 1 + src/app/dialogs/app/configdialog.h | 2 ++ src/app/mainwindow.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/src/app/dialogs/app/configdialog.cpp b/src/app/dialogs/app/configdialog.cpp index 52bc5d5f0..c210cdf12 100644 --- a/src/app/dialogs/app/configdialog.cpp +++ b/src/app/dialogs/app/configdialog.cpp @@ -156,6 +156,7 @@ void ConfigDialog::Apply() default: break; } + emit UpdateProperties(); setResult(QDialog::Accepted); } diff --git a/src/app/dialogs/app/configdialog.h b/src/app/dialogs/app/configdialog.h index 8045a33d2..1c93a6ab6 100644 --- a/src/app/dialogs/app/configdialog.h +++ b/src/app/dialogs/app/configdialog.h @@ -43,6 +43,8 @@ public: explicit ConfigDialog(QWidget *parent = nullptr); public slots: void changePage(QListWidgetItem *current, QListWidgetItem *previous); +signals: + void UpdateProperties(); protected: virtual void closeEvent(QCloseEvent *event); private: diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index de93e055c..56b43ca2b 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1402,6 +1402,7 @@ void MainWindow::Open() void MainWindow::Preferences() { ConfigDialog dlg(this); + connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); if (dlg.exec() == QDialog::Accepted) { InitAutoSave(); From 0056ec49e03412e3fbf99adcc1e5c880d4da6979 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 21:27:11 +0200 Subject: [PATCH 06/10] Set locale according to global options. --HG-- branch : feature --- src/app/core/vapplication.cpp | 1 - src/app/core/vapplication.h | 2 +- src/app/dialogs/app/configdialog.cpp | 3 +++ src/app/dialogs/app/dialogaboutapp.cpp | 3 +++ src/app/dialogs/app/dialoghistory.cpp | 3 +++ src/app/dialogs/app/dialogincrements.cpp | 2 ++ src/app/dialogs/app/dialogindividualmeasurements.cpp | 2 ++ src/app/dialogs/app/dialoglayoutprogress.cpp | 4 ++++ src/app/dialogs/app/dialoglayoutsettings.cpp | 3 +++ src/app/dialogs/app/dialogmeasurements.cpp | 4 ++++ src/app/dialogs/app/dialogpatternproperties.cpp | 2 ++ src/app/dialogs/app/dialogpatternxmledit.cpp | 4 +++- src/app/dialogs/app/dialogsavelayout.cpp | 2 ++ src/app/dialogs/app/dialogstandardmeasurements.cpp | 2 ++ src/app/dialogs/app/dialogundo.cpp | 2 ++ src/app/dialogs/tools/dialogtool.cpp | 2 -- src/app/dialogs/tools/dialogtool.h | 2 ++ src/app/mainwindow.cpp | 8 ++++++++ src/app/mainwindow.h | 1 + src/app/tablewindow.cpp | 3 +++ 20 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index 34b5f0ad7..fc4256c2c 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -35,7 +35,6 @@ #include "vmaingraphicsview.h" #include "../container/calculator.h" #include "../version.h" -#include "vsettings.h" #include #include diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index b3e944d05..25f44bf36 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -33,6 +33,7 @@ #include "../options.h" #include "../widgets/vmaingraphicsview.h" #include "../../libs/qmuparser/qmutranslation.h" +#include "vsettings.h" class VApplication;// used in define class QUndoStack; @@ -40,7 +41,6 @@ class VMainGraphicsView; class VMainGraphicsScene; class VPattern; class QFile; -class VSettings; class QLockFile; #if defined(qApp) diff --git a/src/app/dialogs/app/configdialog.cpp b/src/app/dialogs/app/configdialog.cpp index c210cdf12..181b2006a 100644 --- a/src/app/dialogs/app/configdialog.cpp +++ b/src/app/dialogs/app/configdialog.cpp @@ -33,6 +33,7 @@ #include #include #include +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- ConfigDialog::ConfigDialog(QWidget *parent) : @@ -93,6 +94,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) : this->setFixedSize(QSize(750, 550)); this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); } //--------------------------------------------------------------------------------------------------------------------- @@ -156,6 +158,7 @@ void ConfigDialog::Apply() default: break; } + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); emit UpdateProperties(); setResult(QDialog::Accepted); } diff --git a/src/app/dialogs/app/dialogaboutapp.cpp b/src/app/dialogs/app/dialogaboutapp.cpp index 1961177c9..11d8ec5dc 100644 --- a/src/app/dialogs/app/dialogaboutapp.cpp +++ b/src/app/dialogs/app/dialogaboutapp.cpp @@ -33,6 +33,7 @@ #include #include #include "../../options.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- DialogAboutApp::DialogAboutApp(QWidget *parent) : @@ -41,6 +42,8 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION)); ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION)); ui->label_QT_Version->setText(buildCompatibilityString()); diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 6e70e1b97..b284365ad 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -49,6 +49,9 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) cursorToolRecordRow(0) { ui->setupUi(this); + + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); FillTable(); diff --git a/src/app/dialogs/app/dialogincrements.cpp b/src/app/dialogs/app/dialogincrements.cpp index 62f5d47fb..809bbce06 100644 --- a/src/app/dialogs/app/dialogincrements.cpp +++ b/src/app/dialogs/app/dialogincrements.cpp @@ -55,6 +55,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + qCDebug(vDialog)<<"Showing variables."; if (qApp->patternType() == MeasurementsType::Individual) { diff --git a/src/app/dialogs/app/dialogindividualmeasurements.cpp b/src/app/dialogs/app/dialogindividualmeasurements.cpp index 8fedf9f43..f85925557 100644 --- a/src/app/dialogs/app/dialogindividualmeasurements.cpp +++ b/src/app/dialogs/app/dialogindividualmeasurements.cpp @@ -47,6 +47,8 @@ DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, con { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + QRect position = this->frameGeometry(); position.moveCenter(QDesktopWidget().availableGeometry().center()); move(position.topLeft()); diff --git a/src/app/dialogs/app/dialoglayoutprogress.cpp b/src/app/dialogs/app/dialoglayoutprogress.cpp index d7d5fb620..7244cdbb5 100644 --- a/src/app/dialogs/app/dialoglayoutprogress.cpp +++ b/src/app/dialogs/app/dialoglayoutprogress.cpp @@ -29,6 +29,7 @@ #include "dialoglayoutprogress.h" #include "ui_dialoglayoutprogress.h" #include "../options.h" +#include "../core/vapplication.h" #include #include @@ -38,6 +39,9 @@ DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent) :QDialog(parent), ui(new Ui::DialogLayoutProgress) { ui->setupUi(this); + + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + ui->progressBar->setMaximum(count); ui->progressBar->setValue(0); diff --git a/src/app/dialogs/app/dialoglayoutsettings.cpp b/src/app/dialogs/app/dialoglayoutsettings.cpp index a96b4a30f..2d81b2d33 100644 --- a/src/app/dialogs/app/dialoglayoutsettings.cpp +++ b/src/app/dialogs/app/dialoglayoutsettings.cpp @@ -42,6 +42,9 @@ DialogLayoutSettings::DialogLayoutSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogLayoutSettings), oldPaperUnit(Unit::Mm), oldLayoutUnit(Unit::Mm) { ui->setupUi(this); + + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + InitPaperUnits(); InitLayoutUnits(); InitTemplates(); diff --git a/src/app/dialogs/app/dialogmeasurements.cpp b/src/app/dialogs/app/dialogmeasurements.cpp index af84fc440..f58ed626f 100644 --- a/src/app/dialogs/app/dialogmeasurements.cpp +++ b/src/app/dialogs/app/dialogmeasurements.cpp @@ -28,12 +28,16 @@ #include "dialogmeasurements.h" #include "ui_dialogmeasurements.h" +#include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- DialogMeasurements::DialogMeasurements(QWidget *parent) : QDialog(parent), ui(new Ui::DialogMeasurements), result(MeasurementsType::Individual) { ui->setupUi(this); + + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + connect(ui->toolButtonStandard, &QToolButton::clicked, this, &DialogMeasurements::StandardMeasurements); connect(ui->toolButtonIndividual, &QToolButton::clicked, this, &DialogMeasurements::IndividualMeasurements); } diff --git a/src/app/dialogs/app/dialogpatternproperties.cpp b/src/app/dialogs/app/dialogpatternproperties.cpp index 51e68a418..3229aceda 100644 --- a/src/app/dialogs/app/dialogpatternproperties.cpp +++ b/src/app/dialogs/app/dialogpatternproperties.cpp @@ -45,6 +45,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) SCASSERT(doc != nullptr); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + ui->lineEditAuthor->setText(doc->GetAuthor()); connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited); diff --git a/src/app/dialogs/app/dialogpatternxmledit.cpp b/src/app/dialogs/app/dialogpatternxmledit.cpp index 6339ff47c..2e4701137 100644 --- a/src/app/dialogs/app/dialogpatternxmledit.cpp +++ b/src/app/dialogs/app/dialogpatternxmledit.cpp @@ -28,6 +28,7 @@ #include "dialogpatternxmledit.h" #include "ui_dialogpatternxmledit.h" +#include "../core/vapplication.h" #include #include @@ -36,7 +37,6 @@ const short int DialogPatternXmlEdit::ChangeTypeDelete=1; const short int DialogPatternXmlEdit::ChangeTypeAdd=2; const short int DialogPatternXmlEdit::ChangeTypeModify=3; - //--------------------------------------------------------------------------------------------------------------------- DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc) :QDialog(parent), treeChange(false), currentNodeEdited(nullptr), currentNodeEditedStatus(0), @@ -46,6 +46,8 @@ DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc) { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + this->xmlmodel = new VXMLTreeView(); this->doc=xmldoc; this->root = this->doc->documentElement(); diff --git a/src/app/dialogs/app/dialogsavelayout.cpp b/src/app/dialogs/app/dialogsavelayout.cpp index 3a427a76b..94b3c55ab 100644 --- a/src/app/dialogs/app/dialogsavelayout.cpp +++ b/src/app/dialogs/app/dialogsavelayout.cpp @@ -43,6 +43,8 @@ DialogSaveLayout::DialogSaveLayout(const QMap &formates, int c { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr); bOk->setEnabled(false); diff --git a/src/app/dialogs/app/dialogstandardmeasurements.cpp b/src/app/dialogs/app/dialogstandardmeasurements.cpp index f3a8fc4f1..5b4bc433b 100644 --- a/src/app/dialogs/app/dialogstandardmeasurements.cpp +++ b/src/app/dialogs/app/dialogstandardmeasurements.cpp @@ -46,6 +46,8 @@ DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const Q { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + QRect position = this->frameGeometry(); position.moveCenter(QDesktopWidget().availableGeometry().center()); move(position.topLeft()); diff --git a/src/app/dialogs/app/dialogundo.cpp b/src/app/dialogs/app/dialogundo.cpp index 705adee55..a26fff415 100644 --- a/src/app/dialogs/app/dialogundo.cpp +++ b/src/app/dialogs/app/dialogundo.cpp @@ -39,6 +39,8 @@ DialogUndo::DialogUndo(QWidget *parent) { ui->setupUi(this); + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + bool opening = qApp->getOpeningPattern(); if (opening) { diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 4605dff65..043c49042 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -34,8 +34,6 @@ #include "../../geometry/vsplinepath.h" #include "../../tools/vabstracttool.h" #include "../../../libs/qmuparser/qmuparsererror.h" -#include "../../core/vapplication.h" -#include "../../core/vsettings.h" #include "../../libs/ifc/xml/vdomdocument.h" #include #include diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 8cd7cece1..191195b6d 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -321,6 +321,8 @@ protected: QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel); SCASSERT(bCancel != nullptr); connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected); + + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); } template /** diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 56b43ca2b..b06ca4732 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -84,6 +84,7 @@ MainWindow::MainWindow(QWidget *parent) recentFileActs[i] = nullptr; } + WindowsLocale(); CreateActions(); CreateMenus(); ToolBarDraws(); @@ -1403,6 +1404,7 @@ void MainWindow::Preferences() { ConfigDialog dlg(this); connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); + connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); if (dlg.exec() == QDialog::Accepted) { InitAutoSave(); @@ -2474,6 +2476,12 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const return restoreFiles; } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::WindowsLocale() +{ + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ReopenFilesAfterCrash(QStringList &args) { diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 3e1a2c210..8cb40ce60 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -130,6 +130,7 @@ public slots: void Layout(); void UpdateGradation(); void GlobalChangePP(const QString &patternPiece); + void WindowsLocale(); signals: /** * @brief ModelChosen emit after calculation all details. diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index 30649add5..c2fa61c10 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -60,6 +60,9 @@ TableWindow::TableWindow(QWidget *parent) description(QString()), tempScene(nullptr) { ui->setupUi(this); + + qApp->getSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + tempScene = new QGraphicsScene(QRectF(0, 0, qApp->toPixel(823, Unit::Mm), qApp->toPixel(1171, Unit::Mm))); QBrush brush; brush.setStyle( Qt::SolidPattern ); From 0459fccee0614cd2811d6a47a02da37ca34e047f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 10 Feb 2015 22:09:44 +0200 Subject: [PATCH 07/10] Convert number to string according to locale options. --HG-- branch : feature --- src/app/container/vformula.cpp | 11 +---------- src/app/core/vapplication.h | 10 ++++++++++ src/app/dialogs/tools/dialogtool.cpp | 11 +---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp index 247ed1ab7..5b846bbad 100644 --- a/src/app/container/vformula.cpp +++ b/src/app/container/vformula.cpp @@ -239,17 +239,8 @@ void VFormula::Eval() } else { - QLocale loc; - if (qApp->getSettings()->GetOsSeparator()) - { - loc = QLocale::system(); - } - else - { - loc = QLocale(QLocale::C); - } dValue = result; - value = QString(loc.toString(result) + " " + postfix); + value = QString(qApp->LocaleToString(result) + " " + postfix); _error = false; } } diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index 25f44bf36..6ddbd683f 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -81,8 +81,18 @@ public: QString GuiText(const QString &measurement) const; QString Description(const QString &measurement) const; QString PostfixOperator(const QString &name) const; + QString FormulaFromUser(const QString &formula); QString FormulaToUser(const QString &formula); + + template + QString LocaleToString(const T &value) + { + QLocale loc; + qApp->getSettings()->GetOsSeparator() ? loc = QLocale::system() : loc = QLocale(QLocale::C); + return loc.toString(value); + } + QUndoStack *getUndoStack() const; VMainGraphicsView *getSceneView() const; void setSceneView(VMainGraphicsView *value); diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 043c49042..41be6369c 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -500,16 +500,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt } else { - QLocale loc; - if (qApp->getSettings()->GetOsSeparator()) - { - loc = QLocale::system(); - } - else - { - loc = QLocale(QLocale::C); - } - label->setText(loc.toString(result) + " " +postfix); + label->setText(qApp->LocaleToString(result) + " " +postfix); flag = true; ChangeColor(labelEditFormula, okColor); label->setToolTip(tr("Value")); From 2726bd4eb6e70bb8714e80458161083008888a43 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 11 Feb 2015 11:11:49 +0200 Subject: [PATCH 08/10] Global locale settings in dialog increments. --HG-- branch : feature --- src/app/dialogs/app/dialogincrements.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/dialogs/app/dialogincrements.cpp b/src/app/dialogs/app/dialogincrements.cpp index 809bbce06..e3f68a768 100644 --- a/src/app/dialogs/app/dialogincrements.cpp +++ b/src/app/dialogs/app/dialogincrements.cpp @@ -179,14 +179,14 @@ void DialogIncrements::FillMeasurements() if (qApp->patternType() == MeasurementsType::Standard) { - QTableWidgetItem *item = new QTableWidgetItem(QString() - .setNum(data->GetTableValue(qApp->VarFromUser(iMap.key())))); + QTableWidgetItem *item = new QTableWidgetItem(qApp->LocaleToString( + data->GetTableValue(qApp->VarFromUser(iMap.key())))); item->setTextAlignment(Qt::AlignHCenter); SetItemViewOnly(item); ui->tableWidgetMeasurements->setItem(currentRow, 1, item);// calculated value } - item = new QTableWidgetItem(QString().setNum(m->GetBase())); + item = new QTableWidgetItem(qApp->LocaleToString(m->GetBase())); item->setTextAlignment(Qt::AlignHCenter); if (qApp->patternType() == MeasurementsType::Standard) { @@ -196,12 +196,12 @@ void DialogIncrements::FillMeasurements() if (qApp->patternType() == MeasurementsType::Standard) { - QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m->GetKsize())); + QTableWidgetItem *item = new QTableWidgetItem(qApp->LocaleToString(m->GetKsize())); item->setTextAlignment(Qt::AlignHCenter); SetItemViewOnly(item); ui->tableWidgetMeasurements->setItem(currentRow, 3, item);// in sizes - item = new QTableWidgetItem(QString().setNum(m->GetKheight())); + item = new QTableWidgetItem(qApp->LocaleToString(m->GetKheight())); item->setTextAlignment(Qt::AlignHCenter); SetItemViewOnly(item); ui->tableWidgetMeasurements->setItem(currentRow, 4, item);// in heights @@ -252,23 +252,23 @@ void DialogIncrements::FillIncrements() if (qApp->patternType() == MeasurementsType::Standard) { - item = new QTableWidgetItem(QString().setNum(data->GetTableValue(iMap.value()))); + item = new QTableWidgetItem(qApp->LocaleToString(data->GetTableValue(iMap.value()))); item->setTextAlignment(Qt::AlignHCenter); SetItemViewOnly(item); ui->tableWidgetIncrement->setItem(currentRow, 1, item); } - item = new QTableWidgetItem(QString().setNum(incr->GetBase())); + item = new QTableWidgetItem(qApp->LocaleToString(incr->GetBase())); item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetIncrement->setItem(currentRow, 2, item); if (qApp->patternType() == MeasurementsType::Standard) { - item = new QTableWidgetItem(QString().setNum(incr->GetKsize())); + item = new QTableWidgetItem(qApp->LocaleToString(incr->GetKsize())); item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetIncrement->setItem(currentRow, 3, item); - item = new QTableWidgetItem(QString().setNum(incr->GetKheight())); + item = new QTableWidgetItem(qApp->LocaleToString(incr->GetKheight())); item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetIncrement->setItem(currentRow, 4, item); } @@ -307,7 +307,7 @@ void DialogIncrements::FillTable(const QMap varTable, QTableWidget * item->setFont(QFont("Times", 12, QFont::Bold)); table->setItem(currentRow, 0, item); - item = new QTableWidgetItem(QString().setNum(length)); + item = new QTableWidgetItem(qApp->LocaleToString(length)); item->setTextAlignment(Qt::AlignHCenter); table->setItem(currentRow, 1, item); } From f6e511e43c8a3d8742c309bd14d6b05fc28d8747 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 11 Feb 2015 12:33:13 +0200 Subject: [PATCH 09/10] Set and dynamically refresh locale settings for tool property browser. --HG-- branch : feature --- src/app/mainwindow.cpp | 7 ++++--- src/app/widgets/doubledelegate.cpp | 1 + src/app/widgets/textdelegate.cpp | 1 + src/app/widgets/vformulaproperty.cpp | 2 +- src/app/widgets/vtooloptionspropertybrowser.cpp | 8 ++++++++ src/app/widgets/vtooloptionspropertybrowser.h | 1 + src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/venumproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vfileproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp | 2 ++ src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp | 2 +- src/libs/vpropertyexplorer/plugins/vstringproperty.cpp | 1 + 15 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index b06ca4732..9e35e4b2d 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -84,7 +84,6 @@ MainWindow::MainWindow(QWidget *parent) recentFileActs[i] = nullptr; } - WindowsLocale(); CreateActions(); CreateMenus(); ToolBarDraws(); @@ -135,6 +134,7 @@ MainWindow::MainWindow(QWidget *parent) PropertyBrowser(); setCurrentFile(""); + WindowsLocale(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1144,6 +1144,7 @@ void MainWindow::ArrowTool() ui->actionArrowTool->setChecked(true); ui->actionStopTool->setEnabled(false); tool = Tool::Arrow; + emit EnableItemMove(true); QCursor cur(Qt::ArrowCursor); ui->view->setCursor(cur); helpLabel->setText(""); @@ -1403,8 +1404,8 @@ void MainWindow::Open() void MainWindow::Preferences() { ConfigDialog dlg(this); - connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); - connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); + connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first + connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); if (dlg.exec() == QDialog::Accepted) { InitAutoSave(); diff --git a/src/app/widgets/doubledelegate.cpp b/src/app/widgets/doubledelegate.cpp index 981ad3d0d..f375376a6 100644 --- a/src/app/widgets/doubledelegate.cpp +++ b/src/app/widgets/doubledelegate.cpp @@ -53,6 +53,7 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption Q_UNUSED(index); emit NewLastValue(-10001.0);//Here need reset value to default because we begin work with new item QDoubleSpinBox *editor = new QDoubleSpinBox(parent); + editor->setLocale(parent->locale()); editor->setMinimum(-10000.0); editor->setMaximum(10000.0); connect(editor, &QDoubleSpinBox::editingFinished, this, &DoubleSpinBoxDelegate::commitAndCloseEditor); diff --git a/src/app/widgets/textdelegate.cpp b/src/app/widgets/textdelegate.cpp index 296dd1507..a02fadece 100644 --- a/src/app/widgets/textdelegate.cpp +++ b/src/app/widgets/textdelegate.cpp @@ -58,6 +58,7 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem Q_UNUSED(option); Q_UNUSED(index); QLineEdit *editor = new QLineEdit(parent); + editor->setLocale(parent->locale()); //Same regex pattern in xsd file editor->setValidator( new QRegExpValidator(QRegExp(regex)) ); connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor); diff --git a/src/app/widgets/vformulaproperty.cpp b/src/app/widgets/vformulaproperty.cpp index 09fbd2057..4e32e8bf9 100644 --- a/src/app/widgets/vformulaproperty.cpp +++ b/src/app/widgets/vformulaproperty.cpp @@ -94,7 +94,7 @@ QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewI VFormula formula = VProperty::d_ptr->VariantValue.value(); VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent); - + tmpEditor->setLocale(parent->locale()); tmpEditor->SetFormula(formula); VProperty::d_ptr->editor = tmpEditor; return VProperty::d_ptr->editor; diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index d565d45e5..63dff0c6c 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -232,6 +232,14 @@ void VToolOptionsPropertyBrowser::UpdateOptions() } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::RefreshOptions() +{ + QGraphicsItem *item = currentItem; + itemClicked(nullptr);//close options + itemClicked(item);//reopen options +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) { diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h index 50a4d9ed8..4e28e7a5f 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.h +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -51,6 +51,7 @@ public slots: void itemClicked(QGraphicsItem *item); void userChangedData(VPE::VProperty* property); void UpdateOptions(); + void RefreshOptions(); private: Q_DISABLE_COPY(VToolOptionsPropertyBrowser) diff --git a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp index 38a1791a9..fc27d18f2 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp @@ -58,6 +58,7 @@ QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewIte Q_UNUSED(delegate); VColorPropertyEditor* tmpWidget = new VColorPropertyEditor(parent); + tmpWidget->setLocale(parent->locale()); tmpWidget->SetColor(d_ptr->VariantValue.value()); return tmpWidget; } diff --git a/src/libs/vpropertyexplorer/plugins/venumproperty.cpp b/src/libs/vpropertyexplorer/plugins/venumproperty.cpp index 30330044d..14d3d5ea7 100644 --- a/src/libs/vpropertyexplorer/plugins/venumproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/venumproperty.cpp @@ -70,6 +70,7 @@ QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewIte Q_UNUSED(delegate); QComboBox* tmpEditor = new QComboBox(parent); tmpEditor->clear(); + tmpEditor->setLocale(parent->locale()); tmpEditor->addItems(EnumerationLiterals); tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt()); connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, diff --git a/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp b/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp index 4434675d0..8e965fabf 100644 --- a/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp @@ -87,6 +87,7 @@ QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewIte VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*))); } + tmpWidget->setLocale(parent->locale()); tmpWidget->setFilter(static_cast(d_ptr)->FileFilters); // todo: parse this string tmpWidget->setFile(d_ptr->VariantValue.toString()); tmpWidget->setDirectory(static_cast(d_ptr)->Directory); diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp index f4fce1de4..58c03b877 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp @@ -86,6 +86,7 @@ QWidget *VLineColorProperty::createEditor(QWidget *parent, const QStyleOptionVie ++i; } + tmpEditor->setLocale(parent->locale()); tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt()); connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, &VLineColorProperty::currentIndexChanged); diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp index a5305dbee..c449096fd 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp @@ -76,6 +76,7 @@ QWidget *VLineTypeProperty::createEditor(QWidget *parent, const QStyleOptionView Q_UNUSED(delegate); QComboBox* tmpEditor = new QComboBox(parent); tmpEditor->clear(); + tmpEditor->setLocale(parent->locale()); tmpEditor->setIconSize(QSize(80, 14)); tmpEditor->setMinimumWidth(80); tmpEditor->setMaximumWidth(110); diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp index b86def022..65ee10a1a 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp @@ -56,6 +56,7 @@ QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionView Q_UNUSED(delegate); QSpinBox* tmpEditor = new QSpinBox(parent); + tmpEditor->setLocale(parent->locale()); tmpEditor->setMinimum(static_cast(minValue)); tmpEditor->setMaximum(static_cast(maxValue)); tmpEditor->setSingleStep(static_cast(singleStep)); @@ -162,6 +163,7 @@ QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewI Q_UNUSED(options); Q_UNUSED(delegate); QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent); + tmpEditor->setLocale(parent->locale()); tmpEditor->setMinimum(minValue); tmpEditor->setMaximum(maxValue); tmpEditor->setDecimals(Precision); diff --git a/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp b/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp index 513d8d812..d117e764e 100644 --- a/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp @@ -64,6 +64,7 @@ QWidget* VObjectProperty::createEditor(QWidget * parent, const QStyleOptionViewI Q_UNUSED(delegate); QComboBox* tmpEditor = new QComboBox(parent); tmpEditor->clear(); + tmpEditor->setLocale(parent->locale()); FillList(tmpEditor, objects); tmpEditor->setCurrentIndex(tmpEditor->findData(VProperty::d_ptr->VariantValue.toUInt())); connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp index f51346d54..6d10a23f2 100644 --- a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp @@ -61,7 +61,7 @@ QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionVie { VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*))); } - + tmpWidget->setLocale(parent->locale()); return tmpWidget; } diff --git a/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp b/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp index d4bac678c..08341ded4 100644 --- a/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp @@ -50,6 +50,7 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV Q_UNUSED(delegate); QLineEdit* tmpEditor = new QLineEdit(parent); + tmpEditor->setLocale(parent->locale()); tmpEditor->setReadOnly(readOnly); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setText(d_ptr->VariantValue.toString()); From 28f806a77908a59c317ddd9aa754dfb8e7541c08 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 11 Feb 2015 12:43:50 +0200 Subject: [PATCH 10/10] Refactoring. More good looking code. --HG-- branch : feature --- src/app/dialogs/app/dialoghistory.cpp | 2 +- src/app/dialogs/app/dialogincrements.cpp | 4 ++-- src/app/tools/drawTools/vdrawtool.cpp | 6 +++--- src/app/tools/drawTools/vtoolcut.cpp | 2 +- src/app/tools/drawTools/vtoolline.cpp | 2 +- src/app/tools/drawTools/vtoolsplinepath.cpp | 2 +- src/app/tools/nodeDetails/vabstractnode.cpp | 2 +- src/app/tools/nodeDetails/vnodearc.cpp | 2 +- src/app/tools/nodeDetails/vnodepoint.cpp | 4 ++-- src/app/tools/nodeDetails/vnodespline.cpp | 2 +- src/app/tools/nodeDetails/vnodesplinepath.cpp | 2 +- src/app/tools/vabstracttool.cpp | 2 +- src/app/tools/vtooldetail.cpp | 2 +- src/app/tools/vtooluniondetails.cpp | 2 +- src/app/undocommands/adddet.cpp | 2 +- src/app/undocommands/adddetnode.cpp | 2 +- src/app/undocommands/addtocalc.cpp | 4 ++-- src/app/undocommands/adduniondetails.cpp | 2 +- src/app/undocommands/deletedetail.cpp | 4 ++-- src/app/undocommands/movedetail.cpp | 6 +++--- src/app/undocommands/movelabel.cpp | 4 ++-- src/app/undocommands/movespline.cpp | 2 +- src/app/undocommands/movesplinepath.cpp | 2 +- src/app/undocommands/movespoint.cpp | 4 ++-- src/app/undocommands/savedetailoptions.cpp | 4 ++-- src/app/undocommands/savetooloptions.cpp | 4 ++-- src/libs/ifc/xml/vdomdocument.cpp | 6 ++++++ src/libs/ifc/xml/vdomdocument.h | 1 + 28 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index b284365ad..e906cd494 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -200,7 +200,7 @@ void DialogHistory::FillTable() */ QString DialogHistory::Record(const VToolRecord &tool) { - const QDomElement domElem = doc->elementById(QString().setNum(tool.getId())); + const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) { qDebug()<<"Can't find element by id"<RemoveIncrement(itemName->text()); quint32 id = qvariant_cast(itemName->data(Qt::UserRole)); - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements); @@ -750,7 +750,7 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column ) const QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0); const QTableWidgetItem *item = ui->tableWidgetIncrement->item(row, column); const quint32 id = qvariant_cast(itemName->data(Qt::UserRole)); - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement() == false) { qCDebug(vDialog)<<"Cant't find increment with id = "<elementById(QString().setNum(id)); + QDomElement oldDomElement = doc->elementById(id); if (oldDomElement.isElement()) { QDomElement newDomElement = oldDomElement.cloneNode().toElement(); @@ -148,7 +148,7 @@ void VDrawTool::AddToFile() */ void VDrawTool::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { QSharedPointer obj = VAbstractTool::data.GetGObject(id); @@ -176,7 +176,7 @@ QColor VDrawTool::CorrectColor(const QColor &color) const //--------------------------------------------------------------------------------------------------------------------- void VDrawTool::ReadAttributes() { - const QDomElement domElement = doc->elementById(QString().setNum(id)); + const QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { ReadToolAttributes(domElement); diff --git a/src/app/tools/drawTools/vtoolcut.cpp b/src/app/tools/drawTools/vtoolcut.cpp index 192fc1e69..7eefbc110 100644 --- a/src/app/tools/drawTools/vtoolcut.cpp +++ b/src/app/tools/drawTools/vtoolcut.cpp @@ -146,7 +146,7 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve) { Q_ASSERT_X(attrCurve.isEmpty() == false, Q_FUNC_INFO, "attribute name is empty"); - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { formula = domElement.attribute(AttrLength, ""); diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index 1f879afb9..8f9f8003e 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -275,7 +275,7 @@ void VToolLine::AddToFile() */ void VToolLine::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { QSharedPointer obj = QSharedPointer (); diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 7c82241a8..9c7b4157f 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -335,7 +335,7 @@ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolSplinePath::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement() == false) { qDebug()<<"Can't find element with id="<DecrementReferens(idNode); - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { QDomNode element = domElement.parentNode(); diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp index d7c0aeb68..865671106 100644 --- a/src/app/tools/nodeDetails/vnodearc.cpp +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -164,7 +164,7 @@ void VNodeArc::AddToFile() */ void VNodeArc::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, idNode); diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index 952d1e4e6..638ef3277 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -180,7 +180,7 @@ void VNodePoint::AddToFile() void VNodePoint::RefreshDataInFile() { const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, idNode); @@ -253,7 +253,7 @@ void VNodePoint::NameChangePosition(const QPointF &pos) */ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx))); diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp index a83545287..0982190d7 100644 --- a/src/app/tools/nodeDetails/vnodespline.cpp +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -167,7 +167,7 @@ void VNodeSpline::AddToFile() */ void VNodeSpline::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp index a2654e473..7b8c3f5da 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -170,7 +170,7 @@ void VNodeSplinePath::AddToFile() */ void VNodeSplinePath::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 194c5b5c7..d01708581 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -310,7 +310,7 @@ int VAbstractTool::ConfirmDeletion() void VAbstractTool::SaveOption(QSharedPointer &obj) { qCDebug(vTool)<<"Saving tool options"; - QDomElement oldDomElement = doc->elementById(QString().setNum(id)); + QDomElement oldDomElement = doc->elementById(id); if (oldDomElement.isElement()) { QDomElement newDomElement = oldDomElement.cloneNode().toElement(); diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index 744f8a8a1..cab1ed4b5 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -304,7 +304,7 @@ void VToolDetail::AddToFile() */ void VToolDetail::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { VDetail det = VAbstractTool::data.GetDetail(id); diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index 32350ad1d..087afa9f3 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -750,7 +750,7 @@ void VToolUnionDetails::AddToFile() */ void VToolUnionDetails::RefreshDataInFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIndexD1, indexD1); diff --git a/src/app/undocommands/adddet.cpp b/src/app/undocommands/adddet.cpp index de773f50d..8641c05c5 100644 --- a/src/app/undocommands/adddet.cpp +++ b/src/app/undocommands/adddet.cpp @@ -50,7 +50,7 @@ void AddDet::undo() QDomElement element; if (doc->GetActivNodeElement(VPattern::TagDetails, element)) { - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { if (element.removeChild(domElement).isNull()) diff --git a/src/app/undocommands/adddetnode.cpp b/src/app/undocommands/adddetnode.cpp index fc483ed0c..993c7a00a 100644 --- a/src/app/undocommands/adddetnode.cpp +++ b/src/app/undocommands/adddetnode.cpp @@ -49,7 +49,7 @@ void AddDetNode::undo() QDomElement modelingElement; if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement)) { - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { if (modelingElement.removeChild(domElement).isNull()) diff --git a/src/app/undocommands/addtocalc.cpp b/src/app/undocommands/addtocalc.cpp index 87f205c1f..30cbb631a 100644 --- a/src/app/undocommands/addtocalc.cpp +++ b/src/app/undocommands/addtocalc.cpp @@ -56,7 +56,7 @@ void AddToCalc::undo() QDomElement calcElement; if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement)) { - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { if (calcElement.removeChild(domElement).isNull()) @@ -102,7 +102,7 @@ void AddToCalc::redo() } else { - QDomElement refElement = doc->elementById(QString().setNum(cursor)); + QDomElement refElement = doc->elementById(cursor); if (refElement.isElement()) { calcElement.insertAfter(xml, refElement); diff --git a/src/app/undocommands/adduniondetails.cpp b/src/app/undocommands/adduniondetails.cpp index 9f5a8549e..e5ed9f1e3 100644 --- a/src/app/undocommands/adduniondetails.cpp +++ b/src/app/undocommands/adduniondetails.cpp @@ -49,7 +49,7 @@ void AddUnionDetails::undo() QDomElement modelingElement; if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement)) { - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { if (modelingElement.removeChild(domElement).isNull()) diff --git a/src/app/undocommands/deletedetail.cpp b/src/app/undocommands/deletedetail.cpp index a67794df3..fd7fecac7 100644 --- a/src/app/undocommands/deletedetail.cpp +++ b/src/app/undocommands/deletedetail.cpp @@ -36,7 +36,7 @@ DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent) { setText(tr("Delete tool")); nodeId = id; - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { xml = domElement.cloneNode().toElement(); @@ -77,7 +77,7 @@ void DeleteDetail::redo() { qCDebug(vUndo)<<"Redo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { parentNode.removeChild(domElement); diff --git a/src/app/undocommands/movedetail.cpp b/src/app/undocommands/movedetail.cpp index 8d5b42b16..025457337 100644 --- a/src/app/undocommands/movedetail.cpp +++ b/src/app/undocommands/movedetail.cpp @@ -42,7 +42,7 @@ MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const qu nodeId = id; SCASSERT(scene != nullptr); - QDomElement domElement = doc->elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")); @@ -64,7 +64,7 @@ void MoveDetail::undo() { qCDebug(vUndo)<<"Undo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { SaveCoordinates(domElement, oldX, oldY); @@ -86,7 +86,7 @@ void MoveDetail::redo() { qCDebug(vUndo)<<"Redo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { SaveCoordinates(domElement, newX, newY); diff --git a/src/app/undocommands/movelabel.cpp b/src/app/undocommands/movelabel.cpp index eaada78e2..1d7d3858e 100644 --- a/src/app/undocommands/movelabel.cpp +++ b/src/app/undocommands/movelabel.cpp @@ -46,7 +46,7 @@ MoveLabel::MoveLabel(VPattern *doc, const double &x, const double &y, const quin qCDebug(vUndo)<<"Label new My"<elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")); @@ -114,7 +114,7 @@ void MoveLabel::Do(double mx, double my) qCDebug(vUndo)<<"New mx"<elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(mx))); diff --git a/src/app/undocommands/movespline.cpp b/src/app/undocommands/movespline.cpp index a59ac23c8..2b1eddfe4 100644 --- a/src/app/undocommands/movespline.cpp +++ b/src/app/undocommands/movespline.cpp @@ -88,7 +88,7 @@ int MoveSpline::id() const //--------------------------------------------------------------------------------------------------------------------- void MoveSpline::Do(const VSpline &spl) { - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(spl.GetAngle1())); diff --git a/src/app/undocommands/movesplinepath.cpp b/src/app/undocommands/movesplinepath.cpp index 86f72b5a3..44a4e53e9 100644 --- a/src/app/undocommands/movesplinepath.cpp +++ b/src/app/undocommands/movesplinepath.cpp @@ -86,7 +86,7 @@ int MoveSplinePath::id() const //--------------------------------------------------------------------------------------------------------------------- void MoveSplinePath::Do(const VSplinePath &splPath) { - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(splPath.GetKCurve())); diff --git a/src/app/undocommands/movespoint.cpp b/src/app/undocommands/movespoint.cpp index dbc04eaf6..668594e90 100644 --- a/src/app/undocommands/movespoint.cpp +++ b/src/app/undocommands/movespoint.cpp @@ -46,7 +46,7 @@ MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const qu qCDebug(vUndo)<<"SPoint newY"<elementById(QString().setNum(id)); + QDomElement domElement = doc->elementById(id); if (domElement.isElement()) { oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrX, "0.0")); @@ -114,7 +114,7 @@ void MoveSPoint::Do(double x, double y) qCDebug(vUndo)<<"Move to x"<elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(x))); diff --git a/src/app/undocommands/savedetailoptions.cpp b/src/app/undocommands/savedetailoptions.cpp index 4dcb7d8d7..5caa88a8a 100644 --- a/src/app/undocommands/savedetailoptions.cpp +++ b/src/app/undocommands/savedetailoptions.cpp @@ -48,7 +48,7 @@ void SaveDetailOptions::undo() { qCDebug(vUndo)<<"Undo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { SaveDet(domElement, oldDet); @@ -85,7 +85,7 @@ void SaveDetailOptions::redo() { qCDebug(vUndo)<<"Redo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { SaveDet(domElement, newDet); diff --git a/src/app/undocommands/savetooloptions.cpp b/src/app/undocommands/savetooloptions.cpp index a57416c3e..2e9d98dda 100644 --- a/src/app/undocommands/savetooloptions.cpp +++ b/src/app/undocommands/savetooloptions.cpp @@ -48,7 +48,7 @@ void SaveToolOptions::undo() { qCDebug(vUndo)<<"Undo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { domElement.parentNode().replaceChild(oldXml, domElement); @@ -67,7 +67,7 @@ void SaveToolOptions::redo() { qCDebug(vUndo)<<"Redo."; - QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + QDomElement domElement = doc->elementById(nodeId); if (domElement.isElement()) { domElement.parentNode().replaceChild(newXml, domElement); diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 40480bf0f..b48d4abbe 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -134,6 +134,12 @@ QDomElement VDomDocument::elementById(const QString& id) return QDomElement(); } +//--------------------------------------------------------------------------------------------------------------------- +QDomElement VDomDocument::elementById(quint32 id) +{ + return elementById(QString().setNum(id)); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Removes all children of a given element tag. RENAME: removeAllChildren diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 633c33b74..00fba6c8f 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -81,6 +81,7 @@ public: VDomDocument(); virtual ~VDomDocument(); QDomElement elementById(const QString& id); + QDomElement elementById(quint32 id); void removeAllChilds(QDomElement &element); template /**