mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Update number and name to the editor: Work now!
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2632 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -58,6 +58,7 @@ void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
// 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 @@ const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||
// Write name and number to XML
|
||||
xml_element.setAttribute("number", number_);
|
||||
xml_element.setAttribute("name", name_);
|
||||
xml_element.setAttribute("nameHidden", nameHidden_);
|
||||
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -180,6 +182,20 @@ void PartTerminal::setName(const QString &na) {
|
||||
name_ = na;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 :
|
||||
@@ -204,6 +220,9 @@ void PartTerminal::setProperty(const QString &property, const QVariant &value) {
|
||||
} 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 @@ QVariant PartTerminal::property(const QString &property) {
|
||||
return(number_);
|
||||
} else if (property == "name") {
|
||||
return(name_);
|
||||
} else if (property == "nameHidden") {
|
||||
return(nameHidden_);
|
||||
}
|
||||
return(QVariant());
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
||||
QET::Orientation _orientation;
|
||||
QPointF second_point;
|
||||
QString number_, name_;
|
||||
bool nameHidden_;
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -59,6 +60,8 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
||||
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 &);
|
||||
|
||||
@@ -43,6 +43,7 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
||||
|
||||
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 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
||||
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 @@ void TerminalEditor::updateTerminal() {
|
||||
);
|
||||
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 @@ void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"),
|
||||
/// 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 @@ void TerminalEditor::updateForm() {
|
||||
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 @@ void TerminalEditor::activeConnections(bool active) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class TerminalEditor : public ElementItemEditor {
|
||||
QLineEdit *qle_x, *qle_y;
|
||||
QComboBox *orientation;
|
||||
QLineEdit *qle_number, *qle_name;
|
||||
QCheckBox *qcheck_name_visible;
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -51,6 +52,7 @@ class TerminalEditor : public ElementItemEditor {
|
||||
void updateTerminalO();
|
||||
void updateTerminalNum();
|
||||
void updateTerminalName();
|
||||
void updateTerminalNameVisible();
|
||||
void updateForm();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user