1 /************************************************************************ 2 ** 3 ** @file vtranslatevars.h 4 ** @author Roman Telezhynskyi <dismine(at)gmail.com> 5 ** @date 10 6, 2015 6 ** 7 ** @brief 8 ** @copyright 9 ** This source code is part of the Valentina project, a pattern making 10 ** program, whose allow create and modeling patterns of clothing. 11 ** Copyright (C) 2015 Valentina project 12 ** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved. 13 ** 14 ** Valentina is free software: you can redistribute it and/or modify 15 ** it under the terms of the GNU General Public License as published by 16 ** the Free Software Foundation, either version 3 of the License, or 17 ** (at your option) any later version. 18 ** 19 ** Valentina is distributed in the hope that it will be useful, 20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 ** GNU General Public License for more details. 23 ** 24 ** You should have received a copy of the GNU General Public License 25 ** along with Valentina. If not, see <http://www.gnu.org/licenses/>. 26 ** 27 *************************************************************************/ 28 29 #ifndef VTRANSLATEVARS_H 30 #define VTRANSLATEVARS_H 31 32 #include <qcompilerdetection.h> 33 #include <QtGlobal> 34 35 #include "vtranslatemeasurements.h" 36 37 class VTranslateVars : public VTranslateMeasurements 38 { 39 public: 40 explicit VTranslateVars(); 41 virtual ~VTranslateVars() = default; 42 43 bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const; 44 bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; 45 bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const; 46 47 QString InternalVarToUser(const QString &var) const; 48 49 QString VarToUser(const QString &var) const; 50 QString VarFromUser(const QString &var) const; 51 52 QString PMSystemName(const QString &code) const; 53 QString PMSystemAuthor(const QString &code) const; 54 QString PMSystemBook(const QString &code) const; 55 56 QString FormulaFromUser(const QString &formula, bool osSeparator) const; 57 static QString TryFormulaFromUser(const QString &formula, bool osSeparator); 58 59 QString FormulaToUser(const QString &formula, bool osSeparator) const; 60 static QString TryFormulaToUser(const QString &formula, bool osSeparator); 61 62 virtual void Retranslate() override; 63 64 QMap<QString, QString> GetTranslatedFunctions() const; 65 QMap<QString, qmu::QmuTranslation> GetFunctions() const; 66 QMap<QString, qmu::QmuTranslation> GetFunctionsDescriptions() const; 67 68 static void BiasTokens(int position, int bias, QMap<int, QString> &tokens); 69 70 private: Q_DISABLE_COPY(VTranslateVars)71 Q_DISABLE_COPY(VTranslateVars) 72 QMap<QString, qmu::QmuTranslation> PMSystemNames{}; 73 QMap<QString, qmu::QmuTranslation> PMSystemAuthors{}; 74 QMap<QString, qmu::QmuTranslation> PMSystemBooks{}; 75 QMap<QString, qmu::QmuTranslation> variables{}; 76 QMap<QString, qmu::QmuTranslation> functions{}; 77 QMap<QString, qmu::QmuTranslation> functionsDescriptions{}; 78 QMap<QString, qmu::QmuTranslation> stDescriptions{}; 79 QMap<QString, QString> translatedFunctions{}; 80 81 void InitPatternMakingSystems(); 82 void InitVariables(); 83 void InitFunctions(); 84 85 void PrepareFunctionTranslations(); 86 87 void InitSystem(const QString &code, const qmu::QmuTranslation &name, const qmu::QmuTranslation &author, 88 const qmu::QmuTranslation &book); 89 90 void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens, QMap<int, QString> &numbers) const; 91 92 }; 93 94 #endif // VTRANSLATEVARS_H 95