diff --git a/sources/editor/ui/elementpropertieseditorwidget.cpp b/sources/editor/ui/elementpropertieseditorwidget.cpp index 23db80ddf..dbdabafcc 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.cpp +++ b/sources/editor/ui/elementpropertieseditorwidget.cpp @@ -188,13 +188,13 @@ void ElementPropertiesEditorWidget::updateTree() */ void ElementPropertiesEditorWidget::populateTree() { - auto keys = QETInformation::elementEditorElementInfoKeys(); + const auto keys = QETInformation::elementEditorElementInfoKeys(); for(const QString& key : keys) { QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree); qtwi->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable); qtwi->setData(0, Qt::DisplayRole, - QETInformation::translatedInfoKey(key)); + QETInformation::translatedInfoKey(key)); qtwi->setData(0, Qt::UserRole, key); qtwi->setText(1, m_data.m_informations.value(key).toString()); } @@ -256,6 +256,8 @@ void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int in ui->m_slave_gb->setVisible(slave); ui->m_master_gb->setVisible(master); ui->m_terminal_gb->setVisible(terminal); - + ui->tabWidget->setTabVisible(1, + (type_ == ElementData::Simple || + type_ == ElementData::Master)); updateTree(); } diff --git a/sources/qetinformation.cpp b/sources/qetinformation.cpp index 817c41857..1206f6420 100644 --- a/sources/qetinformation.cpp +++ b/sources/qetinformation.cpp @@ -255,3 +255,16 @@ QStringList QETInformation::elementEditorElementInfoKeys() ELMT_MACHINE_MANUFACTURER_REF}; return list; } + +QStringList QETInformation::terminalElementInfoKeys() +{ + QStringList list = { ELMT_FORMULA, + ELMT_LABEL, + ELMT_COMMENT, + ELMT_DESIGNATION, + ELMT_MANUFACTURER, + ELMT_MANUFACTURER_REF, + ELMT_MACHINE_MANUFACTURER_REF, + ELMT_SUPPLIER }; + return list; +} diff --git a/sources/qetinformation.h b/sources/qetinformation.h index 7fc0aa2f5..6dbfde862 100644 --- a/sources/qetinformation.h +++ b/sources/qetinformation.h @@ -108,6 +108,8 @@ namespace QETInformation QStringList elementEditorElementInfoKeys(); QString elementInfoToVar(const QString &info); + QStringList terminalElementInfoKeys(); + QString infoToVar(const QString &info); QString translatedInfoKey(const QString &info); } diff --git a/sources/ui/elementinfowidget.cpp b/sources/ui/elementinfowidget.cpp index 50924010b..e4978d624 100644 --- a/sources/ui/elementinfowidget.cpp +++ b/sources/ui/elementinfowidget.cpp @@ -37,7 +37,6 @@ ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) : m_first_activation (false) { ui->setupUi(this); - buildInterface(); setElement(elmt); } @@ -179,7 +178,14 @@ void ElementInfoWidget::disableLiveEdit() */ void ElementInfoWidget::buildInterface() { - for (auto str : QETInformation::elementInfoKeys()) + QStringList keys; + auto type_ = m_element.data()->elementData().m_type; + if (type_ == ElementData::Terminale) + keys = QETInformation::terminalElementInfoKeys(); + else + keys = QETInformation::elementInfoKeys(); + + for (auto str : keys) { ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this); ui->scroll_vlayout->addWidget(eipw); @@ -212,6 +218,10 @@ ElementInfoPartWidget *ElementInfoWidget::infoPartWidgetForKey(const QString &ke */ void ElementInfoWidget::updateUi() { + if (!m_ui_builded) { + buildInterface(); + m_ui_builded = true; + } //We disable live edit to avoid wrong undo when we fill the line edit with new text if (m_live_edit) disableLiveEdit(); diff --git a/sources/ui/elementinfowidget.h b/sources/ui/elementinfowidget.h index 9b01b688a..c2942cc15 100644 --- a/sources/ui/elementinfowidget.h +++ b/sources/ui/elementinfowidget.h @@ -72,6 +72,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget Ui::ElementInfoWidget *ui; QList m_eipw_list; bool m_first_activation; + bool m_ui_builded = false; }; #endif // ELEMENTINFOWIDGET_H