[qet] [2632] Update number and name to the editor: Work now! |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2632
Author: cfdev
Date: 2013-11-21 17:25:56 +0100 (Thu, 21 Nov 2013)
Log Message:
-----------
Update number and name to the editor: Work now!
Modified Paths:
--------------
trunk/sources/editor/partterminal.cpp
trunk/sources/editor/partterminal.h
trunk/sources/editor/terminaleditor.cpp
trunk/sources/editor/terminaleditor.h
Modified: trunk/sources/editor/partterminal.cpp
===================================================================
--- trunk/sources/editor/partterminal.cpp 2013-11-21 16:24:55 UTC (rev 2631)
+++ trunk/sources/editor/partterminal.cpp 2013-11-21 16:25:56 UTC (rev 2632)
@@ -58,6 +58,7 @@
// Read number and name of terminal from XML
number_ = xml_elmt.attribute("number");
name_ = xml_elmt.attribute("name");
+ nameHidden_ = xml_elmt.attribute("nameHidden").toInt();
updateSecondPoint();
}
@@ -79,6 +80,7 @@
// Write name and number to XML
xml_element.setAttribute("number", number_);
xml_element.setAttribute("name", name_);
+ xml_element.setAttribute("nameHidden", nameHidden_);
return(xml_element);
}
@@ -181,6 +183,20 @@
}
/**
+ * @brief PartTerminal::nameIsHidden
+ * @return
+ */
+bool PartTerminal::nameIsHidden() const {
+ return(nameHidden_);
+}
+/**
+ * @brief PartTerminal::setNameHidden
+ */
+void PartTerminal::setNameHidden(const bool &nh) {
+ nameHidden_ = nh;
+}
+
+/**
Specifie la valeur d'une propriete donnee de la borne
@param property propriete a modifier. Valeurs acceptees :
* x : abscisse de la borne
@@ -204,6 +220,9 @@
} else if (property == "name") {
if (!value.canConvert(QVariant::String)) return;
setName(value.toString());
+ } else if (property == "nameHidden") {
+ if (!value.canConvert(QVariant::Int)) return;
+ setNameHidden(value.toInt());
}
}
@@ -226,6 +245,8 @@
return(number_);
} else if (property == "name") {
return(name_);
+ } else if (property == "nameHidden") {
+ return(nameHidden_);
}
return(QVariant());
}
Modified: trunk/sources/editor/partterminal.h
===================================================================
--- trunk/sources/editor/partterminal.h 2013-11-21 16:24:55 UTC (rev 2631)
+++ trunk/sources/editor/partterminal.h 2013-11-21 16:25:56 UTC (rev 2632)
@@ -37,6 +37,7 @@
QET::Orientation _orientation;
QPointF second_point;
QString number_, name_;
+ bool nameHidden_;
// methods
public:
@@ -59,6 +60,8 @@
void setNumber(const QString &);
QString nameOfTerminal() const;
void setName(const QString &);
+ bool nameIsHidden() const;
+ void setNameHidden(const bool &);
virtual void setProperty(const QString &, const QVariant &);
virtual QVariant property(const QString &);
Modified: trunk/sources/editor/terminaleditor.cpp
===================================================================
--- trunk/sources/editor/terminaleditor.cpp 2013-11-21 16:24:55 UTC (rev 2631)
+++ trunk/sources/editor/terminaleditor.cpp 2013-11-21 16:25:56 UTC (rev 2632)
@@ -43,6 +43,7 @@
qle_number = new QLineEdit();
qle_name = new QLineEdit();
+ qcheck_name_visible = new QCheckBox(tr("Visible"));
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
@@ -59,11 +60,15 @@
ori -> addWidget(orientation );
main_layout -> addLayout(ori);
+ QHBoxLayout *name = new QHBoxLayout();
+ name -> addWidget(new QLabel(tr("Nom : ")));
+ name -> addWidget(qle_name );
+ name -> addWidget(qcheck_name_visible );
+ main_layout -> addLayout(name);
+
QHBoxLayout *num = new QHBoxLayout();
num -> addWidget(new QLabel(tr("Num\351ro : ")));
num -> addWidget(qle_number );
- num -> addWidget(new QLabel(tr("Nom : ")));
- num -> addWidget(qle_name );
main_layout -> addLayout(num);
main_layout -> addStretch();
@@ -121,8 +126,10 @@
);
part -> setNumber( qle_number->text() );
part -> setName ( qle_name->text() );
+ part -> setNameHidden( !qcheck_name_visible ->isChecked() );
}
+/// WARNING!!!! on addChangePartCommand the prop accept only the simple string! (NOT /:;,?...)
/// Met a jour l'abscisse de la position de la borne et cree un objet d'annulation
void TerminalEditor::updateTerminalX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
/// Met a jour l'ordonnee de la position de la borne et cree un objet d'annulation
@@ -130,9 +137,18 @@
/// Met a jour l'orientation de la borne et cree un objet d'annulation
void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex()).toInt()); }
/// update Number and name, create cancel object
-void TerminalEditor::updateTerminalNum() { addChangePartCommand(tr("num\351ro: ")+qle_number -> text(), part, "num\351ro:", qle_number -> text()); updateForm(); }
-void TerminalEditor::updateTerminalName() { addChangePartCommand(tr("nom: ")+qle_name -> text(), part, "nom", qle_name -> text()); updateForm(); }
-
+void TerminalEditor::updateTerminalNum() {
+ addChangePartCommand(tr("num\351ro: ")+qle_number -> text(), part, "number", qle_number -> text());
+ updateForm();
+}
+void TerminalEditor::updateTerminalName() {
+ addChangePartCommand(tr("nom: ")+qle_name -> text(), part, "name", qle_name -> text());
+ updateForm();
+}
+void TerminalEditor::updateTerminalNameVisible() {
+ addChangePartCommand(tr("nom visible: ")+QString::number( qcheck_name_visible->isChecked()), part, "nameHidden", !qcheck_name_visible -> isChecked());
+ updateForm();
+}
/**
Met a jour le formulaire d'edition
*/
@@ -144,6 +160,7 @@
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
qle_number -> setText(part -> number() );
qle_name -> setText(part -> nameOfTerminal() );
+ qcheck_name_visible ->setChecked( !part -> nameIsHidden() );
activeConnections(true);
}
@@ -158,11 +175,13 @@
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
connect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
connect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
+ connect(qcheck_name_visible, SIGNAL(stateChanged ( int)), this, SLOT(updateTerminalNameVisible()));
} else {
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
disconnect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
disconnect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
disconnect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
+ disconnect(qcheck_name_visible, SIGNAL(stateChanged ( int)), this, SLOT(updateTerminalNameVisible()));
}
}
Modified: trunk/sources/editor/terminaleditor.h
===================================================================
--- trunk/sources/editor/terminaleditor.h 2013-11-21 16:24:55 UTC (rev 2631)
+++ trunk/sources/editor/terminaleditor.h 2013-11-21 16:25:56 UTC (rev 2632)
@@ -38,6 +38,7 @@
QLineEdit *qle_x, *qle_y;
QComboBox *orientation;
QLineEdit *qle_number, *qle_name;
+ QCheckBox *qcheck_name_visible;
// methods
public:
@@ -51,6 +52,7 @@
void updateTerminalO();
void updateTerminalNum();
void updateTerminalName();
+ void updateTerminalNameVisible();
void updateForm();
private: