Refactoring. Move translation variables outside VApplication.
--HG-- branch : feature
This commit is contained in:
parent
6e74a5ac48
commit
a3caf574cb
|
@ -18,7 +18,8 @@ SOURCES += \
|
|||
$$PWD/variables/vcurvevariable.cpp \
|
||||
container/variables/vcurveangle.cpp \
|
||||
container/variables/varcangle.cpp \
|
||||
container/variables/vsplineangle.cpp
|
||||
container/variables/vsplineangle.cpp \
|
||||
container/vtranslatevars.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vcontainer.h \
|
||||
|
@ -45,4 +46,5 @@ HEADERS += \
|
|||
$$PWD/variables/vcurvevariable_p.h \
|
||||
container/variables/vcurveangle.h \
|
||||
container/variables/varcangle.h \
|
||||
container/variables/vsplineangle.h
|
||||
container/variables/vsplineangle.h \
|
||||
container/vtranslatevars.h
|
||||
|
|
|
@ -489,7 +489,7 @@ const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type)
|
|||
if (i.value()->GetType() == type)
|
||||
{
|
||||
QSharedPointer<T> var = GetVariable<T>(i.key());
|
||||
map.insert(qApp->VarToUser(i.key()), var);
|
||||
map.insert(qApp->TrVars()->VarToUser(i.key()), var);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
|
|
@ -42,7 +42,7 @@ VFormula::VFormula()
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula::VFormula(const QString &formula, const VContainer *container)
|
||||
:formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container),
|
||||
:formula(qApp->TrVars()->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container),
|
||||
toolId(NULL_ID), postfix(QString()), _error(true), dValue(0)
|
||||
{
|
||||
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
||||
|
@ -102,7 +102,7 @@ QString VFormula::GetFormula(FormulaType type) const
|
|||
}
|
||||
else
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void VFormula::SetFormula(const QString &value, FormulaType type)
|
|||
{
|
||||
if (type == FormulaType::ToUser)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -226,7 +226,7 @@ void VFormula::Eval()
|
|||
try
|
||||
{
|
||||
Calculator *cal = new Calculator(data);
|
||||
QString expression = qApp->FormulaFromUser(formula);
|
||||
QString expression = qApp->TrVars()->FormulaFromUser(formula);
|
||||
const qreal result = cal->EvalFormula(expression);
|
||||
delete cal;
|
||||
|
||||
|
|
1538
src/app/container/vtranslatevars.cpp
Normal file
1538
src/app/container/vtranslatevars.cpp
Normal file
File diff suppressed because it is too large
Load Diff
83
src/app/container/vtranslatevars.h
Normal file
83
src/app/container/vtranslatevars.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtranslatevars.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 10 6, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VTRANSLATEVARS_H
|
||||
#define VTRANSLATEVARS_H
|
||||
|
||||
#include <QMap>
|
||||
#include "../../libs/qmuparser/qmutranslation.h"
|
||||
#include "../core/vsettings.h"
|
||||
|
||||
class VTranslateVars
|
||||
{
|
||||
public:
|
||||
VTranslateVars(const VSettings *settings);
|
||||
~VTranslateVars();
|
||||
|
||||
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
bool PostfixOperatorsFromUser(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;
|
||||
|
||||
QString VarToUser(const QString &var) const;
|
||||
QString VarFromUser(const QString &var) const;
|
||||
|
||||
QString GuiText(const QString &measurement) const;
|
||||
QString Description(const QString &measurement) const;
|
||||
QString PostfixOperator(const QString &name) const;
|
||||
QString STDescription(const QString &id) const;
|
||||
|
||||
QString FormulaFromUser(const QString &formula) const;
|
||||
QString FormulaToUser(const QString &formula) const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VTranslateVars)
|
||||
QMap<QString, qmu::QmuTranslation> measurements;
|
||||
QMap<QString, qmu::QmuTranslation> guiTexts;
|
||||
QMap<QString, qmu::QmuTranslation> descriptions;
|
||||
QMap<QString, qmu::QmuTranslation> variables;
|
||||
QMap<QString, qmu::QmuTranslation> functions;
|
||||
QMap<QString, qmu::QmuTranslation> postfixOperators;
|
||||
QMap<QString, qmu::QmuTranslation> stDescriptions;
|
||||
const VSettings *settings;
|
||||
|
||||
void InitMeasurements();
|
||||
void InitVariables();
|
||||
void InitFunctions();
|
||||
void InitPostfixOperators();
|
||||
void InitSTDescriptions();
|
||||
|
||||
void InitMeasurement(const QString &name, const qmu::QmuTranslation &m, const qmu::QmuTranslation &g,
|
||||
const qmu::QmuTranslation &d);
|
||||
|
||||
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens, QMap<int, QString> &numbers) const;
|
||||
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
|
||||
};
|
||||
|
||||
#endif // VTRANSLATEVARS_H
|
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,7 @@
|
|||
#include <QApplication>
|
||||
#include "../options.h"
|
||||
#include "../widgets/vmaingraphicsview.h"
|
||||
#include "../../libs/qmuparser/qmutranslation.h"
|
||||
#include "../container/vtranslatevars.h"
|
||||
#include "vsettings.h"
|
||||
|
||||
class VApplication;// used in define
|
||||
|
@ -79,14 +79,6 @@ public:
|
|||
QString translationsPath() const;
|
||||
qreal widthMainLine() const;
|
||||
qreal widthHairLine() const;
|
||||
QString VarToUser(const QString &var) const;
|
||||
QString VarFromUser(const QString &var) const;
|
||||
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 <typename T>
|
||||
QString LocaleToString(const T &value)
|
||||
|
@ -119,11 +111,13 @@ public:
|
|||
static void restoreOverrideCursor(const QString & pixmapPath);
|
||||
|
||||
static QStringList LabelLanguages();
|
||||
QString STDescription(const QString &id)const;
|
||||
|
||||
void StartLogging();
|
||||
QTextStream *LogFile();
|
||||
|
||||
const VTranslateVars *TrVars();
|
||||
void InitTrVars();
|
||||
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
static void DrMingw();
|
||||
|
@ -141,13 +135,7 @@ private:
|
|||
MeasurementsType _patternType;
|
||||
qreal _widthMainLine;
|
||||
qreal _widthHairLine;
|
||||
QMap<QString, qmu::QmuTranslation> measurements;
|
||||
QMap<QString, qmu::QmuTranslation> guiTexts;
|
||||
QMap<QString, qmu::QmuTranslation> descriptions;
|
||||
QMap<QString, qmu::QmuTranslation> variables;
|
||||
QMap<QString, qmu::QmuTranslation> functions;
|
||||
QMap<QString, qmu::QmuTranslation> postfixOperators;
|
||||
QMap<QString, qmu::QmuTranslation> stDescriptions;
|
||||
VTranslateVars *trVars;
|
||||
QUndoStack *undoStack;
|
||||
VMainGraphicsView *sceneView;
|
||||
QGraphicsScene *currentScene;
|
||||
|
@ -174,22 +162,6 @@ private:
|
|||
QLockFile *logLock;
|
||||
#endif
|
||||
void InitLineWidth();
|
||||
void InitMeasurements();
|
||||
void InitVariables();
|
||||
void InitFunctions();
|
||||
void InitPostfixOperators();
|
||||
void InitSTDescriptions();
|
||||
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
bool PostfixOperatorsFromUser(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;
|
||||
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
|
||||
QMap<int, QString> &numbers);
|
||||
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
|
||||
void InitMeasurement(const QString &name, const qmu::QmuTranslation &m, const qmu::QmuTranslation &g,
|
||||
const qmu::QmuTranslation &d);
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
static const QString GistFileName;
|
||||
|
|
|
@ -214,7 +214,7 @@ void DialogIncrements::FillMeasurements()
|
|||
if (qApp->patternType() == MeasurementsType::Standard)
|
||||
{
|
||||
QTableWidgetItem *item = new QTableWidgetItem(qApp->LocaleToString(
|
||||
data->GetTableValue(qApp->VarFromUser(iMap.key()))));
|
||||
data->GetTableValue(qApp->TrVars()->VarFromUser(iMap.key()))));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
SetItemViewOnly(item);
|
||||
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);// calculated value
|
||||
|
@ -915,7 +915,8 @@ void DialogIncrements::MeasurementChanged(qint32 row, qint32 column)
|
|||
const QTableWidgetItem *itemName = ui->tableWidgetMeasurements->item(row, 0);// name column
|
||||
QTableWidgetItem *item = ui->tableWidgetMeasurements->item(row, 2);
|
||||
|
||||
QSharedPointer<VMeasurement> measur = data->GetVariable<VMeasurement>(qApp->VarFromUser(itemName->text()));
|
||||
QSharedPointer<VMeasurement> measur = data->GetVariable<VMeasurement>(
|
||||
qApp->TrVars()->VarFromUser(itemName->text()));
|
||||
const QString tag = measur->TagName();
|
||||
QDomNodeList list = m->elementsByTagName(tag);
|
||||
QDomElement domElement = list.at(0).toElement();
|
||||
|
|
|
@ -240,7 +240,7 @@ void DialogAlongLine::SetFirstPointId(const quint32 &value)
|
|||
*/
|
||||
void DialogAlongLine::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ QString DialogAlongLine::GetTypeLine() const
|
|||
*/
|
||||
QString DialogAlongLine::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -134,7 +134,7 @@ void DialogArc::SetCenter(const quint32 &value)
|
|||
*/
|
||||
void DialogArc::SetF2(const QString &value)
|
||||
{
|
||||
f2 = qApp->FormulaToUser(value);
|
||||
f2 = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (f2.length() > 80)
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ void DialogArc::SetColor(const QString &value)
|
|||
*/
|
||||
void DialogArc::SetF1(const QString &value)
|
||||
{
|
||||
f1 = qApp->FormulaToUser(value);
|
||||
f1 = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (f1.length() > 80)
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ void DialogArc::SetF1(const QString &value)
|
|||
*/
|
||||
void DialogArc::SetRadius(const QString &value)
|
||||
{
|
||||
radius = qApp->FormulaToUser(value);
|
||||
radius = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (radius.length() > 80)
|
||||
{
|
||||
|
@ -424,7 +424,7 @@ quint32 DialogArc::GetCenter() const
|
|||
*/
|
||||
QString DialogArc::GetRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(radius);
|
||||
return qApp->TrVars()->FormulaFromUser(radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -434,7 +434,7 @@ QString DialogArc::GetRadius() const
|
|||
*/
|
||||
QString DialogArc::GetF1() const
|
||||
{
|
||||
return qApp->FormulaFromUser(f1);
|
||||
return qApp->TrVars()->FormulaFromUser(f1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -444,5 +444,5 @@ QString DialogArc::GetF1() const
|
|||
*/
|
||||
QString DialogArc::GetF2() const
|
||||
{
|
||||
return qApp->FormulaFromUser(f2);
|
||||
return qApp->TrVars()->FormulaFromUser(f2);
|
||||
}
|
||||
|
|
|
@ -109,13 +109,13 @@ void DialogArcWithLength::SetCenter(const quint32 &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogArcWithLength::GetRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(radius);
|
||||
return qApp->TrVars()->FormulaFromUser(radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogArcWithLength::SetRadius(const QString &value)
|
||||
{
|
||||
radius = qApp->FormulaToUser(value);
|
||||
radius = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (radius.length() > 80)
|
||||
{
|
||||
|
@ -133,12 +133,12 @@ void DialogArcWithLength::SetRadius(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogArcWithLength::GetF1() const
|
||||
{
|
||||
return qApp->FormulaFromUser(f1);
|
||||
return qApp->TrVars()->FormulaFromUser(f1);
|
||||
}
|
||||
|
||||
void DialogArcWithLength::SetF1(const QString &value)
|
||||
{
|
||||
f1 = qApp->FormulaToUser(value);
|
||||
f1 = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (f1.length() > 80)
|
||||
{
|
||||
|
@ -156,13 +156,13 @@ void DialogArcWithLength::SetF1(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogArcWithLength::GetLength() const
|
||||
{
|
||||
return qApp->FormulaFromUser(length);
|
||||
return qApp->TrVars()->FormulaFromUser(length);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogArcWithLength::SetLength(const QString &value)
|
||||
{
|
||||
length = qApp->FormulaToUser(value);
|
||||
length = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (length.length() > 80)
|
||||
{
|
||||
|
|
|
@ -230,7 +230,7 @@ void DialogBisector::SetTypeLine(const QString &value)
|
|||
*/
|
||||
void DialogBisector::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ QString DialogBisector::GetTypeLine() const
|
|||
*/
|
||||
QString DialogBisector::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -99,13 +99,13 @@ void DialogCurveIntersectAxis::SetTypeLine(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCurveIntersectAxis::GetAngle() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formulaAngle);
|
||||
return qApp->TrVars()->FormulaFromUser(formulaAngle);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCurveIntersectAxis::SetAngle(const QString &value)
|
||||
{
|
||||
formulaAngle = qApp->FormulaToUser(value);
|
||||
formulaAngle = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formulaAngle.length() > 80)
|
||||
|
|
|
@ -183,7 +183,7 @@ void DialogCutArc::SetColor(const QString &value)
|
|||
*/
|
||||
void DialogCutArc::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
@ -216,7 +216,7 @@ void DialogCutArc::SetPointName(const QString &value)
|
|||
*/
|
||||
QString DialogCutArc::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -91,7 +91,7 @@ void DialogCutSpline::SetPointName(const QString &value)
|
|||
*/
|
||||
void DialogCutSpline::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formula.length() > 80)
|
||||
|
@ -210,7 +210,7 @@ void DialogCutSpline::ShowVisualization()
|
|||
*/
|
||||
QString DialogCutSpline::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -91,7 +91,7 @@ void DialogCutSplinePath::SetPointName(const QString &value)
|
|||
*/
|
||||
void DialogCutSplinePath::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formula.length() > 80)
|
||||
|
@ -210,7 +210,7 @@ void DialogCutSplinePath::ShowVisualization()
|
|||
*/
|
||||
QString DialogCutSplinePath::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -135,7 +135,7 @@ void DialogEditWrongFormula::ValChenged(int row)
|
|||
}
|
||||
if (ui->radioButtonStandardTable->isChecked())
|
||||
{
|
||||
const QString name = qApp->VarFromUser(item->text());
|
||||
const QString name = qApp->TrVars()->VarFromUser(item->text());
|
||||
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name))
|
||||
.arg(stable->GetGuiText());
|
||||
|
@ -153,56 +153,56 @@ void DialogEditWrongFormula::ValChenged(int row)
|
|||
if (ui->radioButtonLengthLine->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VLengthLine>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Line length"));
|
||||
.arg(*data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Line length"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (ui->radioButtonLengthArc->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VArcLength>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Arc length"));
|
||||
.arg(*data->GetVariable<VArcLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Arc length"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (ui->radioButtonLengthSpline->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VSplineLength>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Curve length"));
|
||||
.arg(*data->GetVariable<VSplineLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Curve length"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (ui->radioButtonAngleLine->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VLineAngle>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Line Angle"));
|
||||
.arg(*data->GetVariable<VLineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Line Angle"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (ui->radioButtonRadiusesArcs->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VArcRadius>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Arc radius"));
|
||||
.arg(*data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Arc radius"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (ui->radioButtonAnglesArcs->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VArcAngle>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Arc angle"));
|
||||
.arg(*data->GetVariable<VArcAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Arc angle"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (ui->radioButtonAnglesCurves->isChecked())
|
||||
{
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(*data->GetVariable<VCurveAngle>(qApp->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Curve angle"));
|
||||
.arg(*data->GetVariable<VCurveAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
|
||||
.arg(tr("Curve angle"));
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ void DialogEditWrongFormula::closeEvent(QCloseEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogEditWrongFormula::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formula.length() > 80)
|
||||
|
@ -383,7 +383,7 @@ void DialogEditWrongFormula::setPostfix(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogEditWrongFormula::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -195,7 +195,7 @@ void DialogEndLine::SetTypeLine(const QString &value)
|
|||
*/
|
||||
void DialogEndLine::SetFormula(const QString &value)
|
||||
{
|
||||
formulaLength = qApp->FormulaToUser(value);
|
||||
formulaLength = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formulaLength.length() > 80)
|
||||
|
@ -218,7 +218,7 @@ void DialogEndLine::SetFormula(const QString &value)
|
|||
*/
|
||||
void DialogEndLine::SetAngle(const QString &value)
|
||||
{
|
||||
formulaAngle = qApp->FormulaToUser(value);
|
||||
formulaAngle = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formulaAngle.length() > 80)
|
||||
|
@ -355,7 +355,7 @@ QString DialogEndLine::GetTypeLine() const
|
|||
*/
|
||||
QString DialogEndLine::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formulaLength);
|
||||
return qApp->TrVars()->FormulaFromUser(formulaLength);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -365,7 +365,7 @@ QString DialogEndLine::GetFormula() const
|
|||
*/
|
||||
QString DialogEndLine::GetAngle() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formulaAngle);
|
||||
return qApp->TrVars()->FormulaFromUser(formulaAngle);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -107,13 +107,13 @@ void DialogLineIntersectAxis::SetTypeLine(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogLineIntersectAxis::GetAngle() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formulaAngle);
|
||||
return qApp->TrVars()->FormulaFromUser(formulaAngle);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLineIntersectAxis::SetAngle(const QString &value)
|
||||
{
|
||||
formulaAngle = qApp->FormulaToUser(value);
|
||||
formulaAngle = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||
// of this PlainTextEdit to change 80 to this value
|
||||
if (formulaAngle.length() > 80)
|
||||
|
|
|
@ -261,7 +261,7 @@ void DialogNormal::SetAngle(const qreal &value)
|
|||
*/
|
||||
void DialogNormal::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ QString DialogNormal::GetTypeLine() const
|
|||
*/
|
||||
QString DialogNormal::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -111,13 +111,13 @@ void DialogPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointFromCircleAndTangent::GetCircleRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(ui->plainTextEditRadius->toPlainText());
|
||||
return qApp->TrVars()->FormulaFromUser(ui->plainTextEditRadius->toPlainText());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointFromCircleAndTangent::SetCircleRadius(const QString &value)
|
||||
{
|
||||
const QString formula = qApp->FormulaToUser(value);
|
||||
const QString formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
|
|
@ -271,7 +271,7 @@ void DialogPointOfContact::setCenter(const quint32 &value)
|
|||
*/
|
||||
void DialogPointOfContact::setRadius(const QString &value)
|
||||
{
|
||||
radius = qApp->FormulaToUser(value);
|
||||
radius = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (radius.length() > 80)
|
||||
{
|
||||
|
@ -304,7 +304,7 @@ void DialogPointOfContact::SetPointName(const QString &value)
|
|||
*/
|
||||
QString DialogPointOfContact::getRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(radius);
|
||||
return qApp->TrVars()->FormulaFromUser(radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -143,13 +143,13 @@ void DialogPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &va
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCircles::GetFirstCircleRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText());
|
||||
return qApp->TrVars()->FormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value)
|
||||
{
|
||||
const QString formula = qApp->FormulaToUser(value);
|
||||
const QString formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
@ -167,13 +167,13 @@ void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCircles::GetSecondCircleRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText());
|
||||
return qApp->TrVars()->FormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetSecondCircleRadius(const QString &value)
|
||||
{
|
||||
const QString formula = qApp->FormulaToUser(value);
|
||||
const QString formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
|
|
@ -288,7 +288,7 @@ void DialogShoulderPoint::SetP1Line(const quint32 &value)
|
|||
*/
|
||||
void DialogShoulderPoint::SetFormula(const QString &value)
|
||||
{
|
||||
formula = qApp->FormulaToUser(value);
|
||||
formula = qApp->TrVars()->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ QString DialogShoulderPoint::GetTypeLine() const
|
|||
*/
|
||||
QString DialogShoulderPoint::GetFormula() const
|
||||
{
|
||||
return qApp->FormulaFromUser(formula);
|
||||
return qApp->TrVars()->FormulaFromUser(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -460,7 +460,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
|
|||
// Replace line return character with spaces for calc if exist
|
||||
QString formula = text;
|
||||
formula.replace("\n", " ");
|
||||
formula = qApp->FormulaFromUser(formula);// Translate to internal look.
|
||||
formula = qApp->TrVars()->FormulaFromUser(formula);// Translate to internal look.
|
||||
Calculator *cal = new Calculator(data);
|
||||
result = cal->EvalFormula(formula);
|
||||
delete cal;
|
||||
|
|
|
@ -105,6 +105,8 @@ int main(int argc, char *argv[])
|
|||
appTranslator.load("valentina_" + checkedLocale, qApp->translationsPath());
|
||||
app.installTranslator(&appTranslator);
|
||||
|
||||
app.InitTrVars();//Very important do it after load QM files.
|
||||
|
||||
static const char * GENERIC_ICON_TO_CHECK = "document-open";
|
||||
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
|
||||
{
|
||||
|
|
|
@ -136,7 +136,7 @@ void VToolAlongLine::SetVisualization()
|
|||
SCASSERT(visual != nullptr)
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -345,9 +345,9 @@ void VToolArc::SetVisualization()
|
|||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setPoint1Id(arc->GetCenter().id());
|
||||
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
|
||||
visual->setF1(qApp->FormulaToUser(arc->GetFormulaF1()));
|
||||
visual->setF2(qApp->FormulaToUser(arc->GetFormulaF2()));
|
||||
visual->setRadius(qApp->TrVars()->FormulaToUser(arc->GetFormulaRadius()));
|
||||
visual->setF1(qApp->TrVars()->FormulaToUser(arc->GetFormulaF1()));
|
||||
visual->setF2(qApp->TrVars()->FormulaToUser(arc->GetFormulaF2()));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,9 +302,9 @@ void VToolArcWithLength::SetVisualization()
|
|||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setPoint1Id(arc->GetCenter().id());
|
||||
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
|
||||
visual->setF1(qApp->FormulaToUser(arc->GetFormulaF1()));
|
||||
visual->setLength(qApp->FormulaToUser(arc->GetFormulaLength()));
|
||||
visual->setRadius(qApp->TrVars()->FormulaToUser(arc->GetFormulaRadius()));
|
||||
visual->setF1(qApp->TrVars()->FormulaToUser(arc->GetFormulaF1()));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(arc->GetFormulaLength()));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ void VToolBisector::SetVisualization()
|
|||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(basePointId);
|
||||
visual->setPoint3Id(thirdPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ void VToolCurveIntersectAxis::SetVisualization()
|
|||
|
||||
visual->setPoint1Id(curveId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ void VToolCutArc::SetVisualization()
|
|||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ void VToolCutSpline::SetVisualization()
|
|||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ void VToolCutSplinePath::SetVisualization()
|
|||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,8 +231,8 @@ void VToolEndLine::SetVisualization()
|
|||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ void VToolLineIntersectAxis::SetVisualization()
|
|||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ void VToolNormal::SetVisualization()
|
|||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(angle);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
|
|
|
@ -313,7 +313,7 @@ void VToolPointOfContact::SetVisualization()
|
|||
visual->setPoint1Id(firstPointId);
|
||||
visual->setLineP2Id(secondPointId);
|
||||
visual->setRadiusId(center);
|
||||
visual->setRadius(qApp->FormulaToUser(arcRadius));
|
||||
visual->setRadius(qApp->TrVars()->FormulaToUser(arcRadius));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ void VToolShoulderPoint::SetVisualization()
|
|||
visual->setPoint1Id(pShoulder);
|
||||
visual->setLineP1Id(basePointId);
|
||||
visual->setLineP2Id(p2Line);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ qreal Visualization::FindVal(const QString &expression)
|
|||
// Replace line return with spaces for calc if exist
|
||||
QString formula = expression;
|
||||
formula.replace("\n", " ");
|
||||
formula = qApp->FormulaFromUser(formula);
|
||||
formula = qApp->TrVars()->FormulaFromUser(formula);
|
||||
Calculator *cal = new Calculator(Visualization::data);
|
||||
val = cal->EvalFormula(formula);
|
||||
delete cal;
|
||||
|
|
|
@ -70,7 +70,8 @@ void VIndividualMeasurements::ReadMeasurement(const QDomElement &domElement, con
|
|||
{
|
||||
qreal value = GetParametrDouble(domElement, AttrValue, "0.0");
|
||||
value = UnitConvertor(value, MUnit(), qApp->patternUnit());
|
||||
data->AddVariable(tag, new VMeasurement(tag, value, qApp->GuiText(tag), qApp->Description(tag), tag));
|
||||
data->AddVariable(tag, new VMeasurement(tag, value, qApp->TrVars()->GuiText(tag),
|
||||
qApp->TrVars()->Description(tag), tag));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -64,7 +64,7 @@ QString VStandardMeasurements::OrigDescription ()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VStandardMeasurements::TrDescription()
|
||||
{
|
||||
const QString trDesc = qApp->STDescription(Id());
|
||||
const QString trDesc = qApp->TrVars()->STDescription(Id());
|
||||
if (trDesc.isEmpty() == false)
|
||||
{
|
||||
return trDesc;
|
||||
|
@ -115,8 +115,8 @@ void VStandardMeasurements::ReadMeasurement(const QDomElement &domElement, const
|
|||
qWarning()<<"Standard table can't use inch unit.";
|
||||
}
|
||||
|
||||
data->AddVariable(tag, new VMeasurement(tag, value, size_increase, height_increase, qApp->GuiText(tag),
|
||||
qApp->Description(tag), tag));
|
||||
data->AddVariable(tag, new VMeasurement(tag, value, size_increase, height_increase, qApp->TrVars()->GuiText(tag),
|
||||
qApp->TrVars()->Description(tag), tag));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user