diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index 21415c290..6a0b23942 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -23,8 +23,8 @@ */ ElementEditionCommand::ElementEditionCommand(ElementScene *scene, ElementView *view, QUndoCommand *parent): QUndoCommand(parent), - editor_scene_(scene), - editor_view_(view) + m_scene(scene), + m_view(view) { } @@ -35,8 +35,8 @@ ElementEditionCommand::ElementEditionCommand(ElementScene *scene, ElementView *v */ ElementEditionCommand::ElementEditionCommand(const QString &text, ElementScene *scene, ElementView *view, QUndoCommand *parent): QUndoCommand(text, parent), - editor_scene_(scene), - editor_view_(view) + m_scene(scene), + m_view(view) { } @@ -50,28 +50,28 @@ ElementEditionCommand::~ElementEditionCommand() { @return the element editor/scene the command should take place on */ ElementScene *ElementEditionCommand::elementScene() const { - return(editor_scene_); + return(m_scene); } /** Define \a scene as the element editor/scene the command should take place */ void ElementEditionCommand::setElementScene(ElementScene *scene) { - editor_scene_ = scene; + m_scene = scene; } /** @return the view the effect of the command should be rendered on */ ElementView *ElementEditionCommand::elementView() const { - return(editor_view_); + return(m_view); } /** Define \a view as the view the effect of the command should be rendered on */ void ElementEditionCommand::setElementView(ElementView *view) { - editor_view_ = view; + m_view = view; } /*** DeletePartsCommand ***/ @@ -90,33 +90,33 @@ DeletePartsCommand::DeletePartsCommand( deleted_parts(parts) { foreach(QGraphicsItem *qgi, deleted_parts) { - editor_scene_ -> qgiManager().manage(qgi); + m_scene -> qgiManager().manage(qgi); } } /// Destructeur : detruit egalement les parties supprimees DeletePartsCommand::~DeletePartsCommand() { foreach(QGraphicsItem *qgi, deleted_parts) { - editor_scene_ -> qgiManager().release(qgi); + m_scene -> qgiManager().release(qgi); } } /// Restaure les parties supprimees void DeletePartsCommand::undo() { - editor_scene_ -> blockSignals(true); + m_scene -> blockSignals(true); foreach(QGraphicsItem *qgi, deleted_parts) { - editor_scene_ -> addItem(qgi); + m_scene -> addItem(qgi); } - editor_scene_ -> blockSignals(false); + m_scene -> blockSignals(false); } /// Supprime les parties void DeletePartsCommand::redo() { - editor_scene_ -> blockSignals(true); + m_scene -> blockSignals(true); foreach(QGraphicsItem *qgi, deleted_parts) { - editor_scene_ -> removeItem(qgi); + m_scene -> removeItem(qgi); } - editor_scene_ -> blockSignals(false); + m_scene -> blockSignals(false); } /*** CutPartsCommand ***/ @@ -137,27 +137,27 @@ PastePartsCommand::PastePartsCommand( first_redo(true) { setText(QObject::tr("coller")); - editor_scene_ -> qgiManager().manage(content_); + m_scene -> qgiManager().manage(content_); } /// Destructeur PastePartsCommand::~PastePartsCommand() { - editor_scene_ -> qgiManager().release(content_); + m_scene -> qgiManager().release(content_); } /// annule le coller void PastePartsCommand::undo() { // enleve les parties - editor_scene_ -> blockSignals(true); + m_scene -> blockSignals(true); foreach(QGraphicsItem *part, content_) { - editor_scene_ -> removeItem(part); + m_scene -> removeItem(part); } - editor_scene_ -> blockSignals(false); + m_scene -> blockSignals(false); if (uses_offset) { - editor_view_ -> offset_paste_count_ = old_offset_paste_count_; - editor_view_ -> start_top_left_corner_ = old_start_top_left_corner_; + m_view -> offset_paste_count_ = old_offset_paste_count_; + m_view -> start_top_left_corner_ = old_start_top_left_corner_; } - editor_view_ -> adjustSceneRect(); + m_view -> adjustSceneRect(); } /// refait le coller @@ -165,18 +165,18 @@ void PastePartsCommand::redo() { if (first_redo) first_redo = false; else { // pose les parties - editor_scene_ -> blockSignals(true); + m_scene -> blockSignals(true); foreach(QGraphicsItem *part, content_) { - editor_scene_ -> addItem(part); + m_scene -> addItem(part); } - editor_scene_ -> blockSignals(false); + m_scene -> blockSignals(false); if (uses_offset) { - editor_view_ -> offset_paste_count_ = new_offset_paste_count_; - editor_view_ -> start_top_left_corner_ = new_start_top_left_corner_; + m_view -> offset_paste_count_ = new_offset_paste_count_; + m_view -> start_top_left_corner_ = new_start_top_left_corner_; } } - editor_scene_ -> slot_select(content_); - editor_view_ -> adjustSceneRect(); + m_scene -> slot_select(content_); + m_view -> adjustSceneRect(); } /** @@ -271,17 +271,17 @@ AddPartCommand::AddPartCommand( part(p), first_redo(true) { - editor_scene_ -> qgiManager().manage(part); + m_scene -> qgiManager().manage(part); } /// Destructeur AddPartCommand::~AddPartCommand() { - editor_scene_ -> qgiManager().release(part); + m_scene -> qgiManager().release(part); } /// Annule l'ajout void AddPartCommand::undo() { - editor_scene_ -> removeItem(part); + m_scene -> removeItem(part); } /// Refait l'ajout @@ -291,15 +291,15 @@ void AddPartCommand::redo() { if (!part -> zValue()) { // the added part has no specific zValue already defined, we put it // above existing items (but still under terminals) - QList existing_items = editor_scene_ -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot); + QList existing_items = m_scene -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot); qreal z = existing_items.count() ? existing_items.last() -> zValue() + 1 : 1; part -> setZValue(z); } - editor_scene_ -> clearSelection(); + m_scene -> clearSelection(); first_redo = false; return; } - editor_scene_ -> addItem(part); + m_scene -> addItem(part); } /** @@ -327,12 +327,12 @@ ChangeNamesCommand::~ChangeNamesCommand() { /// Annule le changement void ChangeNamesCommand::undo() { - editor_scene_ -> setNames(names_before); + m_scene -> setNames(names_before); } /// Refait le changement void ChangeNamesCommand::redo() { - editor_scene_ -> setNames(names_after); + m_scene -> setNames(names_after); } /** @@ -350,7 +350,7 @@ ChangeZValueCommand::ChangeZValueCommand( option(o) { // retrieve all primitives but terminals - QList items_list = editor_scene_ -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot); + QList items_list = m_scene -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot); // prend un snapshot des zValues foreach(QGraphicsItem *qgi, items_list) undo_hash.insert(qgi, qgi -> zValue()); @@ -478,12 +478,12 @@ ChangeInformationsCommand::~ChangeInformationsCommand() { /// Annule le changement d'autorisation pour les connexions internes void ChangeInformationsCommand::undo() { - editor_scene_ -> setInformations(old_informations_); + m_scene -> setInformations(old_informations_); } /// Refait le changement d'autorisation pour les connexions internes void ChangeInformationsCommand::redo() { - editor_scene_ -> setInformations(new_informations_); + m_scene -> setInformations(new_informations_); } /** @@ -524,7 +524,7 @@ void ScalePartsCommand::redo() { @return the element editor/scene the command should take place on */ ElementScene *ScalePartsCommand::elementScene() const { - return(editor_scene_); + return(m_scene); } /** @@ -593,24 +593,27 @@ void ScalePartsCommand::adjustText() { * @param context: new info about type. * @param parent: parent undo */ -ChangePropertiesCommand::ChangePropertiesCommand(ElementScene *scene, QString type, DiagramContext info, QUndoCommand *parent) : +ChangePropertiesCommand::ChangePropertiesCommand(ElementScene *scene, QString type, DiagramContext info, DiagramContext elmt_info, QUndoCommand *parent) : ElementEditionCommand(scene, nullptr, parent) { m_type << scene->m_elmt_type << type; - m_info << scene->m_elmt_kindInfo << info; + m_kind_info << scene->m_elmt_kindInfo << info; + m_elmt_info << scene->m_elmt_information << elmt_info; setText(QObject::tr("Modifier les propriétés")); } ChangePropertiesCommand::~ChangePropertiesCommand() {} void ChangePropertiesCommand::undo() { - editor_scene_-> m_elmt_type = m_type.first(); - editor_scene_-> m_elmt_kindInfo = m_info.first(); + m_scene->m_elmt_type = m_type.first(); + m_scene->m_elmt_kindInfo = m_kind_info.first(); + m_scene->m_elmt_information = m_elmt_info.first(); } void ChangePropertiesCommand::redo() { - editor_scene_-> m_elmt_type = m_type.last(); - editor_scene_-> m_elmt_kindInfo = m_info.last(); + m_scene->m_elmt_type = m_type.last(); + m_scene->m_elmt_kindInfo = m_kind_info.last(); + m_scene->m_elmt_information = m_elmt_info.last(); } diff --git a/sources/editor/editorcommands.h b/sources/editor/editorcommands.h index 8a0e77052..651bc7016 100644 --- a/sources/editor/editorcommands.h +++ b/sources/editor/editorcommands.h @@ -49,8 +49,8 @@ class ElementEditionCommand : public QUndoCommand // attributes protected: /// Element editor/view/scene the command should take place on - ElementScene *editor_scene_; - ElementView *editor_view_; + ElementScene *m_scene; + ElementView *m_view; }; /** @@ -296,7 +296,7 @@ class ScalePartsCommand : public ElementEditionCommand { class ChangePropertiesCommand : public ElementEditionCommand { public: - ChangePropertiesCommand (ElementScene *scene, QString type, DiagramContext info, QUndoCommand *parent=nullptr); + ChangePropertiesCommand (ElementScene *scene, QString type, DiagramContext info, DiagramContext elmt_info, QUndoCommand *parent=nullptr); ~ChangePropertiesCommand () override; void undo() override; @@ -304,7 +304,8 @@ class ChangePropertiesCommand : public ElementEditionCommand { private: QList m_type; - QList m_info; + QList m_kind_info; + QList < DiagramContext> m_elmt_info; }; #endif diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index cacca5027..9716c2e16 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -341,6 +341,13 @@ const QDomDocument ElementScene::toXml(bool all_parts) root.appendChild(kindInfo); } + if(m_elmt_type == "simple" || m_elmt_type == "master" || m_elmt_type == "terminal") + { + QDomElement element_info = xml_document.createElement("elementInformations"); + m_elmt_information.toXml(element_info, "elementInformation"); + root.appendChild(element_info); + } + //complementary information about the element QDomElement informations_element = xml_document.createElement("informations"); root.appendChild(informations_element); @@ -638,13 +645,19 @@ void ElementScene::slot_editAuthorInformations() { * @brief ElementScene::slot_editProperties * Open dialog to edit the element properties */ -void ElementScene::slot_editProperties() { +void ElementScene::slot_editProperties() +{ QString type = m_elmt_type; - DiagramContext info = m_elmt_kindInfo; - ElementPropertiesEditorWidget epew(type, info); + DiagramContext kind_info = m_elmt_kindInfo; + DiagramContext elmt_info = m_elmt_information; + + ElementPropertiesEditorWidget epew(type, kind_info, elmt_info); epew.exec(); - if (type != m_elmt_type || info != m_elmt_kindInfo) - undoStack().push(new ChangePropertiesCommand(this, type, info)); + + if (type != m_elmt_type || + kind_info != m_elmt_kindInfo || + elmt_info != m_elmt_information) + undoStack().push(new ChangePropertiesCommand(this, type, kind_info, elmt_info)); } /** @@ -874,9 +887,11 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document) if (root.tagName() != "definition" || root.attribute("type") != "element") return(false); - //Extract info about element type + //Extract info about element type m_elmt_type = root.attribute("link_type", "simple"); m_elmt_kindInfo.fromXml(root.firstChildElement("kindInformations"), "kindInformation"); + //Extract info of element + m_elmt_information.fromXml(root.firstChildElement("elementInformations"), "elementInformation"); //Extract names of xml definition m_names_list.fromXml(root); diff --git a/sources/editor/elementscene.h b/sources/editor/elementscene.h index 184b8a508..c8cf69cf6 100644 --- a/sources/editor/elementscene.h +++ b/sources/editor/elementscene.h @@ -61,19 +61,20 @@ class ElementScene : public QGraphicsScene private: ElementScene(const ElementScene &); - // attributes + // attributes private: - /// List of localized names + /// List of localized names NamesList m_names_list; - /// Extra informations + /// Extra informations QString m_informations; - /// element type + /// element type QString m_elmt_type; - /// element kind info - DiagramContext m_elmt_kindInfo; - /// QGraphicsItem manager + /// element kind info + DiagramContext m_elmt_kindInfo, + m_elmt_information; + /// QGraphicsItem manager QGIManager m_qgi_manager; - /// Undo stack + /// Undo stack QUndoStack m_undo_stack; /// Variables related to drawing diff --git a/sources/editor/ui/elementpropertieseditorwidget.cpp b/sources/editor/ui/elementpropertieseditorwidget.cpp index 50dcea185..b8b9f148d 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.cpp +++ b/sources/editor/ui/elementpropertieseditorwidget.cpp @@ -17,23 +17,51 @@ */ #include "elementpropertieseditorwidget.h" #include "ui_elementpropertieseditorwidget.h" +#include "qetapp.h" + +#include + +/** + * @brief The EditorDelegate class + * This delegate is only use for disable the edition of the first + * column of the information tree widget + */ +class EditorDelegate : public QItemDelegate +{ + public: + EditorDelegate(QObject *parent) : + QItemDelegate(parent) + {} + + QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const + { + if(index.column() == 1) + { + return QItemDelegate::createEditor(parent, option, index); + } + return nullptr; + } +}; /** * @brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget * Default constructor * @param basic_type : QString of the drawed element - * @param dc : DiagramContext to store kindInfo of drawed element + * @param kind_info : DiagramContext to store kindInfo of drawed element + * @param elmt_info : the information of element (label, manufacturer etc...] * @param parent : parent widget */ -ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &dc, QWidget *parent) : +ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &kind_info, DiagramContext &elmt_info, QWidget *parent) : QDialog(parent), ui(new Ui::ElementPropertiesEditorWidget), m_basic_type(basic_type), - m_dc (dc) + m_kind_info (kind_info), + m_elmt_info (elmt_info) { ui->setupUi(this); setUpInterface(); upDateInterface(); + qDebug() << "const"; } /** @@ -49,17 +77,18 @@ ElementPropertiesEditorWidget::~ElementPropertiesEditorWidget() * @brief ElementPropertiesEditorWidget::upDateInterface * Update the interface with the curent value */ -void ElementPropertiesEditorWidget::upDateInterface() { - ui -> m_base_type_cb -> setCurrentIndex (ui -> m_base_type_cb -> findData (QVariant(m_basic_type))); - - if (m_basic_type == "slave") { - ui -> m_state_cb -> setCurrentIndex (ui -> m_state_cb -> findData (m_dc["state"].toString())); - ui -> m_type_cb -> setCurrentIndex (ui -> m_type_cb -> findData (m_dc["type"].toString())); - ui -> m_number_ctc -> setValue (m_dc["number"].toInt()); +void ElementPropertiesEditorWidget::upDateInterface() +{ + ui->m_base_type_cb->setCurrentIndex(ui->m_base_type_cb->findData(QVariant(m_basic_type))); + + if (m_basic_type == "slave") + { + ui->m_state_cb->setCurrentIndex(ui->m_state_cb->findData(m_kind_info["state"].toString())); + ui->m_type_cb->setCurrentIndex (ui->m_type_cb->findData(m_kind_info["type"].toString())); + ui->m_number_ctc->setValue(m_kind_info["number"].toInt()); } - else if (m_basic_type == "master") { - ui -> m_master_type_cb -> setCurrentIndex (ui -> m_master_type_cb -> findData (m_dc["type"])); + ui->m_master_type_cb->setCurrentIndex(ui->m_master_type_cb->findData (m_kind_info["type"])); } on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex()); @@ -68,28 +97,71 @@ void ElementPropertiesEditorWidget::upDateInterface() { /** * @brief ElementPropertiesEditorWidget::setUpInterface */ -void ElementPropertiesEditorWidget::setUpInterface() { - // Type combo box - ui -> m_base_type_cb -> addItem (tr("Simple"), QVariant("simple")); - ui -> m_base_type_cb -> addItem (tr("Maître"), QVariant("master")); - ui -> m_base_type_cb -> addItem (tr("Esclave"), QVariant("slave")); - ui -> m_base_type_cb -> addItem (tr("Renvoi de folio suivant"), QVariant("next_report")); - ui -> m_base_type_cb -> addItem (tr("Renvoi de folio précédent"), QVariant("previous_report")); - ui -> m_base_type_cb -> addItem (tr("Bornier"), QVariant("terminal")); +void ElementPropertiesEditorWidget::setUpInterface() +{ + // Type combo box + ui->m_base_type_cb->addItem (tr("Simple"), QVariant("simple")); + ui->m_base_type_cb->addItem (tr("Maître"), QVariant("master")); + ui->m_base_type_cb->addItem (tr("Esclave"), QVariant("slave")); + ui->m_base_type_cb->addItem (tr("Renvoi de folio suivant"), QVariant("next_report")); + ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"), QVariant("previous_report")); + ui->m_base_type_cb->addItem (tr("Bornier"), QVariant("terminal")); - // Slave option - ui -> m_state_cb -> addItem(tr("Normalement ouvert"), QVariant("NO")); - ui -> m_state_cb -> addItem(tr("Normalement fermé"), QVariant("NC")); - ui -> m_state_cb -> addItem(tr("Inverseur"), QVariant("SW")); - ui -> m_type_cb -> addItem(tr("Simple"), QVariant("simple")); - ui -> m_type_cb -> addItem(tr("Puissance"), QVariant("power")); - ui -> m_type_cb -> addItem(tr("Temporisé travail"), QVariant("delayOn")); - ui -> m_type_cb -> addItem(tr("Temporisé repos"), QVariant("delayOff")); + // Slave option + ui->m_state_cb->addItem(tr("Normalement ouvert"),QVariant("NO")); + ui->m_state_cb->addItem(tr("Normalement fermé"), QVariant("NC")); + ui->m_state_cb->addItem(tr("Inverseur"), QVariant("SW")); + ui->m_type_cb->addItem(tr("Simple"), QVariant("simple")); + ui->m_type_cb->addItem(tr("Puissance"), QVariant("power")); + ui->m_type_cb->addItem(tr("Temporisé travail"), QVariant("delayOn")); + ui->m_type_cb->addItem(tr("Temporisé repos"), QVariant("delayOff")); - //Master option - ui -> m_master_type_cb -> addItem(tr("Bobine"), QVariant("coil")); - ui -> m_master_type_cb -> addItem(tr("Organe de protection"), QVariant("protection")); - ui -> m_master_type_cb -> addItem(tr("Commutateur / bouton"), QVariant("commutator")); + //Master option + ui->m_master_type_cb->addItem(tr("Bobine"), QVariant("coil")); + ui->m_master_type_cb->addItem(tr("Organe de protection"), QVariant("protection")); + ui->m_master_type_cb->addItem(tr("Commutateur / bouton"), QVariant("commutator")); + + //Disable the edition of the first column of the information tree + //by this little workaround + ui->m_tree->setItemDelegate(new EditorDelegate(this)); + ui->m_tree->header()->resizeSection(0, 150); + populateTree(); +} + +void ElementPropertiesEditorWidget::updateTree() +{ + QString type = ui->m_base_type_cb->itemData(ui->m_base_type_cb->currentIndex()).toString(); + + if (type == "master") + ui->m_tree->setEnabled(true); + else if (type == "slave") + ui->m_tree->setDisabled(true); + else if (type == "simple") + ui->m_tree->setEnabled(true); + else if (type == "next_report") + ui->m_tree->setDisabled(true); + else if (type == "previous_report") + ui->m_tree->setDisabled(true); + else if (type == "terminal") + ui->m_tree->setEnabled(true); +} + +/** + * @brief ElementPropertiesEditorWidget::populateTree + * Create QTreeWidgetItem of the tree widget and populate it + */ +void ElementPropertiesEditorWidget::populateTree() +{ + QStringList keys{"label", "comment", "designation", "manufacturer", "manufacturer-reference", "machine-manufacturer-reference"}; + + for(QString key : keys) + { + QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree); + qtwi->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable); + qtwi->setData(0, Qt::DisplayRole, QETApp::elementTranslatedInfoKey(key)); + qtwi->setData(0, Qt::UserRole, key); + qtwi->setText(1, m_elmt_info.value(key).toString()); + } } /** @@ -100,13 +172,18 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted() { m_basic_type = ui -> m_base_type_cb -> itemData(ui -> m_base_type_cb -> currentIndex()).toString(); if (m_basic_type == "slave") { - m_dc.addValue("state", ui -> m_state_cb -> itemData(ui -> m_state_cb -> currentIndex())); - m_dc.addValue("type", ui -> m_type_cb -> itemData(ui -> m_type_cb -> currentIndex())); - m_dc.addValue("number", QVariant(ui -> m_number_ctc -> value())); + m_kind_info.addValue("state", ui -> m_state_cb -> itemData(ui -> m_state_cb -> currentIndex())); + m_kind_info.addValue("type", ui -> m_type_cb -> itemData(ui -> m_type_cb -> currentIndex())); + m_kind_info.addValue("number", QVariant(ui -> m_number_ctc -> value())); } else if(m_basic_type == "master") { - m_dc.addValue("type", ui -> m_master_type_cb -> itemData(ui -> m_master_type_cb -> currentIndex())); + m_kind_info.addValue("type", ui -> m_master_type_cb -> itemData(ui -> m_master_type_cb -> currentIndex())); } + + for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren()) + if(!qtwi->text(1).isEmpty()) + m_elmt_info.addValue(qtwi->data(0, Qt::UserRole).toString(), qtwi->text(1)); + this->close(); } @@ -118,9 +195,11 @@ void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int in { bool slave = false , master = false; - if (ui -> m_base_type_cb -> itemData(index).toString() == "slave") slave = true; - else if (ui -> m_base_type_cb -> itemData(index).toString() == "master") master = true; + if (ui->m_base_type_cb->itemData(index).toString() == "slave") slave = true; + else if (ui->m_base_type_cb->itemData(index).toString() == "master") master = true; - ui -> m_slave_gb -> setVisible(slave); - ui -> m_master_gb -> setVisible(master); + ui->m_slave_gb->setVisible(slave); + ui->m_master_gb->setVisible(master); + + updateTree(); } diff --git a/sources/editor/ui/elementpropertieseditorwidget.h b/sources/editor/ui/elementpropertieseditorwidget.h index fa432b66a..f608e588a 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.h +++ b/sources/editor/ui/elementpropertieseditorwidget.h @@ -37,24 +37,27 @@ class ElementPropertiesEditorWidget : public QDialog //METHODS public: - explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &dc, QWidget *parent = nullptr); - ~ElementPropertiesEditorWidget() override; + explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &kind_info, DiagramContext &elmt_info, QWidget *parent = nullptr); + ~ElementPropertiesEditorWidget() override; - void upDateInterface(); + void upDateInterface(); private: - void setUpInterface(); + void setUpInterface(); + void updateTree(); + void populateTree(); - //SLOTS + //SLOTS private slots: - void on_m_buttonBox_accepted(); - void on_m_base_type_cb_currentIndexChanged(int index); + void on_m_buttonBox_accepted(); + void on_m_base_type_cb_currentIndexChanged(int index); - //ATTRIBUTES + //ATTRIBUTES private: - Ui::ElementPropertiesEditorWidget *ui; - QString &m_basic_type; - DiagramContext &m_dc; + Ui::ElementPropertiesEditorWidget *ui; + QString &m_basic_type; + DiagramContext &m_kind_info, + &m_elmt_info; }; #endif // ELEMENTPROPERTIESEDITORWIDGET_H diff --git a/sources/editor/ui/elementpropertieseditorwidget.ui b/sources/editor/ui/elementpropertieseditorwidget.ui index e0738c37d..d68cd3103 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.ui +++ b/sources/editor/ui/elementpropertieseditorwidget.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 450 + 321 @@ -18,98 +18,136 @@ - - - - - Type de base : - - - - - - - - - - - - Élément esclave + + + 0 - - - - - - - 1 - - - - - + + + Type + + + + + + + + Type de base : + + + + + + + + + + + + Élément esclave + + + + + + + + 1 + + + + + + + Nombre de contact représenté + + + + + + + Type de contact + + + + + + + État du contact + + + + + + + + + + + + + + + + + + Élément maître + + + + + + Type concret + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Informations + + + + + + 150 + + - Nombre de contact représenté + Nom - - - - + + - Type de contact + Valeurs - - - - - - État du contact - - - - - - - - - - - - + + + + + - - - - Élément maître - - - - - - Type concret - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/sources/qetgraphicsitem/customelement.cpp b/sources/qetgraphicsitem/customelement.cpp index 6f32c8349..a59801760 100644 --- a/sources/qetgraphicsitem/customelement.cpp +++ b/sources/qetgraphicsitem/customelement.cpp @@ -150,7 +150,9 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) { setToolTip(name()); //load kind informations - kind_informations_.fromXml(xml_def_elmt.firstChildElement("kindInformations"), "kindInformation"); + m_kind_informations.fromXml(xml_def_elmt.firstChildElement("kindInformations"), "kindInformation"); + //load element information + m_element_informations.fromXml(xml_def_elmt.firstChildElement("elementInformations"), "elementInformation"); //scroll of the Children of the Definition: Parts of the Drawing int parsed_elements_count = 0; diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index a16112797..b73bf4fea 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -136,7 +136,7 @@ class Element : public QetGraphicsItem DiagramContext elementInformations ()const {return m_element_informations;} DiagramContext& rElementInformations () {return m_element_informations;} virtual void setElementInformations (DiagramContext dc); - DiagramContext kindInformations () const {return kind_informations_;} //@kind_information_ is used to store more information + DiagramContext kindInformations () const {return m_kind_informations;} //@kind_information_ is used to store more information //about the herited class like contactelement for know // kind of contact (simple tempo) or number of contact show by the element. @@ -154,7 +154,7 @@ class Element : public QetGraphicsItem //ATTRIBUTES protected: - DiagramContext m_element_informations, kind_informations_; + DiagramContext m_element_informations, m_kind_informations; autonum::sequentialNumbers m_autoNum_seq; bool m_freeze_label = false; QString m_F_str;