mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
EditorElement: try to add number and name GUI...so hard! why is it so complicated?!
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2618 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -54,6 +54,11 @@ void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
|
||||
// lit l'orientation de la borne
|
||||
_orientation = QET::orientationFromString(xml_elmt.attribute("orientation"));
|
||||
|
||||
// Read number and name of terminal from XML
|
||||
number_ = xml_elmt.attribute("number");
|
||||
name_ = xml_elmt.attribute("name");
|
||||
|
||||
updateSecondPoint();
|
||||
}
|
||||
|
||||
@@ -71,6 +76,9 @@ const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||
|
||||
// ecrit l'orientation de la borne
|
||||
xml_element.setAttribute("orientation", orientationToString(_orientation));
|
||||
// Write name and number to XML
|
||||
xml_element.setAttribute("number", number_);
|
||||
xml_element.setAttribute("name", name_);
|
||||
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -142,6 +150,36 @@ void PartTerminal::setOrientation(QET::Orientation ori) {
|
||||
updateSecondPoint();
|
||||
}
|
||||
|
||||
/**
|
||||
@return Number of terminal
|
||||
*/
|
||||
QString PartTerminal::number() const {
|
||||
return(number_);
|
||||
}
|
||||
|
||||
/**
|
||||
set Number of Terminal
|
||||
@param num number of terminal
|
||||
*/
|
||||
void PartTerminal::setNumber(const QString &num) {
|
||||
number_ = num;
|
||||
}
|
||||
|
||||
/**
|
||||
@return Name of terminal
|
||||
*/
|
||||
QString PartTerminal::nameOfTerminal() const {
|
||||
return(name_);
|
||||
}
|
||||
|
||||
/**
|
||||
set Name of Terminal
|
||||
@param na Name of terminal
|
||||
*/
|
||||
void PartTerminal::setName(const QString &na) {
|
||||
name_ = na;
|
||||
}
|
||||
|
||||
/**
|
||||
Specifie la valeur d'une propriete donnee de la borne
|
||||
@param property propriete a modifier. Valeurs acceptees :
|
||||
@@ -160,6 +198,12 @@ void PartTerminal::setProperty(const QString &property, const QVariant &value) {
|
||||
} else if (property == "orientation") {
|
||||
if (!value.canConvert(QVariant::Int)) return;
|
||||
setOrientation(static_cast<QET::Orientation>(value.toInt()));
|
||||
} else if (property == "number") {
|
||||
if (!value.canConvert(QVariant::String)) return;
|
||||
setNumber(value.toString());
|
||||
} else if (property == "name") {
|
||||
if (!value.canConvert(QVariant::String)) return;
|
||||
setName(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +222,10 @@ QVariant PartTerminal::property(const QString &property) {
|
||||
return(scenePos().y());
|
||||
} else if (property == "orientation") {
|
||||
return(_orientation);
|
||||
} else if (property == "number") {
|
||||
return(number_);
|
||||
} else if (property == "name") {
|
||||
return(name_);
|
||||
}
|
||||
return(QVariant());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
||||
private:
|
||||
QET::Orientation _orientation;
|
||||
QPointF second_point;
|
||||
QString number_, name_;
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -54,6 +55,11 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
||||
virtual QRectF boundingRect() const;
|
||||
QET::Orientation orientation() const;
|
||||
void setOrientation(QET::Orientation);
|
||||
QString number() const;
|
||||
void setNumber(const QString &);
|
||||
QString nameOfTerminal() const;
|
||||
void setName(const QString &);
|
||||
|
||||
virtual void setProperty(const QString &, const QVariant &);
|
||||
virtual QVariant property(const QString &);
|
||||
virtual bool isUseless() const;
|
||||
|
||||
@@ -41,6 +41,9 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
||||
orientation -> addItem(QET::Icons::South, tr("Sud"), QET::South);
|
||||
orientation -> addItem(QET::Icons::West, tr("Ouest"), QET::West);
|
||||
|
||||
qle_number = new QLineEdit();
|
||||
qle_name = new QLineEdit();
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||
|
||||
@@ -55,6 +58,14 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
||||
ori -> addWidget(new QLabel(tr("Orientation : ")));
|
||||
ori -> addWidget(orientation );
|
||||
main_layout -> addLayout(ori);
|
||||
|
||||
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();
|
||||
setLayout(main_layout);
|
||||
|
||||
@@ -108,6 +119,8 @@ void TerminalEditor::updateTerminal() {
|
||||
).toInt()
|
||||
)
|
||||
);
|
||||
part -> setNumber( qle_number->text() );
|
||||
part -> setName ( qle_name->text() );
|
||||
}
|
||||
|
||||
/// Met a jour l'abscisse de la position de la borne et cree un objet d'annulation
|
||||
@@ -116,6 +129,9 @@ void TerminalEditor::updateTerminalX() { addChangePartCommand(tr("abscisse"),
|
||||
void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
||||
/// 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(); }
|
||||
|
||||
/**
|
||||
Met a jour le formulaire d'edition
|
||||
@@ -126,6 +142,8 @@ void TerminalEditor::updateForm() {
|
||||
qle_x -> setText(part -> property("x").toString());
|
||||
qle_y -> setText(part -> property("y").toString());
|
||||
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
||||
qle_number -> setText(part -> number() );
|
||||
qle_name -> setText(part -> nameOfTerminal() );
|
||||
activeConnections(true);
|
||||
}
|
||||
|
||||
@@ -138,9 +156,13 @@ void TerminalEditor::activeConnections(bool active) {
|
||||
connect(qle_x, SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
|
||||
connect(qle_y, SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
|
||||
connect(orientation, SIGNAL(activated(int)), this, SLOT(updateTerminalO()));
|
||||
connect(qle_number, SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
|
||||
connect(qle_name, SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
|
||||
} 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class TerminalEditor : public ElementItemEditor {
|
||||
PartTerminal *part;
|
||||
QLineEdit *qle_x, *qle_y;
|
||||
QComboBox *orientation;
|
||||
QLineEdit *qle_number, *qle_name;
|
||||
|
||||
// methods
|
||||
public:
|
||||
@@ -48,6 +49,8 @@ class TerminalEditor : public ElementItemEditor {
|
||||
void updateTerminalX();
|
||||
void updateTerminalY();
|
||||
void updateTerminalO();
|
||||
void updateTerminalNum();
|
||||
void updateTerminalName();
|
||||
void updateForm();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user