2007-12-01 10:47:15 +00:00
|
|
|
/*
|
|
|
|
Copyright 2006-2007 Xavier Guerrin
|
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
#include "terminaleditor.h"
|
|
|
|
#include "partterminal.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param term Borne a editer
|
|
|
|
@param parent QWidget parent de ce widget
|
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWidget *parent) : ElementItemEditor(editor, parent) {
|
2007-06-30 17:41:07 +00:00
|
|
|
part = term;
|
|
|
|
|
|
|
|
qle_x = new QLineEdit();
|
|
|
|
qle_y = new QLineEdit();
|
|
|
|
|
|
|
|
orientation = new QComboBox();
|
|
|
|
orientation -> addItem(QIcon(":/ico/north.png"), tr("Nord"), QET::North);
|
|
|
|
orientation -> addItem(QIcon(":/ico/east.png"), tr("Est"), QET::East);
|
|
|
|
orientation -> addItem(QIcon(":/ico/south.png"), tr("Sud"), QET::South);
|
|
|
|
orientation -> addItem(QIcon(":/ico/west.png"), tr("Ouest"), QET::West);
|
|
|
|
|
|
|
|
QVBoxLayout *main_layout = new QVBoxLayout();
|
2007-09-05 22:11:45 +00:00
|
|
|
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
2007-06-30 17:41:07 +00:00
|
|
|
|
|
|
|
QHBoxLayout *position = new QHBoxLayout();
|
|
|
|
position -> addWidget(new QLabel(tr("x : ")));
|
|
|
|
position -> addWidget(qle_x );
|
|
|
|
position -> addWidget(new QLabel(tr("y : ")));
|
|
|
|
position -> addWidget(qle_y );
|
|
|
|
main_layout -> addLayout(position);
|
|
|
|
|
|
|
|
QHBoxLayout *ori = new QHBoxLayout();
|
|
|
|
ori -> addWidget(new QLabel(tr("Orientation : ")));
|
|
|
|
ori -> addWidget(orientation );
|
|
|
|
main_layout -> addLayout(ori);
|
|
|
|
main_layout -> addStretch();
|
|
|
|
setLayout(main_layout);
|
|
|
|
|
2007-08-25 03:43:05 +00:00
|
|
|
activeConnections(true);
|
2007-06-30 17:41:07 +00:00
|
|
|
updateForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructeur
|
|
|
|
*/
|
|
|
|
TerminalEditor::~TerminalEditor() {
|
|
|
|
};
|
|
|
|
|
|
|
|
void TerminalEditor::updateTerminal() {
|
|
|
|
part -> setPos(qle_x -> text().toDouble(), qle_y -> text().toDouble());
|
|
|
|
part -> setOrientation(
|
|
|
|
static_cast<QET::Orientation>(
|
|
|
|
orientation -> itemData(
|
|
|
|
orientation -> currentIndex()
|
|
|
|
).toInt()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-08-25 03:43:05 +00:00
|
|
|
void TerminalEditor::updateTerminalX() { addChangePartCommand(tr("abscisse"), part, "x", qle_x -> text().toDouble()); updateForm(); }
|
|
|
|
void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
|
|
|
void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex()).toInt()); }
|
|
|
|
|
2007-06-30 17:41:07 +00:00
|
|
|
void TerminalEditor::updateForm() {
|
2007-08-25 03:43:05 +00:00
|
|
|
activeConnections(false);
|
|
|
|
qle_x -> setText(part -> property("x").toString());
|
|
|
|
qle_y -> setText(part -> property("y").toString());
|
2007-06-30 17:41:07 +00:00
|
|
|
orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
|
2007-08-25 03:43:05 +00:00
|
|
|
activeConnections(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalEditor::activeConnections(bool active) {
|
|
|
|
if (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()));
|
|
|
|
} 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()));
|
|
|
|
}
|
2007-06-30 17:41:07 +00:00
|
|
|
}
|