Element editor : add terminal properties editable

This commit is contained in:
joshua
2021-02-16 21:39:09 +01:00
parent 444f62a1f8
commit be2067148e
4 changed files with 65 additions and 9 deletions

View File

@@ -466,7 +466,8 @@ const QDomDocument ElementScene::toXml(bool all_parts)
auto type_ = m_element_data.m_type; auto type_ = m_element_data.m_type;
if (type_ == ElementData::Slave || if (type_ == ElementData::Slave ||
type_ == ElementData::Master) type_ == ElementData::Master ||
type_ == ElementData::Terminale)
{ {
root.appendChild(m_element_data.kindInfoToXml(xml_document)); root.appendChild(m_element_data.kindInfoToXml(xml_document));
} }

View File

@@ -1,4 +1,4 @@
/* /*
Copyright 2006-2021 The QElectroTech Team Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
@@ -98,6 +98,13 @@ void ElementPropertiesEditorWidget::upDateInterface()
ui->m_master_type_cb->setCurrentIndex( ui->m_master_type_cb->setCurrentIndex(
ui->m_master_type_cb->findData ( ui->m_master_type_cb->findData (
m_data.m_master_type)); m_data.m_master_type));
} else if (m_data.m_type == ElementData::Terminale) {
ui->m_terminal_type_cb->setCurrentIndex(
ui->m_terminal_type_cb->findData(
m_data.m_terminal_type));
ui->m_terminal_func_cb->setCurrentIndex(
ui->m_terminal_func_cb->findData(
m_data.m_terminal_function));
} }
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex()); on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
@@ -131,6 +138,17 @@ void ElementPropertiesEditorWidget::setUpInterface()
ui->m_master_type_cb->addItem(tr("Organe de protection"), ElementData::Protection); ui->m_master_type_cb->addItem(tr("Organe de protection"), ElementData::Protection);
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"), ElementData::Commutator); ui->m_master_type_cb->addItem(tr("Commutateur / bouton"), ElementData::Commutator);
//Terminal option
ui->m_terminal_type_cb->addItem(tr("Générique"), ElementData::TTGeneric);
ui->m_terminal_type_cb->addItem(tr("Fusible"), ElementData::Fuse);
ui->m_terminal_type_cb->addItem(tr("Séctionnable"), ElementData::Sectional);
ui->m_terminal_type_cb->addItem(tr("Diode"), ElementData::Diode);
ui->m_terminal_func_cb->addItem(tr("Générique"), ElementData::TFGeneric);
ui->m_terminal_func_cb->addItem(tr("Phase"), ElementData::Phase);
ui->m_terminal_func_cb->addItem(tr("Neutre"), ElementData::Neutral);
ui->m_terminal_func_cb->addItem(tr("Terre"), ElementData::PE);
//Disable the edition of the first column of the information tree //Disable the edition of the first column of the information tree
//by this little workaround //by this little workaround
ui->m_tree->setItemDelegate(new EditorDelegate(this)); ui->m_tree->setItemDelegate(new EditorDelegate(this));
@@ -199,6 +217,11 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
else if (m_data.m_type == ElementData::Master) { else if (m_data.m_type == ElementData::Master) {
m_data.m_master_type = ui->m_master_type_cb->currentData().value<ElementData::MasterType>(); m_data.m_master_type = ui->m_master_type_cb->currentData().value<ElementData::MasterType>();
} }
else if (m_data.m_type == ElementData::Terminale)
{
m_data.m_terminal_type = ui->m_terminal_type_cb->currentData().value<ElementData::TerminalType>();
m_data.m_terminal_function = ui->m_terminal_func_cb->currentData().value<ElementData::TerminalFunction>();
}
for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren()) for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren())
{ {
@@ -220,16 +243,19 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
*/ */
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int index) void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int index)
{ {
bool slave = false , master = false; bool slave = false , master = false, terminal = false;
auto type_ = ui->m_base_type_cb->itemData(index).value<ElementData::Type>(); auto type_ = ui->m_base_type_cb->itemData(index).value<ElementData::Type>();
if (type_ == ElementData::Slave) if (type_ == ElementData::Slave)
slave = true; slave = true;
else if (type_ == ElementData::Master) else if (type_ == ElementData::Master)
master = true; master = true;
else if (type_ == ElementData::Terminale)
terminal = true;
ui->m_slave_gb->setVisible(slave); ui->m_slave_gb->setVisible(slave);
ui->m_master_gb->setVisible(master); ui->m_master_gb->setVisible(master);
ui->m_terminal_gb->setVisible(terminal);
updateTree(); updateTree();
} }

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>450</width> <width>527</width>
<height>321</height> <height>442</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -107,6 +107,35 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="m_terminal_gb">
<property name="title">
<string>Élément bornier</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Fonction</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_terminal_type_cb"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_terminal_func_cb"/>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">

View File

@@ -115,7 +115,7 @@ QDomElement ElementData::kindInfoToXml(QDomDocument &document)
auto xml_func = document.createElement("kindInformation"); auto xml_func = document.createElement("kindInformation");
xml_func.setAttribute("name", "function"); xml_func.setAttribute("name", "function");
auto func_txt = document.createTextNode(terminalFunctionToString(m_terminal_function)); auto func_txt = document.createTextNode(terminalFunctionToString(m_terminal_function));
xml_type.appendChild(xml_func); xml_func.appendChild(func_txt);
returned_elmt.appendChild(xml_func); returned_elmt.appendChild(xml_func);
} }
@@ -313,7 +313,7 @@ QString ElementData::terminalTypeToString(ElementData::TerminalType type)
case ElementData::Sectional: case ElementData::Sectional:
return QString("sectional"); return QString("sectional");
case ElementData::Diode: case ElementData::Diode:
return QString("didoe"); return QString("diode");
} }
} }