Change function QETApp::elementTranslatedInfoKey

Use the function QETInformation::translatedInfoKey(const QString &info)
instead of QETApp::elementTranslatedInfoKey(const QString &info).

The final goal is to remove all information from the QETApp and use
instea QETInformation who is dedicated to this
This commit is contained in:
Claveau Joshua 2020-11-08 19:16:02 +01:00
parent 7882c5734a
commit 6f60156e00
10 changed files with 18 additions and 42 deletions

View File

@ -18,6 +18,7 @@
#include "replaceadvanceddialog.h"
#include "ui_replaceadvanceddialog.h"
#include "qetapp.h"
#include "qetinformation.h"
#include <QAbstractButton>
@ -99,7 +100,7 @@ void replaceAdvancedDialog::fillWhatComboBox(int index)
}
else if (index == 1) {
for (QString str : QETApp::elementInfoKeys()) {
ui->m_what_cb->addItem(QETApp::elementTranslatedInfoKey(str), str);
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
}
}
else if (index == 2) {

View File

@ -21,6 +21,7 @@
#include "elementinfopartwidget.h"
#include "qetapp.h"
#include "searchandreplaceworker.h"
#include "qetinformation.h"
#include <QAbstractButton>
@ -74,7 +75,7 @@ void ReplaceElementDialog::buildWidget()
for (QString str : QETApp::elementInfoKeys())
{
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETApp::elementTranslatedInfoKey(str), this);
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
eipw->setEraseTextVisible(true);
eipw->setPlaceHolderText(tr("Ne pas modifier"));
ui->m_scroll_layout->addWidget(eipw);

View File

@ -18,6 +18,7 @@
#include "elementquerywidget.h"
#include "ui_elementquerywidget.h"
#include "qetapp.h"
#include "qetinformation.h"
#include <QRegularExpression>
@ -449,7 +450,7 @@ void ElementQueryWidget::setUpItems()
if (key == "formula")
continue;
auto item = new QListWidgetItem(QETApp::elementTranslatedInfoKey(key), ui->m_var_list);
auto item = new QListWidgetItem(QETInformation::translatedInfoKey(key), ui->m_var_list);
item->setData(Qt::UserRole, key);
m_items_list << item;
}

View File

@ -18,6 +18,7 @@
#include "elementpropertieseditorwidget.h"
#include "ui_elementpropertieseditorwidget.h"
#include "qetapp.h"
#include "qetinformation.h"
#include <QItemDelegate>
@ -184,7 +185,7 @@ void ElementPropertiesEditorWidget::populateTree()
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree);
qtwi->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
qtwi->setData(0, Qt::DisplayRole,
QETApp::elementTranslatedInfoKey(key));
QETInformation::translatedInfoKey(key));
qtwi->setData(0, Qt::UserRole, key);
qtwi->setText(1, m_elmt_info.value(key).toString());
}

View File

@ -412,37 +412,6 @@ QStringList QETApp::elementInfoKeys()
return info_list;
}
/**
@brief ElementsProperties::translatedInfo
Return the translated information key given by info
If info don't match, return an empty string
@param info the key to be translated
@return
*/
QString QETApp::elementTranslatedInfoKey(const QString &info)
{
if (info == "formula") return tr("Formule du label");
else if (info == "label") return tr("Label");
else if (info == "plant") return tr("Installation");
else if (info == "location") return tr("Localisation");
else if (info == "comment") return tr("Commentaire");
else if (info == "function") return tr("Fonction");
else if (info == "auxiliary1") return tr("Bloc auxiliaire 1");
else if (info == "auxiliary2") return tr("Bloc auxiliaire 2");
else if (info == "description") return tr("Description textuelle");
else if (info == "designation") return tr("Numéro d'article");
else if (info == "manufacturer") return tr("Fabricant");
else if (info == "manufacturer_reference") return tr("Numéro de commande");
else if (info == "machine_manufacturer_reference") return tr("Numéro interne");
else if (info == "supplier") return tr("Fournisseur");
else if (info == "quantity") return tr("Quantité");
else if (info == "unity") return tr("Unité");
else return QString();
}
/**
@brief QETApp::elementInfoToVar
@param info

View File

@ -74,7 +74,6 @@ class QETApp : public QObject
static ElementsCollectionCache *collectionCache();
static QStringList elementInfoKeys();
static QString elementTranslatedInfoKey(const QString &);
static QString elementInfoToVar(const QString &info);
static QStringList conductorInfoKeys();

View File

@ -20,6 +20,7 @@
#include "qetproject.h"
#include "qetxml.h"
#include "qetapp.h"
#include "qetinformation.h"
#include <QSqlError>
#include <QSqlRecord>
@ -348,7 +349,7 @@ void ProjectDBModel::setHeaderString()
} else if (field_name == "diagram_position") {
header_name = tr("Position du folio");
} else {
header_name = QETApp::elementTranslatedInfoKey(field_name);
header_name = QETInformation::translatedInfoKey(field_name);
if (header_name.isEmpty()) {
header_name = QETApp::diagramTranslatedInfoKey(field_name);
}

View File

@ -20,6 +20,7 @@
#include "elementquerywidget.h"
#include "qetproject.h"
#include "qetapp.h"
#include "qetinformation.h"
#include <QMessageBox>
#include <QSqlError>
@ -122,7 +123,7 @@ QString BOMExportDialog::getBom()
} else if (field_name == "designation_qty") {
header_name << tr("Quantité numéro d'article", "Special field with name : designation quantity");
} else {
header_name << QETApp::elementTranslatedInfoKey(field_name);
header_name << QETInformation::translatedInfoKey(field_name);
if (header_name.isEmpty()) {
header_name << QETApp::diagramTranslatedInfoKey(field_name);
}

View File

@ -6,6 +6,7 @@
#include "element.h"
#include "qetapp.h"
#include "conductor.h"
#include "qetinformation.h"
CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent) :
QDialog(parent),
@ -66,7 +67,7 @@ void CompositeTextEditDialog::setUpComboBox()
//the value of the combo box are always alphabetically sorted
QMap <QString, QString> info_map;
for(const QString& str : qstrl) {
info_map.insert(QETApp::elementTranslatedInfoKey(str), QETApp::elementInfoToVar(str));
info_map.insert(QETInformation::translatedInfoKey(str), QETApp::elementInfoToVar(str));
}
for(const QString& key : info_map.keys()) {
ui->m_info_cb->addItem(key, info_map.value(key));

View File

@ -22,6 +22,7 @@
#include "diagram.h"
#include "elementinfopartwidget.h"
#include "element.h"
#include "qetinformation.h"
/**
@brief ElementInfoWidget::ElementInfoWidget
@ -177,9 +178,9 @@ void ElementInfoWidget::disableLiveEdit()
*/
void ElementInfoWidget::buildInterface()
{
foreach (QString str, QETApp::elementInfoKeys())
for (auto str : QETApp::elementInfoKeys())
{
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETApp::elementTranslatedInfoKey(str), this);
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
ui->scroll_vlayout->addWidget(eipw);
m_eipw_list << eipw;
}
@ -194,7 +195,7 @@ void ElementInfoWidget::buildInterface()
*/
ElementInfoPartWidget *ElementInfoWidget::infoPartWidgetForKey(const QString &key) const
{
foreach (ElementInfoPartWidget *eipw, m_eipw_list)
for (auto eipw : m_eipw_list)
{
if (eipw->key() == key)
return eipw;