diff --git a/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp b/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp index 2057d2d77..b8b62dee5 100644 --- a/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp +++ b/sources/SearchAndReplace/ui/replaceadvanceddialog.cpp @@ -104,8 +104,8 @@ void replaceAdvancedDialog::fillWhatComboBox(int index) } } else if (index == 2) { - for (QString str : QETApp::conductorInfoKeys()) { - ui->m_what_cb->addItem(QETApp::conductorTranslatedInfoKey(str), str); + for (auto str : QETInformation::conductorInfoKeys()) { + ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str); } } } diff --git a/sources/editor/ui/dynamictextfieldeditor.cpp b/sources/editor/ui/dynamictextfieldeditor.cpp index 1553ee7bc..efb4fd77e 100644 --- a/sources/editor/ui/dynamictextfieldeditor.cpp +++ b/sources/editor/ui/dynamictextfieldeditor.cpp @@ -206,7 +206,7 @@ void DynamicTextFieldEditor::fillInfoComboBox() QString type = elementEditor() -> elementScene() -> elementType(); if(type.contains("report")) { - strl = QETInformation::folioReportInfoKey(); + strl = QETInformation::folioReportInfoKeys(); } else { strl = QETApp::elementInfoKeys(); diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 23ce9cd4b..29044146b 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -427,40 +427,6 @@ QString QETApp::elementInfoToVar(const QString &info) return (QString ("%{void}")); } -/** - @brief QETApp::conductorInfoKeys - @return the conductor information keys -*/ -QStringList QETApp::conductorInfoKeys() -{ - QStringList keys; - keys.append("formula"); - keys.append("text"); - keys.append("function"); - keys.append("tension/protocol"); - keys.append("conductor_color"); - keys.append("conductor_section"); - - return keys; -} - -/** - @brief QETApp::conductorTranslatedInfoKey - @param key - @return the translated information key given by key - If key don't match, return an empty string -*/ -QString QETApp::conductorTranslatedInfoKey(const QString &key) -{ - if (key == "formula") return tr("Formule du texte"); - else if (key == "text") return tr("Texte"); - else if (key == "function") return tr("Fonction"); - else if (key == "tension/protocol") return tr("Tension / Protocole"); - else if (key == "conductor_color") return tr("Couleur du fil"); - else if (key == "conductor_section")return tr("Section du fil"); - return QString(); -} - /** @brief QETApp::diagramInfoKeys @return the diagram default default information keys diff --git a/sources/qetapp.h b/sources/qetapp.h index 4443e4abb..3f14b22f1 100644 --- a/sources/qetapp.h +++ b/sources/qetapp.h @@ -76,9 +76,6 @@ class QETApp : public QObject static QStringList elementInfoKeys(); static QString elementInfoToVar(const QString &info); - static QStringList conductorInfoKeys(); - static QString conductorTranslatedInfoKey(const QString &key); - static QStringList diagramInfoKeys(); static QString diagramTranslatedInfoKey(const QString &key); diff --git a/sources/qetinformation.cpp b/sources/qetinformation.cpp index f4c06dcef..cfa3d4557 100644 --- a/sources/qetinformation.cpp +++ b/sources/qetinformation.cpp @@ -33,6 +33,11 @@ static QString COND_COLOR = "conductor_color"; static QString COND_COLOR_VAR = "%{conductor_color}"; static QString COND_SECTION = "conductor_section"; static QString COND_SECTION_var = "%{conductor_section}"; +static QString COND_FORMULA = "formula"; +static QString COND_FORMULA_VAR = "%{formula}"; +static QString COND_TEXT = "text"; +static QString COND_TEXT_VAR = "%{text}"; + /** @brief QETInformation::titleblockInfoKeys @@ -67,16 +72,6 @@ QStringList QETInformation::titleblockInfoKeys() return info_list; } -/** - @brief QETInformation::titleblockTranslatedInfoKey - @param info : info key to be translated - @return the translated information given by info - If info don't match, return an empty string -*/ -QString QETInformation::titleblockTranslatedInfoKey(const QString &info) { - return translatedInfoKey(info); -} - /** @brief QETInformation::titleblockInfoKeysToVar @param info @@ -119,7 +114,7 @@ QHash QETInformation::titleblockTranslatedKeyHashVar() { QHash hash_; for (QString str : titleblockInfoKeys()) { - hash_.insert(titleblockTranslatedInfoKey(str), titleblockInfoKeysToVar(str)); + hash_.insert(translatedInfoKey(str), titleblockInfoKeysToVar(str)); } return hash_; } @@ -128,14 +123,13 @@ QHash QETInformation::titleblockTranslatedKeyHashVar() * @brief QETInformation::folioReportInfoKey * @return The info key available for dynamic element text item of a folio report */ -QStringList QETInformation::folioReportInfoKey() +QStringList QETInformation::folioReportInfoKeys() { - QStringList list; - list << ELMT_LABEL; - list << COND_FUNCTION; - list << COND_TENSION_PROTOCOL; - list << COND_COLOR; - list << COND_SECTION; + QStringList list = {ELMT_LABEL, + COND_FUNCTION, + COND_TENSION_PROTOCOL, + COND_COLOR, + COND_SECTION}; return list; } @@ -151,6 +145,18 @@ QHash QETInformation::folioReportInfoKeyToVar() return H_; } +QStringList QETInformation::conductorInfoKeys() +{ + QStringList list = {COND_FORMULA, + COND_TEXT, + COND_FUNCTION, + COND_TENSION_PROTOCOL, + COND_COLOR, + COND_SECTION}; + + return list; +} + /** * @brief QETInformation::translatedInfoKey * @param info @@ -204,5 +210,7 @@ QString QETInformation::translatedInfoKey(const QString &info) else if (info == COND_TENSION_PROTOCOL) return QObject::tr("Tension / Protocole"); else if (info == COND_COLOR) return QObject::tr("Couleur du fil"); else if (info == COND_SECTION) return QObject::tr("Section du fil"); + else if (info == COND_TEXT) return QObject::tr("Texte"); + else if (info == COND_FORMULA) return QObject::tr("Formule du texte"); else return QString(); } diff --git a/sources/qetinformation.h b/sources/qetinformation.h index a0a9e8ab6..5da696dac 100644 --- a/sources/qetinformation.h +++ b/sources/qetinformation.h @@ -21,14 +21,23 @@ #include #include +/** + * Inside this namespace you will fin all information used in QElectrotech for + * element, conductor and diagram. + * Each information have 3 values : + * #1 the info key = the key of an information as a QString used in the code (exemple : label) + * #2 the info key to variable = the key in form of a variable. + * This is used by the user to replace a variable by the string of this variable (exemple : %{label}) + * #3 the info key translated to the current local (exemple label in dutch = Betriebsmittelkennzeichen) + */ namespace QETInformation { QStringList titleblockInfoKeys(); - QString titleblockTranslatedInfoKey(const QString &info); QString titleblockInfoKeysToVar(const QString &info); QHash titleblockTranslatedKeyHashVar(); - QStringList folioReportInfoKey(); + QStringList folioReportInfoKeys(); QHash folioReportInfoKeyToVar(); + QStringList conductorInfoKeys(); QString translatedInfoKey(const QString &info); } diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index f78d91774..67e92d50a 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -1903,7 +1903,7 @@ QStringList DynamicTextItemDelegate::availableInfo( if(deti->parentElement()->linkType() & Element::AllReport) //Special treatment for text owned by a folio report { - return QETInformation::folioReportInfoKey(); + return QETInformation::folioReportInfoKeys(); } else {