mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20: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
|
// Read number and name of terminal from XML
|
||||||
number_ = xml_elmt.attribute("number");
|
number_ = xml_elmt.attribute("number");
|
||||||
name_ = xml_elmt.attribute("name");
|
name_ = xml_elmt.attribute("name");
|
||||||
|
nameHidden_ = xml_elmt.attribute("nameHidden").toInt();
|
||||||
|
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
}
|
}
|
||||||
@@ -79,6 +80,7 @@ const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
|||||||
// Write name and number to XML
|
// Write name and number to XML
|
||||||
xml_element.setAttribute("number", number_);
|
xml_element.setAttribute("number", number_);
|
||||||
xml_element.setAttribute("name", name_);
|
xml_element.setAttribute("name", name_);
|
||||||
|
xml_element.setAttribute("nameHidden", nameHidden_);
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -180,6 +182,20 @@ void PartTerminal::setName(const QString &na) {
|
|||||||
name_ = 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
|
Specifie la valeur d'une propriete donnee de la borne
|
||||||
@param property propriete a modifier. Valeurs acceptees :
|
@param property propriete a modifier. Valeurs acceptees :
|
||||||
@@ -204,6 +220,9 @@ void PartTerminal::setProperty(const QString &property, const QVariant &value) {
|
|||||||
} else if (property == "name") {
|
} else if (property == "name") {
|
||||||
if (!value.canConvert(QVariant::String)) return;
|
if (!value.canConvert(QVariant::String)) return;
|
||||||
setName(value.toString());
|
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_);
|
return(number_);
|
||||||
} else if (property == "name") {
|
} else if (property == "name") {
|
||||||
return(name_);
|
return(name_);
|
||||||
|
} else if (property == "nameHidden") {
|
||||||
|
return(nameHidden_);
|
||||||
}
|
}
|
||||||
return(QVariant());
|
return(QVariant());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
|||||||
QET::Orientation _orientation;
|
QET::Orientation _orientation;
|
||||||
QPointF second_point;
|
QPointF second_point;
|
||||||
QString number_, name_;
|
QString number_, name_;
|
||||||
|
bool nameHidden_;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -59,6 +60,8 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
|||||||
void setNumber(const QString &);
|
void setNumber(const QString &);
|
||||||
QString nameOfTerminal() const;
|
QString nameOfTerminal() const;
|
||||||
void setName(const QString &);
|
void setName(const QString &);
|
||||||
|
bool nameIsHidden() const;
|
||||||
|
void setNameHidden(const bool &);
|
||||||
|
|
||||||
virtual void setProperty(const QString &, const QVariant &);
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
virtual QVariant property(const QString &);
|
virtual QVariant property(const QString &);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
|||||||
|
|
||||||
qle_number = new QLineEdit();
|
qle_number = new QLineEdit();
|
||||||
qle_name = new QLineEdit();
|
qle_name = new QLineEdit();
|
||||||
|
qcheck_name_visible = new QCheckBox(tr("Visible"));
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||||
@@ -59,11 +60,15 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
|||||||
ori -> addWidget(orientation );
|
ori -> addWidget(orientation );
|
||||||
main_layout -> addLayout(ori);
|
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();
|
QHBoxLayout *num = new QHBoxLayout();
|
||||||
num -> addWidget(new QLabel(tr("Num\351ro : ")));
|
num -> addWidget(new QLabel(tr("Num\351ro : ")));
|
||||||
num -> addWidget(qle_number );
|
num -> addWidget(qle_number );
|
||||||
num -> addWidget(new QLabel(tr("Nom : ")));
|
|
||||||
num -> addWidget(qle_name );
|
|
||||||
main_layout -> addLayout(num);
|
main_layout -> addLayout(num);
|
||||||
|
|
||||||
main_layout -> addStretch();
|
main_layout -> addStretch();
|
||||||
@@ -121,8 +126,10 @@ void TerminalEditor::updateTerminal() {
|
|||||||
);
|
);
|
||||||
part -> setNumber( qle_number->text() );
|
part -> setNumber( qle_number->text() );
|
||||||
part -> setName ( qle_name->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
|
/// 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(); }
|
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
|
/// 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
|
/// 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()); }
|
void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex()).toInt()); }
|
||||||
/// update Number and name, create cancel object
|
/// 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::updateTerminalNum() {
|
||||||
void TerminalEditor::updateTerminalName() { addChangePartCommand(tr("nom: ")+qle_name -> text(), part, "nom", qle_name -> text()); updateForm(); }
|
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
|
Met a jour le formulaire d'edition
|
||||||
*/
|
*/
|
||||||
@@ -144,6 +160,7 @@ void TerminalEditor::updateForm() {
|
|||||||
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
||||||
qle_number -> setText(part -> number() );
|
qle_number -> setText(part -> number() );
|
||||||
qle_name -> setText(part -> nameOfTerminal() );
|
qle_name -> setText(part -> nameOfTerminal() );
|
||||||
|
qcheck_name_visible ->setChecked( !part -> nameIsHidden() );
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,11 +175,13 @@ void TerminalEditor::activeConnections(bool active) {
|
|||||||
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
||||||
connect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
|
connect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
|
||||||
connect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
|
connect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
|
||||||
|
connect(qcheck_name_visible, SIGNAL(stateChanged ( int)), this, SLOT(updateTerminalNameVisible()));
|
||||||
} else {
|
} else {
|
||||||
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
disconnect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
||||||
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
disconnect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
||||||
disconnect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
disconnect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
||||||
disconnect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
|
disconnect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
|
||||||
disconnect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
|
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;
|
QLineEdit *qle_x, *qle_y;
|
||||||
QComboBox *orientation;
|
QComboBox *orientation;
|
||||||
QLineEdit *qle_number, *qle_name;
|
QLineEdit *qle_number, *qle_name;
|
||||||
|
QCheckBox *qcheck_name_visible;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -51,6 +52,7 @@ class TerminalEditor : public ElementItemEditor {
|
|||||||
void updateTerminalO();
|
void updateTerminalO();
|
||||||
void updateTerminalNum();
|
void updateTerminalNum();
|
||||||
void updateTerminalName();
|
void updateTerminalName();
|
||||||
|
void updateTerminalNameVisible();
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user