Rewrite terminaleditor with ui file.

Write terminal editor with ui file.
The terminalData::type of a terminal can be edited with the terminal
editor.
This commit is contained in:
joshua
2021-02-12 19:28:07 +01:00
parent 252106178b
commit a1779d1a7a
10 changed files with 504 additions and 424 deletions

View File

@@ -72,7 +72,7 @@ void PartTerminal::paint(
const QStyleOptionGraphicsItem *options,
QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(widget)
painter -> save();
// annulation des renderhints
@@ -161,6 +161,20 @@ void PartTerminal::setName(QString& name) {
emit nameChanged();
}
/**
* @brief PartTerminal::setTerminalType
* Set the type of terminal to 'type'
* @param type
*/
void PartTerminal::setTerminalType(TerminalData::Type type)
{
if (d->m_type == type) {
return;
}
d->m_type = type;
emit terminalTypeChanged();
}
void PartTerminal::setNewUuid()
{
d -> m_uuid = QUuid::createUuid();

View File

@@ -27,10 +27,13 @@
This class represents a terminal which may be used to compose the drawing of
an electrical element within the element editor.
*/
class PartTerminal : public CustomElementGraphicPart {
class PartTerminal : public CustomElementGraphicPart
{
Q_OBJECT
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(TerminalData::Type terminal_type READ terminalType WRITE setTerminalType)
public:
// constructors, destructor
@@ -42,6 +45,7 @@ class PartTerminal : public CustomElementGraphicPart {
signals:
void orientationChanged();
void nameChanged();
void terminalTypeChanged();
// methods
public:
@@ -51,7 +55,6 @@ class PartTerminal : public CustomElementGraphicPart {
@return the QGraphicsItem type
*/
int type() const override { return Type; }
QString name() const override { return d -> m_name; }
QString xmlName() const override { return(QString("terminal")); }
void fromXml(const QDomElement &) override;
const QDomElement toXml(QDomDocument &) const override;
@@ -71,7 +74,12 @@ class PartTerminal : public CustomElementGraphicPart {
Qet::Orientation orientation() const {return d -> m_orientation;}
void setOrientation(Qet::Orientation ori);
QString name() const override { return d -> m_name; }
void setName(QString& name);
TerminalData::Type terminalType() const {return d->m_type;}
void setTerminalType(TerminalData::Type type);
void setNewUuid();
private:

View File

@@ -1,322 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "terminaleditor.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../editor/graphicspart/partterminal.h"
#include "../qeticons.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
/**
@brief TerminalEditor::TerminalEditor
@param editor
@param parent
*/
TerminalEditor::TerminalEditor(QETElementEditor* editor, QWidget* parent):
ElementItemEditor(editor, parent) {
m_part = nullptr;
m_terminals.clear();
init();
}
/**
@brief TerminalEditor::TerminalEditor
Constructeur
@param editor :
L'editeur d'element concerne
@param terms :
La borne a editer
@param parent :
QWidget parent de ce widget
*/
TerminalEditor::TerminalEditor(
QETElementEditor *editor,
QList<PartTerminal *> &terms,
QWidget *parent) :
ElementItemEditor(editor, parent),
m_terminals(terms),
m_part(terms.first()) {
init();
}
/**
@brief TerminalEditor::init
*/
void TerminalEditor::init()
{
qle_x = new QDoubleSpinBox();
qle_y = new QDoubleSpinBox();
name = new QLineEdit();
qle_x -> setRange(-5000, 5000);
qle_y -> setRange(-5000, 5000);
orientation = new QComboBox();
orientation -> addItem(QET::Icons::North, tr("Nord"), Qet::North);
orientation -> addItem(QET::Icons::East, tr("Est"), Qet::East);
orientation -> addItem(QET::Icons::South, tr("Sud"), Qet::South);
orientation -> addItem(QET::Icons::West, tr("Ouest"), Qet::West);
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
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);
QHBoxLayout *lay_name = new QHBoxLayout();
lay_name -> addWidget(new QLabel(tr("Name : ")));
lay_name -> addWidget(name);
main_layout -> addLayout(lay_name);
main_layout -> addStretch();
setLayout(main_layout);
activeConnections(true);
updateForm();
}
/**
@brief TerminalEditor::~TerminalEditor
Destructeur
*/
TerminalEditor::~TerminalEditor()
{
}
/**
Permet de specifier a cet editeur quelle primitive il doit editer. A noter
qu'un editeur peut accepter ou refuser d'editer une primitive.
L'editeur de borne acceptera d'editer la primitive new_part s'il s'agit d'un
objet de la classe PartTerminal.
@param new_part Nouvelle primitive a editer
@return true si l'editeur a accepter d'editer la primitive, false sinon
*/
bool TerminalEditor::setPart(CustomElementPart* new_part) {
m_terminals.clear();
if (!new_part) {
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(new_part)) {
if(m_part == part_terminal) return true;
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = part_terminal;
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
}
bool TerminalEditor::setParts(QList<CustomElementPart *> parts) {
if (parts.isEmpty()) {
m_terminals.clear();
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first())) {
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = part_terminal;
m_terminals.clear();
m_terminals.append(part_terminal);
for (int i=1; i < parts.length(); i++) {
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
}
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
}
/**
@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
*/
CustomElementPart *TerminalEditor::currentPart() const
{
return(m_part);
}
QList<CustomElementPart*> TerminalEditor::currentParts() const
{
QList<CustomElementPart*> parts;
for (auto term: m_terminals) {
parts.append(static_cast<CustomElementPart*>(term));
}
return parts;
}
/// Met a jour l'orientation de la borne et cree un objet d'annulation
void TerminalEditor::updateTerminalO()
{
if (m_locked) return;
m_locked = true;
QVariant var(orientation -> itemData(orientation -> currentIndex()));
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
if (var != term->property("orientation"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
undo->setText(tr("Modifier l'orientation d'une borne"));
undoStack().push(undo);
}
}
m_locked = false;
}
/**
@brief TerminalEditor::updateXPos
*/
void TerminalEditor::updateXPos()
{
if (m_locked) return;
m_locked = true;
QPointF new_pos(qle_x->value(), 0);
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setY(term->pos().y()); // change only x value
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
}
/**
@brief TerminalEditor::updateYPos
*/
void TerminalEditor::updateYPos()
{
if (m_locked) return;
m_locked = true;
QPointF new_pos(0, qle_y->value()); // change only y value
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setX(term->pos().x());
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
}
/**
@brief TerminalEditor::updateName
SLOT set name to Terminal
*/
void TerminalEditor::updateName() {
if (m_locked) return;
m_locked = true;
QVariant var(name->text());
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
if (var != term->property("name"))
{
QPropertyUndoCommand *undo;
undo = new QPropertyUndoCommand(term,
"name",
term->property("name"),
var);
undo->setText(tr("Modifier le nom du terminal"));
undoStack().push(undo);
}
}
m_locked=false;
}
/// update Number and name, create cancel object
/**
Met a jour le formulaire d'edition
*/
void TerminalEditor::updateForm()
{
if (!m_part) return;
activeConnections(false);
qle_x -> setValue(m_part->property("x").toReal());
qle_y -> setValue(m_part->property("y").toReal());
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
name -> setText(m_part->name());
activeConnections(true);
}
/**
Active ou desactive les connexionx signaux/slots entre les widgets internes.
@param active true pour activer les connexions, false pour les desactiver
*/
void TerminalEditor::activeConnections(bool active) {
if (active) {
connect(qle_x,
&QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateXPos);
connect(qle_y,
&QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateYPos);
connect(orientation,
QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::updateTerminalO);
connect(name, &QLineEdit::editingFinished,
this, &TerminalEditor::updateName);
}
else {
disconnect(qle_x, &QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateXPos);
disconnect(qle_y, &QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateYPos);
disconnect(orientation, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::updateTerminalO);
disconnect(name, &QLineEdit::editingFinished,
this, &TerminalEditor::updateName);
}
}

View File

@@ -1,76 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef TERMINAL_EDITOR_H
#define TERMINAL_EDITOR_H
#include "elementitemeditor.h"
#include <QLineEdit>
class PartTerminal;
class QDoubleSpinBox;
class QComboBox;
/**
@brief The TerminalEditor class
This class provides a widget to edit terminals within the element editor.
The class is capable to change the values of multiple parts of the same time.
The displayed values are from the first selected element
*/
class TerminalEditor : public ElementItemEditor {
Q_OBJECT
// Constructors, destructor
public:
TerminalEditor(
QETElementEditor *,
QList<PartTerminal *>& terms,
QWidget * = nullptr);
TerminalEditor(QETElementEditor *, QWidget * = nullptr);
~TerminalEditor() override;
private:
TerminalEditor(const TerminalEditor &);
void init();
// attributes
private:
QList<PartTerminal *> m_terminals;
PartTerminal *m_part{nullptr};
QDoubleSpinBox *qle_x, *qle_y;
QComboBox *orientation;
QLineEdit *name;
bool m_locked{false};
// methods
public:
bool setPart(CustomElementPart *) override;
bool setParts(QList<CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
public slots:
void updateTerminalO();
void updateXPos();
void updateYPos();
void updateName();
void updateForm() override;
private:
void activeConnections(bool);
};
#endif

View File

@@ -41,7 +41,7 @@
#include "lineeditor.h"
#include "polygoneditor.h"
#include "rectangleeditor.h"
#include "../terminaleditor.h"
#include "terminaleditor.h"
#include "texteditor.h"
#include "dynamictextfieldeditor.h"
#include "../../newelementwizard.h"
@@ -553,14 +553,15 @@ void QETElementEditor::updateInformations()
style_editable = StyleEditor::isStyleEditable(cep_list);
}
if (same_xml_name) {
if (selection_xml_name == "terminal" ||
selection_xml_name == "text" ||
selection_xml_name == "dynamic_text" ||
selection_xml_name == "line" ||
selection_xml_name == "rect" ||
selection_xml_name == "ellipse" ||
selection_xml_name == "arc") {
if (same_xml_name)
{
if ( selection_xml_name == "text"
|| selection_xml_name == "dynamic_text"
|| selection_xml_name == "line"
|| selection_xml_name == "rect"
|| selection_xml_name == "ellipse"
|| selection_xml_name == "arc")
{
clearToolsDock();
//We add the editor widget
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
@@ -605,7 +606,9 @@ void QETElementEditor::updateInformations()
}
return;
}
else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
else if (cep_list.length() == 1 &&
(selection_xml_name == "polygon" || selection_xml_name == "terminal"))
{
#if TODO_LIST
#pragma message("@TODO maybe allowing multipart edit when number of points is the same?")
#endif

View File

@@ -0,0 +1,254 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "terminaleditor.h"
#include "ui_terminaleditor.h"
#include "../../qeticons.h"
#include "../../qet.h"
#include "../graphicspart/partterminal.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
/**
* @brief TerminalEditor::TerminalEditor
* Default constructor
* @param editor : element editor of which this terminal editor belong
* @param parent : parent widget
*/
TerminalEditor::TerminalEditor(QETElementEditor *editor, QWidget *parent) :
ElementItemEditor(editor, parent),
ui(new Ui::TerminalEditor)
{
ui->setupUi(this);
init();
}
/**
* @brief TerminalEditor::~TerminalEditor
* Destructor
*/
TerminalEditor::~TerminalEditor()
{
delete ui;
}
/**
* @brief TerminalEditor::updateForm
* Reimplemented from ElementItemEditor
* Update the content of this widget
*/
void TerminalEditor::updateForm()
{
if (!m_part) {
return;
}
activeConnections(false);
ui->m_x_dsb->setValue(m_part->property("x").toReal());
ui->m_y_dsb->setValue(m_part->property("y").toReal());
ui->m_orientation_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->property("orientation")));
ui->m_name_le->setText(m_part->name());
ui->m_type_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->terminalType()));
activeConnections(true);
}
/**
* @brief TerminalEditor::setPart
* Set the part to edit.
* The part must be a PartTerminal, in other case return false.
* @param new_part : the part to edit
* @return true if the part can be edited.
*/
bool TerminalEditor::setPart(CustomElementPart *new_part)
{
if (m_part == new_part) {
return true;
}
activeChangeConnections(false);
if (!new_part)
{
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = dynamic_cast<PartTerminal *>(new_part))
{
m_part = part_terminal;
updateForm();
activeChangeConnections(true);
return(true);
}
return(false);
}
/**
* @brief TerminalEditor::currentPart
* @return the current edited part
* or nullptr if there is no part or several part
* @see QList<CustomElementPart *> TerminalEditor::currentParts() const
*/
CustomElementPart *TerminalEditor::currentPart() const
{
return m_part;
}
/**
* @brief TerminalEditor::init
* Some init about this class
*/
void TerminalEditor::init()
{
ui->m_orientation_cb->addItem(QET::Icons::North, tr("Nord"), Qet::North);
ui->m_orientation_cb->addItem(QET::Icons::East, tr("Est"), Qet::East);
ui->m_orientation_cb->addItem(QET::Icons::South, tr("Sud"), Qet::South);
ui->m_orientation_cb->addItem(QET::Icons::West, tr("Ouest"), Qet::West);
ui->m_type_cb->addItem(tr("Générique"), TerminalData::Generic);
ui->m_type_cb->addItem(tr("Bornier intérieur"), TerminalData::Inner);
ui->m_type_cb->addItem(tr("Bornier extérieur"), TerminalData::Outer);
}
/**
* @brief TerminalEditor::posEdited
*/
void TerminalEditor::posEdited()
{
if (m_locked) {
return;
}
m_locked = true;
QPointF new_pos(ui->m_x_dsb->value(),
ui->m_y_dsb->value());
if (m_part->pos() != new_pos)
{
auto undo = new QPropertyUndoCommand(m_part, "pos", m_part->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
m_locked = false;
}
/**
* @brief TerminalEditor::orientationEdited
*/
void TerminalEditor::orientationEdited()
{
if (m_locked) {
return;
}
m_locked = true;
auto ori_ = ui->m_orientation_cb->currentData();
if (m_part->orientation() != ori_)
{
auto undo = new QPropertyUndoCommand(m_part, "orientation", m_part->property("orientation"), ori_);
undo->setText(tr("Modifier l'orientation d'une borne"));
undoStack().push(undo);
}
m_locked = false;
}
/**
* @brief TerminalEditor::nameEdited
*/
void TerminalEditor::nameEdited()
{
if (m_locked) {
return;
}
m_locked = true;
QString name_(ui->m_name_le->text());
if (m_part->name() != name_)
{
auto undo = new QPropertyUndoCommand(m_part, "name", m_part->property("name"), name_);
undo->setText(tr("Modifier le nom du terminal"));
undoStack().push(undo);
}
m_locked=false;
}
/**
* @brief TerminalEditor::typeEdited
*/
void TerminalEditor::typeEdited()
{
if (m_locked) {
return;
}
m_locked = true;
auto type = ui->m_type_cb->currentData();
if (type != m_part->terminalType()) {
auto undo = new QPropertyUndoCommand(m_part, "terminal_type", m_part->terminalType(), type);
undo->setText(tr("Modifier le type d'une borne"));
undoStack().push(undo);
}
m_locked = false;
}
/**
* @brief TerminalEditor::activeConnections
* Active connection between the widgets used in this editor
* and method of this class.
* @param active
*/
void TerminalEditor::activeConnections(bool active)
{
if (active) {
m_editor_connections << connect(ui->m_x_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, &TerminalEditor::posEdited);
m_editor_connections << connect(ui->m_y_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, &TerminalEditor::posEdited);
m_editor_connections << connect(ui->m_orientation_cb, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::orientationEdited);
m_editor_connections << connect(ui->m_name_le, &QLineEdit::editingFinished,
this, &TerminalEditor::nameEdited);
m_editor_connections << connect(ui->m_type_cb, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::typeEdited);
} else {
for (auto const & con : qAsConst(m_editor_connections)) {
QObject::disconnect(con);
}
m_editor_connections.clear();
}
}
void TerminalEditor::activeChangeConnections(bool active)
{
if (active)
{
m_change_connections << connect(m_part, &PartTerminal::xChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::yChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::nameChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::terminalTypeChanged, this, &TerminalEditor::updateForm);
} else {
for (auto &con : m_change_connections) {
QObject::disconnect(con);
}
m_change_connections.clear();
}
}

View File

@@ -0,0 +1,64 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef TERMINALEDITOR_H
#define TERMINALEDITOR_H
#include <QWidget>
#include "../elementitemeditor.h"
namespace Ui {
class TerminalEditor;
}
class PartTerminal;
/**
* @brief The TerminalEditor class
* Provide a widget used to edit the properties of a PartTerminal
*/
class TerminalEditor : public ElementItemEditor
{
Q_OBJECT
public:
TerminalEditor(QETElementEditor *editor, QWidget *parent = nullptr);
~TerminalEditor() override;
void updateForm() override;
bool setPart(CustomElementPart *new_part) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart *> currentParts() const override {return QList<CustomElementPart *>();}
private:
void init();
void posEdited();
void orientationEdited();
void nameEdited();
void typeEdited();
void activeConnections(bool active);
void activeChangeConnections(bool active);
private:
Ui::TerminalEditor *ui;
QVector<QMetaObject::Connection> m_editor_connections,
m_change_connections;
PartTerminal *m_part = nullptr;
bool m_locked = false;
};
#endif // TERMINALEDITOR_H

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TerminalEditor</class>
<widget class="QWidget" name="TerminalEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>511</width>
<height>236</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>y :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="m_x_dsb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="m_y_dsb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Orientation :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="m_name_le"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="m_orientation_cb"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>x :</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Nom :</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Type :</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="m_type_cb"/>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -1,3 +1,20 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "terminaldata.h"
#include <QGraphicsObject>
@@ -150,10 +167,10 @@ QString TerminalData::typeToString(TerminalData::Type type)
switch (type) {
case Generic:
return QString("Generic");
case TerminalInner :
return QString("TerminalInner");
case TerminalOuter :
return QString("TerminalOuter");
case Inner :
return QString("Inner");
case Outer :
return QString("Outer");
}
}
@@ -167,10 +184,10 @@ TerminalData::Type TerminalData::typeFromString(const QString &string)
{
if (string == "Generic") {
return TerminalData::Generic;
} else if (string == "TerminalInner") {
return TerminalData::TerminalInner;
} else if (string == "TerminalOuter") {
return TerminalData::TerminalOuter;
} else if (string == "Inner") {
return TerminalData::Inner;
} else if (string == "Outer") {
return TerminalData::Outer;
} else {
qDebug() << "TerminalData::typeFromString, argument string is invalid"
" failsafe type 'TerminalData::Generic' is returned";

View File

@@ -1,3 +1,20 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef TERMINALDATA_H
#define TERMINALDATA_H
@@ -18,13 +35,16 @@ class QGraphicsObject;
*/
class TerminalData : public PropertiesInterface
{
enum Type {
Generic,
TerminalInner,
TerminalOuter
};
Q_GADGET
public:
enum Type {
Generic,
Inner,
Outer
};
Q_ENUM(Type)
TerminalData();
TerminalData(QGraphicsObject* parent);
~TerminalData() override;