mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-24 03:10:52 +01:00
Element editor -> properties: user can edit subtype for master.
Change the properties is now managed by undo command git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3157 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -660,3 +660,33 @@ void ScalePartsCommand::adjustText() {
|
|||||||
setText(QObject::tr("redimensionnement de %1 primitives", "undo caption -- %1 always > 1").arg(scaled_primitives_.count()));
|
setText(QObject::tr("redimensionnement de %1 primitives", "undo caption -- %1 always > 1").arg(scaled_primitives_.count()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief ChangePropertiesCommand::ChangePropertiesCommand
|
||||||
|
* Change the properties of the drawed element
|
||||||
|
* @param scene: scene to belong the property
|
||||||
|
* @param type: new type of element.
|
||||||
|
* @param context: new info about type.
|
||||||
|
* @param parent: parent undo
|
||||||
|
*/
|
||||||
|
ChangePropertiesCommand::ChangePropertiesCommand(ElementScene *scene, QString type, DiagramContext info, QUndoCommand *parent) :
|
||||||
|
ElementEditionCommand(scene, 0, parent)
|
||||||
|
{
|
||||||
|
m_type << scene->m_elmt_type << type;
|
||||||
|
m_info << scene->m_elmt_kindInfo << info;
|
||||||
|
setText(QObject::tr("Modifier les propri\351t\351s"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangePropertiesCommand::~ChangePropertiesCommand() {}
|
||||||
|
|
||||||
|
void ChangePropertiesCommand::undo() {
|
||||||
|
editor_scene_-> m_elmt_type = m_type.first();
|
||||||
|
editor_scene_-> m_elmt_kindInfo = m_info.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangePropertiesCommand::redo() {
|
||||||
|
editor_scene_-> m_elmt_type = m_type.last();
|
||||||
|
editor_scene_-> m_elmt_kindInfo = m_info.last();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -349,4 +349,17 @@ class ScalePartsCommand : public ElementEditionCommand {
|
|||||||
bool first_redo;
|
bool first_redo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ChangePropertiesCommand : public ElementEditionCommand {
|
||||||
|
public:
|
||||||
|
ChangePropertiesCommand (ElementScene *scene, QString type, DiagramContext info, QUndoCommand *parent=0);
|
||||||
|
virtual ~ChangePropertiesCommand ();
|
||||||
|
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList <QString> m_type;
|
||||||
|
QList <DiagramContext> m_info;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ const QDomDocument ElementScene::toXml(bool all_parts) {
|
|||||||
// noms de l'element
|
// noms de l'element
|
||||||
root.appendChild(_names.toXml(xml_document));
|
root.appendChild(_names.toXml(xml_document));
|
||||||
|
|
||||||
if (m_elmt_type == "slave") {
|
if (m_elmt_type == "slave" || m_elmt_type == "master") {
|
||||||
QDomElement kindInfo = xml_document.createElement("kindInformations");
|
QDomElement kindInfo = xml_document.createElement("kindInformations");
|
||||||
m_elmt_kindInfo.toXml(kindInfo, "kindInformation");
|
m_elmt_kindInfo.toXml(kindInfo, "kindInformation");
|
||||||
root.appendChild(kindInfo);
|
root.appendChild(kindInfo);
|
||||||
@@ -722,8 +722,12 @@ void ElementScene::slot_editAuthorInformations() {
|
|||||||
* Open dialog to edit the element properties
|
* Open dialog to edit the element properties
|
||||||
*/
|
*/
|
||||||
void ElementScene::slot_editProperties() {
|
void ElementScene::slot_editProperties() {
|
||||||
ElementPropertiesEditorWidget epew(m_elmt_type, m_elmt_kindInfo);
|
QString type = m_elmt_type;
|
||||||
|
DiagramContext info = m_elmt_kindInfo;
|
||||||
|
ElementPropertiesEditorWidget epew(type, info);
|
||||||
epew.exec();
|
epew.exec();
|
||||||
|
if (type != m_elmt_type || info != m_elmt_kindInfo)
|
||||||
|
undoStack().push(new ChangePropertiesCommand(this, type, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class PartArc;
|
|||||||
border due to its fixed size and its hotspot.
|
border due to its fixed size and its hotspot.
|
||||||
*/
|
*/
|
||||||
class ElementScene : public QGraphicsScene {
|
class ElementScene : public QGraphicsScene {
|
||||||
|
friend class ChangePropertiesCommand;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// enum
|
// enum
|
||||||
|
|||||||
@@ -45,11 +45,22 @@ ElementPropertiesEditorWidget::~ElementPropertiesEditorWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)));
|
ui -> m_base_type_cb -> setCurrentIndex (ui -> m_base_type_cb -> findData (QVariant(m_basic_type)));
|
||||||
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()));
|
if (m_basic_type == "slave") {
|
||||||
ui -> m_number_ctc -> setValue (m_dc["number"].toInt());
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (m_basic_type == "master") {
|
||||||
|
ui -> m_master_type_cb -> setCurrentIndex (ui -> m_master_type_cb -> findData (m_dc["type"]));
|
||||||
|
}
|
||||||
|
|
||||||
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
|
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
|
||||||
}
|
}
|
||||||
@@ -72,6 +83,10 @@ void ElementPropertiesEditorWidget::setUpInterface() {
|
|||||||
ui -> m_type_cb -> addItem(tr("Puissance"), QVariant("power"));
|
ui -> m_type_cb -> addItem(tr("Puissance"), QVariant("power"));
|
||||||
ui -> m_type_cb -> addItem(tr("Temporis\351 travail"), QVariant("delayOn"));
|
ui -> m_type_cb -> addItem(tr("Temporis\351 travail"), QVariant("delayOn"));
|
||||||
ui -> m_type_cb -> addItem(tr("Temporis\351 repos"), QVariant("delayOff"));
|
ui -> m_type_cb -> addItem(tr("Temporis\351 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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,6 +101,9 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
|
|||||||
m_dc.addValue("type", ui -> m_type_cb -> itemData(ui -> m_type_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_dc.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()));
|
||||||
|
}
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,10 +113,11 @@ 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)
|
||||||
{
|
{
|
||||||
if (ui->m_base_type_cb->itemData(index).toString() == "slave") {
|
bool slave = false , master = false;
|
||||||
ui->m_slave_gb->setEnabled(true);
|
|
||||||
} else {
|
|
||||||
ui->m_slave_gb->setEnabled(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;
|
||||||
|
|
||||||
|
ui -> m_slave_gb -> setVisible(slave);
|
||||||
|
ui -> m_master_gb -> setVisible(master);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,25 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="m_master_gb">
|
||||||
|
<property name="title">
|
||||||
|
<string>Élément maître</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Type concret</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="m_master_type_cb"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user