mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Element editor : element informations (manufacturer, reference etc...) can be created directly from the element editor. For that go to the widget "Element Property"
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5057 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -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<QGraphicsItem *> existing_items = editor_scene_ -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot);
|
||||
QList<QGraphicsItem *> 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<QGraphicsItem *> items_list = editor_scene_ -> zItems(ElementScene::SortByZValue | ElementScene::SelectedOrNot);
|
||||
QList<QGraphicsItem *> 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 <QString> m_type;
|
||||
QList <DiagramContext> m_info;
|
||||
QList <DiagramContext> m_kind_info;
|
||||
QList < DiagramContext> m_elmt_info;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -877,6 +890,8 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document)
|
||||
//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);
|
||||
|
||||
@@ -70,7 +70,8 @@ class ElementScene : public QGraphicsScene
|
||||
/// element type
|
||||
QString m_elmt_type;
|
||||
/// element kind info
|
||||
DiagramContext m_elmt_kindInfo;
|
||||
DiagramContext m_elmt_kindInfo,
|
||||
m_elmt_information;
|
||||
/// QGraphicsItem manager
|
||||
QGIManager m_qgi_manager;
|
||||
/// Undo stack
|
||||
|
||||
@@ -17,23 +17,51 @@
|
||||
*/
|
||||
#include "elementpropertieseditorwidget.h"
|
||||
#include "ui_elementpropertieseditorwidget.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
#include <QItemDelegate>
|
||||
|
||||
/**
|
||||
* @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() {
|
||||
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());
|
||||
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,7 +97,8 @@ void ElementPropertiesEditorWidget::upDateInterface() {
|
||||
/**
|
||||
* @brief ElementPropertiesEditorWidget::setUpInterface
|
||||
*/
|
||||
void 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"));
|
||||
@@ -90,6 +120,48 @@ void ElementPropertiesEditorWidget::setUpInterface() {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -123,4 +200,6 @@ void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int in
|
||||
|
||||
ui->m_slave_gb->setVisible(slave);
|
||||
ui->m_master_gb->setVisible(master);
|
||||
|
||||
updateTree();
|
||||
}
|
||||
|
||||
@@ -37,13 +37,15 @@ class ElementPropertiesEditorWidget : public QDialog
|
||||
|
||||
//METHODS
|
||||
public:
|
||||
explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &dc, QWidget *parent = nullptr);
|
||||
explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &kind_info, DiagramContext &elmt_info, QWidget *parent = nullptr);
|
||||
~ElementPropertiesEditorWidget() override;
|
||||
|
||||
void upDateInterface();
|
||||
|
||||
private:
|
||||
void setUpInterface();
|
||||
void updateTree();
|
||||
void populateTree();
|
||||
|
||||
//SLOTS
|
||||
private slots:
|
||||
@@ -54,7 +56,8 @@ class ElementPropertiesEditorWidget : public QDialog
|
||||
private:
|
||||
Ui::ElementPropertiesEditorWidget *ui;
|
||||
QString &m_basic_type;
|
||||
DiagramContext &m_dc;
|
||||
DiagramContext &m_kind_info,
|
||||
&m_elmt_info;
|
||||
};
|
||||
|
||||
#endif // ELEMENTPROPERTIESEDITORWIDGET_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>450</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -17,6 +17,16 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Type">
|
||||
<attribute name="title">
|
||||
<string>Type</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@@ -98,7 +108,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
@@ -110,6 +120,34 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Informations">
|
||||
<attribute name="title">
|
||||
<string>Informations</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="m_tree">
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>150</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Nom</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Valeurs</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user