This commit is contained in:
Martin
2021-02-23 17:35:55 +01:00
7393 changed files with 173795 additions and 176624 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,8 +16,9 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pastepartscommand.h"
#include "elementview.h"
#include "partterminal.h"
#include "../elementview.h"
#include "../graphicspart/partterminal.h"
/**
@brief PastePartsCommand::PastePartsCommand

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,8 +18,8 @@
#ifndef PASTEPARTSCOMMAND_H
#define PASTEPARTSCOMMAND_H
#include "editorcommands.h"
#include "elementcontent.h"
#include "../editorcommands.h"
#include "../elementcontent.h"
class ElementView;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,10 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "arceditor.h"
#include "styleeditor.h"
#include "partarc.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
#include "graphicspart/partarc.h"
#include "styleeditor.h"
/**
Constructeur
@@ -29,10 +30,10 @@
*/
ArcEditor::ArcEditor(QETElementEditor *editor, PartArc *arc, QWidget *parent) :
ElementItemEditor(editor, parent),
part(arc),
m_part(arc),
m_locked(false)
{
style_ = new StyleEditor(editor);
m_style = new StyleEditor(editor);
x = new QDoubleSpinBox();
y = new QDoubleSpinBox();
h = new QDoubleSpinBox();
@@ -65,7 +66,7 @@ ArcEditor::ArcEditor(QETElementEditor *editor, PartArc *arc, QWidget *parent) :
grid -> addWidget(new QLabel(tr("Angle :")), 6, 0);
grid -> addWidget(angle, 6, 1);
v_layout -> addWidget(style_);
v_layout -> addWidget(m_style);
v_layout -> addLayout(grid);
v_layout->addStretch();
@@ -80,9 +81,9 @@ ArcEditor::~ArcEditor()
void ArcEditor::setUpChangeConnections()
{
m_change_connections << connect(part, &PartArc::rectChanged, this, &ArcEditor::updateForm);
m_change_connections << connect(part, &PartArc::spanAngleChanged, this, &ArcEditor::updateForm);
m_change_connections << connect(part, &PartArc::startAngleChanged, this, &ArcEditor::updateForm);
m_change_connections << connect(m_part, &PartArc::rectChanged, this, &ArcEditor::updateForm);
m_change_connections << connect(m_part, &PartArc::spanAngleChanged, this, &ArcEditor::updateForm);
m_change_connections << connect(m_part, &PartArc::startAngleChanged, this, &ArcEditor::updateForm);
#if TODO_LIST
#pragma message("@TODO implement position changes!")
#endif
@@ -109,19 +110,19 @@ bool ArcEditor::setPart(CustomElementPart *new_part)
{
if (!new_part)
{
if (part)
if (m_part)
disconnectChangeConnections();
part = nullptr;
m_part = nullptr;
return(true);
}
if (PartArc *part_arc = dynamic_cast<PartArc *>(new_part))
{
if (part == part_arc) return true;
if (part)
if (m_part == part_arc) return true;
if (m_part)
disconnectChangeConnections();
part = part_arc;
m_part = part_arc;
updateForm();
setUpChangeConnections();
return(true);
@@ -137,7 +138,7 @@ bool ArcEditor::setParts(QList <CustomElementPart *> parts)
if (!setPart(parts.first()))
return false;
return style_->setParts(parts);
return m_style->setParts(parts);
}
/**
@@ -146,12 +147,12 @@ bool ArcEditor::setParts(QList <CustomElementPart *> parts)
*/
CustomElementPart *ArcEditor::currentPart() const
{
return(part);
return(m_part);
}
QList<CustomElementPart*> ArcEditor::currentParts() const
{
return style_->currentParts();
return m_style->currentParts();
}
/**
@@ -164,7 +165,7 @@ void ArcEditor::updateArcS()
m_locked = true;
double value = start_angle->value() * 16;
for (auto part: style_->currentParts()) {
for (auto part: m_style->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
@@ -190,7 +191,7 @@ void ArcEditor::updateArcA()
m_locked = true;
double value = angle->value() * 16;
for (auto part: style_->currentParts()) {
for (auto part: m_style->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
if (value != arc->property("spanAngle"))
@@ -205,124 +206,47 @@ void ArcEditor::updateArcA()
m_locked = false;
}
/**
@brief ArcEditor::updateArcRect
Update the geometrie of the rect that define this arc according the the edited values
*/
void ArcEditor::updateArcRectX()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2); // does not matter which value y is, because only the x value is used
rect.setX(point.x()); // change only the x value
if (rect != part->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void ArcEditor::updateArcRectY()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
QPointF point = arc->mapFromScene(x->value() - h->value()/2, y->value() - v->value()/2);
rect.setY(point.y());
if (rect != arc->property("rect"))
{
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void ArcEditor::updateArcRectH()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
if (rect.width() != h->value())
{
rect.setWidth(h->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
void ArcEditor::updateArcRectV()
{
if (m_locked) return;
m_locked = true;
for (auto part: style_->currentParts()) {
PartArc* arc = static_cast<PartArc*>(part);
QRectF rect = arc->property("rect").toRectF();
if (rect.height() != v->value())
{
rect.setHeight(v->value());
QPropertyUndoCommand *undo= new QPropertyUndoCommand(arc, "rect", arc->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
m_locked = false;
}
/**
@brief ArcEditor::updateForm
Update the value of the widgets
*/
void ArcEditor::updateForm()
{
if (!part) return;
if (!m_part) return;
activeConnections(false);
QRectF rect = part->property("rect").toRectF();
x->setValue(part->mapToScene(rect.topLeft()).x() + (rect.width()/2));
y->setValue(part->mapToScene(rect.topLeft()).y() + (rect.height()/2));
QRectF rect = m_part->property("rect").toRectF();
x->setValue(m_part->mapToScene(rect.topLeft()).x() + (rect.width()/2));
y->setValue(m_part->mapToScene(rect.topLeft()).y() + (rect.height()/2));
h->setValue(rect.width());
v->setValue(rect.height());
start_angle->setValue(part->property("startAngle").toInt()/16);
angle->setValue(part->property("spanAngle").toInt()/16);
start_angle->setValue(m_part->property("startAngle").toInt()/16);
angle->setValue(m_part->property("spanAngle").toInt()/16);
activeConnections(true);
}
void ArcEditor::updateRect()
{
QRectF rect;
auto pos_ = m_part->mapFromScene(QPointF(x->value(), y->value()));
rect.setX(pos_.x() - h->value()/2);
rect.setY(pos_.y() - v->value()/2);
rect.setWidth(h->value());
rect.setHeight(v->value());
for (auto part: m_style->currentParts())
{
auto ellipse = static_cast<PartArc*>(part);
if (rect != part->property("rect"))
{
auto undo= new QPropertyUndoCommand(ellipse, "rect", ellipse->property("rect"), rect);
undo->setText("Modifier un arc");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
}
}
/**
@brief ArcEditor::activeConnections
Enable/disable connection between editor widget and slot editingFinished
@@ -333,20 +257,20 @@ void ArcEditor::activeConnections(bool active)
{
if (active)
{
connect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
connect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
connect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
connect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
connect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
connect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
connect(x, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
connect(y, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
connect(h, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
connect(v, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
connect(start_angle, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateArcS);
connect(angle, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateArcA);
}
else
{
disconnect(x, SIGNAL(editingFinished()), this, SLOT(updateArcRectX()));
disconnect(y, SIGNAL(editingFinished()), this, SLOT(updateArcRectY()));
disconnect(h, SIGNAL(editingFinished()), this, SLOT(updateArcRectH()));
disconnect(v, SIGNAL(editingFinished()), this, SLOT(updateArcRectV()));
disconnect(start_angle, SIGNAL(editingFinished()), this, SLOT(updateArcS()));
disconnect(angle, SIGNAL(editingFinished()), this, SLOT(updateArcA()));
disconnect(x, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
disconnect(y, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
disconnect(h, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
disconnect(v, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateRect);
disconnect(start_angle, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateArcS);
disconnect(angle, &QDoubleSpinBox::editingFinished, this, &ArcEditor::updateArcA);
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -41,8 +41,8 @@ class ArcEditor : public ElementItemEditor
// attributes
private:
PartArc *part;
StyleEditor *style_;
PartArc *m_part;
StyleEditor *m_style;
QDoubleSpinBox *x, *y, *h, *v;
QSpinBox *angle, *start_angle;
bool m_locked;
@@ -59,11 +59,8 @@ class ArcEditor : public ElementItemEditor
public slots:
void updateArcS();
void updateArcA();
void updateArcRectX();
void updateArcRectY();
void updateArcRectH();
void updateArcRectV();
void updateForm() override;
void updateRect();
private:
void activeConnections(bool);

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -282,13 +282,17 @@ ChangeNamesCommand::~ChangeNamesCommand()
/// Annule le changement
void ChangeNamesCommand::undo()
{
m_scene -> setNames(names_before);
auto data = m_scene->elementData();
data.m_names_list = names_before;
m_scene->setElementData(data);
}
/// Refait le changement
void ChangeNamesCommand::redo()
{
m_scene -> setNames(names_after);
auto data = m_scene->elementData();
data.m_names_list = names_after;
m_scene->setElementData(data);
}
/**
@@ -453,13 +457,17 @@ ChangeInformationsCommand::~ChangeInformationsCommand()
/// Annule le changement d'autorisation pour les connexions internes
void ChangeInformationsCommand::undo()
{
m_scene -> setInformations(old_informations_);
auto data = m_scene->elementData();
data.m_drawing_information = old_informations_;
m_scene->setElementData(data);
}
/// Refait le changement d'autorisation pour les connexions internes
void ChangeInformationsCommand::redo()
{
m_scene -> setInformations(new_informations_);
auto data = m_scene->elementData();
data.m_drawing_information = new_informations_;
m_scene->setElementData(data);
}
/**
@@ -572,45 +580,32 @@ void ScalePartsCommand::adjustText()
setText(QObject::tr("redimensionnement de %1 primitives", "undo caption -- %1 always > 1").arg(scaled_primitives_.count()));
}
}
/**
@brief ChangePropertiesCommand::ChangePropertiesCommand
Change the properties of the drawed element
@param scene : scene to belong the property
@param type : new type of element.
@param info
@param elmt_info : new info about type.
@param parent : parent undo
*/
ChangePropertiesCommand::ChangePropertiesCommand(
ElementScene *scene,
const QString& type,
const DiagramContext& info,
const DiagramContext& elmt_info,
QUndoCommand *parent) :
ElementEditionCommand(scene, nullptr, parent)
* @brief changeElementDataCommand::changeElementDataCommand
* Change the properties of the drawed element
* @param scene : scene to belong the property
* @param old_data : old data
* @param new_data : new data
* @param parent : parent undo command
*/
changeElementDataCommand::changeElementDataCommand(ElementScene *scene,
ElementData old_data,
ElementData new_data,
QUndoCommand *parent) :
ElementEditionCommand(scene, nullptr, parent),
m_old(old_data),
m_new(new_data)
{
m_type << scene->m_elmt_type << type;
m_kind_info << scene->m_elmt_kindInfo << info;
m_elmt_info << scene->m_elmt_information << elmt_info;
setText(QObject::tr("Modifier les propriétés"));
setText(QObject::tr("Modifier les propriétées de l'élément"));
}
ChangePropertiesCommand::~ChangePropertiesCommand()
{}
void ChangePropertiesCommand::undo()
{
m_scene->m_elmt_type = m_type.first();
m_scene->m_elmt_kindInfo = m_kind_info.first();
m_scene->setElementInfo(m_elmt_info.first());
void changeElementDataCommand::undo() {
m_scene->setElementData(m_old);
QUndoCommand::undo();
}
void ChangePropertiesCommand::redo()
{
m_scene->m_elmt_type = m_type.last();
m_scene->m_elmt_kindInfo = m_kind_info.last();
m_scene->setElementInfo(m_elmt_info.last());
void changeElementDataCommand::redo() {
m_scene->setElementData(m_new);
QUndoCommand::redo();
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -17,11 +17,11 @@
*/
#ifndef EDITOR_COMMANDS_H
#define EDITOR_COMMANDS_H
#include "customelementpart.h"
#include "elementview.h"
#include "elementscene.h"
#include "../editor/graphicspart/customelementpart.h"
#include "../qgimanager.h"
#include "elementcontent.h"
#include "qgimanager.h"
#include "elementscene.h"
#include "elementview.h"
/**
@brief The ElementEditionCommand class
@@ -262,23 +262,21 @@ class ScalePartsCommand : public ElementEditionCommand {
bool first_redo;
};
class ChangePropertiesCommand : public ElementEditionCommand {
class changeElementDataCommand : public ElementEditionCommand
{
public:
ChangePropertiesCommand (
ElementScene *scene,
const QString& type,
const DiagramContext& info,
const DiagramContext& elmt_info,
QUndoCommand *parent=nullptr);
~ChangePropertiesCommand () override;
changeElementDataCommand(ElementScene *scene,
ElementData old_data,
ElementData new_data,
QUndoCommand *parent = nullptr);
~changeElementDataCommand() override {}
void undo() override;
void redo() override;
void undo() override;
void redo() override;
private:
QList <QString> m_type;
QList <DiagramContext> m_kind_info;
QList < DiagramContext> m_elmt_info;
ElementData m_old,
m_new;
};
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementitemeditor.h"
#include "qetelementeditor.h"
#include "ui/qetelementeditor.h"
#include "editorcommands.h"
/**

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,15 +16,17 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementprimitivedecorator.h"
#include "elementscene.h"
#include "customelementpart.h"
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../editor/graphicspart/customelementpart.h"
#include "../qet.h"
#include "editorcommands.h"
#include "qet.h"
#include <QPainter>
#include <QGraphicsSceneHoverEvent>
#include <QStyleOptionGraphicsItem>
#include "elementscene.h"
#include <QGraphicsScene>
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include <QGraphicsSceneHoverEvent>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
/**
Constructor

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,8 +18,9 @@
#ifndef ELEMENTPRIMITIVEDECORATOR_H
#define ELEMENTPRIMITIVEDECORATOR_H
#include "../qet.h"
#include <QGraphicsObject>
#include "qet.h"
class ElementEditionCommand;
class ElementScene;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,28 +16,29 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementscene.h"
#include "qetelementeditor.h"
#include "elementprimitivedecorator.h"
#include <cmath>
#include "partline.h"
#include "partrectangle.h"
#include "partellipse.h"
#include "partpolygon.h"
#include "partterminal.h"
#include "parttext.h"
#include "partarc.h"
#include "../NameList/ui/namelistdialog.h"
#include "../NameList/ui/namelistwidget.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "editorcommands.h"
#include "elementcontent.h"
#include "elementprimitivedecorator.h"
#include "esevent/eseventinterface.h"
#include "graphicspart/partarc.h"
#include "graphicspart/partdynamictextfield.h"
#include "graphicspart/partellipse.h"
#include "graphicspart/partline.h"
#include "graphicspart/partpolygon.h"
#include "graphicspart/partrectangle.h"
#include "graphicspart/partterminal.h"
#include "graphicspart/parttext.h"
#include "ui/qetelementeditor.h"
#include "ui/elementpropertieseditorwidget.h"
#include "eseventinterface.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "partdynamictextfield.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "namelistdialog.h"
#include "namelistwidget.h"
#include <algorithm>
#include <QKeyEvent>
#include <algorithm>
#include <cmath>
/**
@brief ElementScene::ElementScene
@@ -50,7 +51,6 @@
*/
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
QGraphicsScene(parent),
m_elmt_type("simple"),
m_qgi_manager(this),
m_element_editor(editor)
{
@@ -70,7 +70,25 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
connect(&m_undo_stack, SIGNAL(indexChanged(int)),
this, SLOT(managePrimitivesGroups()));
connect(this, SIGNAL(selectionChanged()),
this, SLOT(managePrimitivesGroups()));
this, SLOT(managePrimitivesGroups()));
}
/**
* @brief ElementScene::elementData
* @return the elementdata using by the scene
*/
ElementData ElementScene::elementData() {
return m_element_data;
}
void ElementScene::setElementData(ElementData data)
{
bool emit_ = m_element_data.m_informations != data.m_informations;
m_element_data = data;
if (emit_)
emit elementInfoChanged();
}
/**
@@ -436,7 +454,7 @@ const QDomDocument ElementScene::toXml(bool all_parts)
-(qRound(size.y() - (ymargin/2)))));
root.setAttribute("version", QET::version);
root.setAttribute("link_type", m_elmt_type);
root.setAttribute("link_type", m_element_data.typeToString(m_element_data.m_type));
//Uuid used to compare two elements
QDomElement uuid = xml_document.createElement("uuid");
@@ -444,29 +462,29 @@ const QDomDocument ElementScene::toXml(bool all_parts)
root.appendChild(uuid);
//names of element
root.appendChild(m_names_list.toXml(xml_document));
root.appendChild(m_element_data.m_names_list.toXml(xml_document));
if (m_elmt_type == "slave" || m_elmt_type == "master")
auto type_ = m_element_data.m_type;
if (type_ == ElementData::Slave ||
type_ == ElementData::Master ||
type_ == ElementData::Terminale)
{
QDomElement kindInfo = xml_document.createElement("kindInformations");
m_elmt_kindInfo.toXml(kindInfo, "kindInformation");
root.appendChild(kindInfo);
root.appendChild(m_element_data.kindInfoToXml(xml_document));
}
if(
m_elmt_type == "simple"
|| m_elmt_type == "master"
|| m_elmt_type == "terminal")
if(type_ == ElementData::Simple ||
type_ == ElementData::Master ||
type_ == ElementData::Terminale)
{
QDomElement element_info = xml_document.createElement("elementInformations");
m_elmt_information.toXml(element_info, "elementInformation");
m_element_data.m_informations.toXml(element_info, "elementInformation");
root.appendChild(element_info);
}
//complementary information about the element
QDomElement informations_element = xml_document.createElement("informations");
root.appendChild(informations_element);
informations_element.appendChild(xml_document.createTextNode(informations()));
informations_element.appendChild(xml_document.createTextNode(m_element_data.m_drawing_information));
QDomElement description = xml_document.createElement("description");
@@ -544,9 +562,16 @@ void ElementScene::fromXml(
{
bool state = true;
//Consider the informations of the element
if (consider_informations) {
state = applyInformations(xml_document);
//Consider the informations of the element
if (consider_informations)
{
// Root must be an element definition
QDomElement root = xml_document.documentElement();
if (root.tagName() == "definition" &&
root.attribute("type") == "element") {
m_element_data.fromXml(root);
}
}
if (state)
@@ -698,19 +723,6 @@ QETElementEditor* ElementScene::editor() const
return m_element_editor;
}
/**
@brief ElementScene::setElementInfo
@param dc
*/
void ElementScene::setElementInfo(const DiagramContext& dc)
{
if(m_elmt_information != dc)
{
m_elmt_information = dc;
emit elementInfoChanged();
}
}
/**
@brief ElementScene::slot_select
Select the item in content,
@@ -832,7 +844,7 @@ void ElementScene::slot_editAuthorInformations()
// ajoute un QTextEdit au dialogue
QTextEdit *text_field = new QTextEdit();
text_field -> setAcceptRichText(false);
text_field -> setPlainText(informations());
text_field -> setPlainText(m_element_data.m_drawing_information);
text_field -> setReadOnly(is_read_only);
dialog_layout -> addWidget(text_field);
@@ -850,10 +862,10 @@ void ElementScene::slot_editAuthorInformations()
if (dialog_author.exec() == QDialog::Accepted && !is_read_only)
{
QString new_infos = text_field -> toPlainText().remove(QChar(13)); // CR-less text
if (new_infos != informations())
if (new_infos != m_element_data.m_drawing_information)
{
undoStack().push(new ChangeInformationsCommand(
this, informations(), new_infos));
this, m_element_data.m_drawing_information, new_infos));
}
}
}
@@ -864,20 +876,15 @@ void ElementScene::slot_editAuthorInformations()
*/
void ElementScene::slot_editProperties()
{
QString type = m_elmt_type;
DiagramContext kind_info = m_elmt_kindInfo;
DiagramContext elmt_info = m_elmt_information;
ElementPropertiesEditorWidget epew(type, kind_info, elmt_info);
ElementPropertiesEditorWidget epew(m_element_data);
epew.exec();
if (type != m_elmt_type ||
kind_info != m_elmt_kindInfo ||
elmt_info != m_elmt_information)
undoStack().push(new ChangePropertiesCommand(this,
type,
kind_info,
elmt_info));
if (m_element_data != epew.editedData())
{
undoStack().push(new changeElementDataCommand(this,
m_element_data,
epew.editedData()));
}
}
/**
@@ -897,15 +904,15 @@ void ElementScene::slot_editNames()
dialog_.setInformationText(tr("Vous pouvez spécifier le nom de l'élément dans plusieurs langues."));
NameListWidget *nlw_ = dialog_.namelistWidget();
nlw_->setNames(m_names_list);
nlw_->setNames(m_element_data.m_names_list);
nlw_->setReadOnly(is_read_only);
if (dialog_.exec() == QDialog::Accepted && !is_read_only && !nlw_->isEmpty())
{
NamesList new_names = nlw_->names();
if (new_names != m_names_list) {
if (new_names != m_element_data. m_names_list) {
undoStack().push(new ChangeNamesCommand(this,
m_names_list,
m_element_data.m_names_list,
new_names));
}
}
@@ -1086,62 +1093,6 @@ QRectF ElementScene::elementContentBoundingRect(
return(bounding_rect);
}
/**
@brief ElementScene::applyInformations
Applies the information (dimensions, hostpot, orientations,
internal connections, names and additional information)
contained in an XML document.
\~French Applique les informations (dimensions, hostpot, orientations,
connexions internes, noms et informations complementaires)
contenu dans un document XML.
\~ @param xml_document : Document XML a analyser
\~ @return
true if reading and applying the information went well, false otherwise.
\~French true si la lecture et l'application
des informations s'est bien passee, false sinon.
*/
bool ElementScene::applyInformations(const QDomDocument &xml_document)
{
// Root must be an element definition
QDomElement root = xml_document.documentElement();
if (
root.tagName() != "definition"
||
root.attribute("type") != "element")
return(false);
//Extract info about element type
m_elmt_type = root.attribute("link_type", "simple");
m_elmt_kindInfo.fromXml(
root.firstChildElement("kindInformations"),
"kindInformation");
//Extract info of element
m_elmt_information.fromXml(
root.firstChildElement("elementInformations"),
"elementInformation");
//Extract names of xml definition
m_names_list.fromXml(root);
//extract additional informations
setInformations(QString());
for (QDomNode node = root.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
{
QDomElement elmt = node.toElement();
if (elmt.isNull()) continue;
if (elmt.tagName() == "informations")
{
setInformations(elmt.text());
break;
}
}
return(true);
}
/**
@brief ElementScene::loadContent
Create and load the content describe in the xml document.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -17,12 +17,14 @@
*/
#ifndef ELEMENT_SCENE_H
#define ELEMENT_SCENE_H
#include "../NameList/nameslist.h"
#include "../diagramcontext.h"
#include "../qgimanager.h"
#include "elementcontent.h"
#include "../properties/elementdata.h"
#include <QtWidgets>
#include <QtXml>
#include "qgimanager.h"
#include "elementcontent.h"
#include "diagramcontext.h"
#include "nameslist.h"
class CustomElementPart;
class ElementEditionCommand;
@@ -64,11 +66,7 @@ class ElementScene : public QGraphicsScene
// attributes
private:
NamesList m_names_list; /// List of localized names
QString m_informations; /// Extra informations
QString m_elmt_type; /// element type
DiagramContext m_elmt_kindInfo,
m_elmt_information; /// element kind info
ElementData m_element_data; ///ElementData. Actualy in transition with old data storage
QGIManager m_qgi_manager;
QUndoStack m_undo_stack;
@@ -89,21 +87,20 @@ class ElementScene : public QGraphicsScene
// methods
public:
ElementData elementData();
void setElementData(ElementData data);
void setEventInterface (ESEventInterface *event_interface);
void clearEventInterface();
void setBehavior (ElementScene::Behavior);
ElementScene::Behavior behavior() const;
QPointF snapToGrid(QPointF point);
void setNames(const NamesList &);
NamesList names() const;
QString informations() const;
void setInformations(const QString &);
QString elementType () const {return m_elmt_type;}
DiagramContext elementKindInfo () const {return m_elmt_kindInfo;}
DiagramContext elementInformation() const {return m_elmt_information;}
virtual int xGrid() const;
virtual int yGrid() const;
virtual void setGrid(int, int);
virtual const QDomDocument toXml(bool = true);
virtual QRectF boundingRectFromXml(const QDomDocument &);
virtual void fromXml(const QDomDocument &,
@@ -127,7 +124,6 @@ class ElementScene : public QGraphicsScene
void cut();
void copy();
QETElementEditor* editor() const;
void setElementInfo(const DiagramContext& dc);
protected:
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
@@ -136,12 +132,10 @@ class ElementScene : public QGraphicsScene
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override;
void keyPressEvent (QKeyEvent *event) override;
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
void drawForeground(QPainter *, const QRectF &) override;
private:
QRectF elementContentBoundingRect(const ElementContent &) const;
bool applyInformations(const QDomDocument &);
ElementContent loadContent(const QDomDocument &);
ElementContent addContent(const ElementContent &);
ElementContent addContentAtPos(const ElementContent &, const QPointF &);
@@ -179,39 +173,4 @@ class ElementScene : public QGraphicsScene
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
/**
@brief ElementScene::setNames
@param nameslist New set of naes for the currently edited element
*/
inline void ElementScene::setNames(const NamesList &nameslist) {
m_names_list = nameslist;
}
/**
@brief ElementScene::names
@return the list of names of the currently edited element
*/
inline NamesList ElementScene::names() const
{
return(m_names_list);
}
/**
@brief ElementScene::informations
@return extra informations of the currently edited element
*/
inline QString ElementScene::informations() const
{
return(m_informations);
}
/**
@brief ElementScene::setInformations
@param infos new extra information for the currently edited element
*/
inline void ElementScene::setInformations(const QString &infos) {
m_informations = infos;
}
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementview.h"
#include "qetelementeditor.h"
#include "qetapp.h"
#include "pastepartscommand.h"
#include "../qetapp.h"
#include "UndoCommand/pastepartscommand.h"
#include "ui/qetelementeditor.h"
/**
Constructeur
@param scene ElementScene visualisee par cette ElementView
@@ -372,8 +373,9 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
du milieu de la souris.
@param e QMouseEvent decrivant l'evenement souris
*/
void ElementView::mousePressEvent(QMouseEvent *e) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
void ElementView::mousePressEvent(QMouseEvent* e)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
@@ -393,14 +395,15 @@ void ElementView::mousePressEvent(QMouseEvent *e) {
@brief ElementView::mouseMoveEvent
Manage the event move mouse
*/
void ElementView::mouseMoveEvent(QMouseEvent *e) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
void ElementView::mouseMoveEvent(QMouseEvent* e)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
if (e->buttons() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
if (e->buttons() == Qt::MiddleButton)
#endif
{
QScrollBar *h = horizontalScrollBar();
@@ -418,8 +421,9 @@ void ElementView::mouseMoveEvent(QMouseEvent *e) {
@brief ElementView::mouseReleaseEvent
Manage event release click mouse
*/
void ElementView::mouseReleaseEvent(QMouseEvent *e) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
void ElementView::mouseReleaseEvent(QMouseEvent* e)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
if (e->button() == Qt::MidButton)
#else
#if TODO_LIST

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,13 +15,14 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "elementscene.h"
#include "partarc.h"
#include "editorcommands.h"
#include "eseventaddarc.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partarc.h"
#include <QObject>
/**
@brief ESEventAddArc::ESEventAddArc
@param scene

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -20,6 +20,8 @@
#include "eseventinterface.h"
#include <QPointF>
class ElementScene;
class PartArc;
class QGraphicsSceneMouseEvent;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "eseventadddynamictextfield.h"
#include "elementscene.h"
#include "editorcommands.h"
#include "partdynamictextfield.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partdynamictextfield.h"
#include <QUndoStack>

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,12 +15,13 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "eseventaddellipse.h"
#include "partellipse.h"
#include "editorcommands.h"
#include "elementscene.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partellipse.h"
#include <QObject>
/**
@brief ESEventAddEllipse::ESEventAddEllipse

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,15 +15,16 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "eseventaddline.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partline.h"
#include "../ui/qetelementeditor.h"
#include <QGraphicsSceneMouseEvent>
#include <QObject>
#include "eseventaddline.h"
#include "elementscene.h"
#include "qetelementeditor.h"
#include "partline.h"
#include "editorcommands.h"
/**
@brief ESEventAddLine::ESEventAddLine
Constructor

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,12 +15,13 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "eseventaddpolygon.h"
#include "elementscene.h"
#include "partpolygon.h"
#include "editorcommands.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partpolygon.h"
#include <QObject>
/**
@brief ESEventAddPolygon::ESEventAddPolygon

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,12 +15,13 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "eseventaddrect.h"
#include "elementscene.h"
#include "partrectangle.h"
#include "editorcommands.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partrectangle.h"
#include <QObject>
/**
@brief ESEventAddRect::ESEventAddRect

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,13 +15,14 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "partterminal.h"
#include "editorcommands.h"
#include "elementscene.h"
#include "eseventaddterminal.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partterminal.h"
#include <QObject>
/**
@brief ESEventAddTerminal::ESEventAddTerminal
@param scene

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -15,12 +15,13 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include "eseventaddtext.h"
#include "parttext.h"
#include "editorcommands.h"
#include "elementscene.h"
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/parttext.h"
#include <QObject>
/**
@brief ESEventAddText::ESEventAddText

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,8 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "eseventinterface.h"
#include "elementscene.h"
#include "qetelementeditor.h"
#include "../elementscene.h"
#include "../ui/qetelementeditor.h"
#include "../elementview.h"
#include <QGraphicsSceneMouseEvent>
ESEventInterface::ESEventInterface(ElementScene *scene) :
@@ -38,7 +41,7 @@ ESEventInterface::ESEventInterface(ElementScene *scene) :
void ESEventInterface::init()
{
m_scene->setBehavior(ElementScene::Behavior::AddPart);
m_editor->slot_setNoDragToView();
m_editor->elementView()->setDragMode(QGraphicsView::NoDrag);
}
/**
@@ -51,31 +54,31 @@ ESEventInterface::~ESEventInterface()
delete m_help_verti;
m_scene->setBehavior(ElementScene::Behavior::Normal);
m_editor->slot_setRubberBandToView();
m_editor->elementView()->setDragMode(QGraphicsView::RubberBandDrag);
}
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
Q_UNUSED (event)
return false;
}
bool ESEventInterface::mousePressEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
Q_UNUSED (event)
return false;
}
bool ESEventInterface::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
Q_UNUSED (event)
return false;
}
bool ESEventInterface::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event);
Q_UNUSED (event)
return false;
}
bool ESEventInterface::wheelEvent(QGraphicsSceneWheelEvent *event) {
Q_UNUSED (event);
Q_UNUSED (event)
return false;
}
@@ -95,7 +98,7 @@ bool ESEventInterface::keyPressEvent(QKeyEvent *event) {
}
bool ESEventInterface::KeyReleaseEvent(QKeyEvent *event) {
Q_UNUSED (event);
Q_UNUSED (event)
return false;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,8 +16,9 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "customelementgraphicpart.h"
#include "elementscene.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../elementscene.h"
#include <QRegularExpression>
@@ -1265,24 +1266,6 @@ void CustomElementGraphicPart::drawShadowShape(QPainter *painter)
painter -> restore ();
}
/**
@brief CustomElementGraphicPart::itemChange
Reimplemented from QGraphicsObject.
If the item position change call updateCurrentPartEditor()
the change is always send to QGraphicsObject
@param change
@param value
@return the returned value of QGraphicsObject::itemChange
*/
QVariant CustomElementGraphicPart::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (scene())
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemPositionHasChanged)
updateCurrentPartEditor();
return(QGraphicsObject::itemChange(change, value));
}
/**
@brief CustomElementGraphicPart::hoverEnterEvent
Reimplemented from QGraphicsObject.

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,7 +16,9 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "customelementpart.h"
#include "qetelementeditor.h"
#include "../ui/qetelementeditor.h"
#include "../elementscene.h"
/// @return le QETElementEditor auquel cet editeur appartient
QETElementEditor *CustomElementPart::elementEditor() const

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,7 +18,7 @@
#ifndef CUSTOM_ELEMENT_PART_H
#define CUSTOM_ELEMENT_PART_H
#include "qet.h"
#include "../../qet.h"
#include "propertiesinterface.h"
class CustomElement;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,11 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partarc.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../elementscene.h"
/**
@brief PartArc::PartArc

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,13 +16,14 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partdynamictextfield.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "qetapp.h"
#include "elementscene.h"
#include <QGraphicsSceneMouseEvent>
#include <QFont>
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../qetapp.h"
#include "../elementscene.h"
#include <QColor>
#include <QFont>
#include <QGraphicsSceneMouseEvent>
PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent) :
QGraphicsTextItem(parent),
@@ -352,7 +353,7 @@ void PartDynamicTextField::setText(const QString &text) {
void PartDynamicTextField::setInfoName(const QString &info_name) {
m_info_name = info_name;
if(m_text_from == DynamicElementTextItem::ElementInfo && elementScene())
setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
setPlainText(elementScene()->elementData().m_informations.value(m_info_name).toString());
emit infoNameChanged(m_info_name);
}
@@ -372,7 +373,7 @@ QString PartDynamicTextField::infoName() const{
void PartDynamicTextField::setCompositeText(const QString &text) {
m_composite_text = text;
if(m_text_from == DynamicElementTextItem::CompositeText && elementScene())
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene() -> elementInformation()));
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene()->elementData().m_informations));
emit compositeTextChanged(m_composite_text);
}
@@ -585,10 +586,10 @@ void PartDynamicTextField::elementInfoChanged()
return;
if(m_text_from == DynamicElementTextItem::ElementInfo)
setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
setPlainText(elementScene()->elementData().m_informations.value(m_info_name).toString());
else if (m_text_from == DynamicElementTextItem::CompositeText && elementScene())
setPlainText(autonum::AssignVariables::replaceVariable(
m_composite_text, elementScene() -> elementInformation()));
m_composite_text, elementScene()->elementData().m_informations));
}
void PartDynamicTextField::prepareAlignment()

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,9 +18,9 @@
#ifndef PARTDYNAMICTEXTFIELD_H
#define PARTDYNAMICTEXTFIELD_H
#include "customelementpart.h"
#include "../../qetgraphicsitem/dynamicelementtextitem.h"
#include "QGraphicsTextItem"
#include "dynamicelementtextitem.h"
#include "customelementpart.h"
/**
@brief The PartDynamicTextField class

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,10 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partellipse.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../elementscene.h"
/**
@brief PartEllipse::PartEllipse

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,11 +16,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partline.h"
#include <cmath>
#include "elementscene.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../elementscene.h"
#include <cmath>
/**
@brief PartLine::PartLine

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,8 +18,8 @@
#ifndef PART_LINE_H
#define PART_LINE_H
#include "../../qet.h"
#include "customelementgraphicpart.h"
#include "qet.h"
class QPropertyUndoCommand;
class QetGraphicsHandlerItem;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,13 +16,13 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partpolygon.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "qetelementeditor.h"
#include "qeticons.h"
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../../qeticons.h"
#include "../elementscene.h"
#include "../ui/qetelementeditor.h"
/**
@brief PartPolygon::PartPolygon

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,10 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partrectangle.h"
#include "elementscene.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../elementscene.h"
/**
@brief PartRectangle::PartRectangle

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,7 +16,8 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "partterminal.h"
#include "terminal.h"
#include "../../qetgraphicsitem/terminal.h"
/**
@brief PartTerminal::PartTerminal
@@ -98,7 +99,7 @@ void PartTerminal::paint(
const QStyleOptionGraphicsItem *options,
QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(widget)
painter -> save();
// annulation des renderhints
@@ -124,7 +125,7 @@ void PartTerminal::paint(
// dessin de la borne en rouge
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
painter -> setPen(t);
painter -> drawLine(QPointF(0.0, 0.0), d -> second_point);
painter -> drawLine(QPointF(0.0, 0.0), d -> m_second_point);
// dessin du point d'amarrage au conducteur en bleu
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
@@ -144,7 +145,7 @@ void PartTerminal::paint(
QPainterPath PartTerminal::shape() const
{
QPainterPath shape;
shape.lineTo(d -> second_point);
shape.lineTo(d -> m_second_point);
QPainterPathStroker pps;
pps.setWidth(1);
@@ -158,7 +159,7 @@ QPainterPath PartTerminal::shape() const
*/
QRectF PartTerminal::boundingRect() const
{
QRectF br(QPointF(0, 0), d -> second_point);
QRectF br(QPointF(0, 0), d -> m_second_point);
br = br.normalized();
qreal adjust = (SHADOWS_HEIGHT + 1) / 2;
@@ -187,6 +188,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();
@@ -200,10 +215,10 @@ void PartTerminal::updateSecondPoint()
{
qreal ts = 4.0; // terminal size
switch(d -> m_orientation) {
case Qet::North: d -> second_point = QPointF(0.0, ts); break;
case Qet::East : d -> second_point = QPointF(-ts, 0.0); break;
case Qet::South: d -> second_point = QPointF(0.0, -ts); break;
case Qet::West : d -> second_point = QPointF(ts, 0.0); break;
case Qet::North: d -> m_second_point = QPointF(0.0, ts); break;
case Qet::East : d -> m_second_point = QPointF(-ts, 0.0); break;
case Qet::South: d -> m_second_point = QPointF(0.0, -ts); break;
case Qet::West : d -> m_second_point = QPointF(ts, 0.0); break;
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,19 +18,22 @@
#ifndef PART_TERMINAL_H
#define PART_TERMINAL_H
#include "../../properties/terminaldata.h"
#include "customelementgraphicpart.h"
#include "QUuid"
#include "terminaldata.h"
#include <QUuid>
/**
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")); }
bool fromXml(const QDomElement &) override;
QDomElement toXml(QDomDocument &) const override;
@@ -74,7 +77,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,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,11 +16,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parttext.h"
#include "texteditor.h"
#include "elementprimitivedecorator.h"
#include "elementscene.h"
#include "qetapp.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../qetapp.h"
#include "../elementprimitivedecorator.h"
#include "../elementscene.h"
#include "../ui/texteditor.h"
/**
Constructeur

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -17,9 +17,10 @@
*/
#ifndef PART_TEXT_H
#define PART_TEXT_H
#include <QtWidgets>
#include "../../qetapp.h"
#include "customelementpart.h"
#include "qetapp.h"
#include <QtWidgets>
class TextEditor;
class ElementPrimitiveDecorator;

File diff suppressed because it is too large Load Diff

View File

@@ -1,190 +0,0 @@
/*
Copyright 2006-2020 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 CUSTOM_ELEMENT_EDITOR_H
#define CUSTOM_ELEMENT_EDITOR_H
#include "qetmainwindow.h"
#include "qet.h"
#include "elementscene.h"
#include "elementslocation.h"
class ElementItemEditor;
class ElementView;
/**
This class represents an element editor, allowing users to draw, change and
configure a particular electrical element.
*/
class QETElementEditor : public QETMainWindow {
Q_OBJECT
// constructor, destructor
public:
QETElementEditor(QWidget * = nullptr);
~QETElementEditor() override;
private:
QETElementEditor(const QETElementEditor &);
void setupActions();
void setupMenus();
void setupInterface();
// attributes
private:
/// whether the editor is "read-only"
bool read_only;
/// menus
QMenu *file_menu, *edit_menu, *paste_from_menu, *display_menu, *tools_menu;
/// view widget for the editing scene
ElementView *m_view;
/// editing scene
ElementScene *m_elmt_scene;
/// container for widgets dedicated to primitive edition
QDockWidget *m_tools_dock;
/// Stack of widgets for tools_dock
QStackedWidget *m_tools_dock_stack;
/// label displayed when several primitives are selected
QLabel *m_default_informations;
/// Hash associating primitive names with their matching edition widget
QHash<QString, ElementItemEditor *> m_editors;
/// container for the undo list
QDockWidget *m_undo_dock;
/// Container for the list of existing primitives
QDockWidget *m_parts_dock;
/// List of primitives
QListWidget *m_parts_list;
/// actions for the "file" menu
QAction *new_element, *open, *open_dxf, *open_file, *save, *save_as, *save_as_file, *reload, *quit;
/// actions for the "edit" menu
QAction *selectall, *deselectall, *inv_select;
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
QAction *undo, *redo;
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
/// toolbars
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
/// Action group
QActionGroup *parts, *m_zoom_ag, *m_depth_action_group;
/// minimum window title
QString min_title;
/// filename of the currently edited element
QString filename_;
/// location of the currently edited element
ElementsLocation location_;
/// whether the currently edited element comes from a file or a location
bool opened_from_file;
// methods
public:
void setNames(const NamesList &);
void setLocation(const ElementsLocation &);
ElementsLocation location() const;
void setFileName(const QString &);
QString fileName() const;
void setReadOnly(bool);
bool isReadOnly() const;
void fromFile(const QString &);
void fromLocation(const ElementsLocation &);
bool toFile(const QString &);
bool toLocation(const ElementsLocation &location);
bool isEditing(const ElementsLocation &);
bool isEditing(const QString &);
ElementScene *elementScene() const;
void readSettings();
void writeSettings();
static QPointF pasteOffset();
static QString getOpenElementFileName(QWidget * = nullptr, const QString & = QString());
void contextMenu(QPoint p, QList<QAction *> actions = QList<QAction*>());
signals:
void saveToLocation(ElementsLocation loc);
protected:
void closeEvent(QCloseEvent *) override;
void firstActivation(QEvent *) override;
private:
bool canClose();
QWidget *clearToolsDock();
void copyAndPasteXml(const QDomDocument &);
public slots:
void addLine();
void addRect();
void addEllipse();
void addPolygon();
void addArc();
void addText();
void addTerminal();
void addDynamicTextField();
void UncheckAddPrimitive();
void slot_new();
void slot_open();
void slot_openDxf();
void slot_openFile();
void openRecentFile(const QString &);
void openElement(const QString &);
void slot_reload();
bool slot_save();
bool slot_saveAs();
bool slot_saveAsFile();
void slot_setRubberBandToView();
void slot_setNoDragToView();
void slot_updateInformations();
void slot_updateMenus();
void slot_updateTitle();
void slot_createPartsList();
void slot_updatePartsList();
void slot_updateSelectionFromPartsList();
bool checkElement();
void pasteFromFile();
void pasteFromElement();
void updateCurrentPartEditor();
};
/**
@param nameslist the new list of names for the currently edited element
*/
inline void QETElementEditor::setNames(const NamesList &nameslist) {
m_elmt_scene -> setNames(nameslist);
}
/**
@return the location of the currently edited element
*/
inline ElementsLocation QETElementEditor::location() const
{
return(location_);
}
/**
@return the filename of the currently edited element
*/
inline QString QETElementEditor::fileName() const
{
return(filename_);
}
/**
@return the editing scene
*/
inline ElementScene *QETElementEditor::elementScene() const
{
return(m_elmt_scene);
}
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,13 +16,15 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "styleeditor.h"
#include "customelementgraphicpart.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "qeticons.h"
#include <QComboBox>
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../editor/graphicspart/customelementgraphicpart.h"
#include "../qeticons.h"
#include <QCheckBox>
#include <QVBoxLayout>
#include <QComboBox>
#include <QLabel>
#include <QVBoxLayout>
/**
Constructeur

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify

View File

@@ -1,320 +0,0 @@
/*
Copyright 2006-2020 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 "partterminal.h"
#include "qeticons.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
/**
@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-2020 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

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,31 +16,36 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dynamictextfieldeditor.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../editor/graphicspart/customelementpart.h"
#include "../../editor/graphicspart/partdynamictextfield.h"
#include "../../qetapp.h"
#include "../../qetinformation.h"
#include "../../ui/alignmenttextdialog.h"
#include "../../ui/compositetexteditdialog.h"
#include "../ui/qetelementeditor.h"
#include "../elementscene.h"
#include "ui_dynamictextfieldeditor.h"
#include "customelementpart.h"
#include "partdynamictextfield.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "qetelementeditor.h"
#include "qetapp.h"
#include "compositetexteditdialog.h"
#include "alignmenttextdialog.h"
#include <QColorDialog>
#include <QGraphicsItem>
#include <QPointer>
#include <assert.h>
#include <QPointer>
#include <QGraphicsItem>
#include <QColorDialog>
DynamicTextFieldEditor::DynamicTextFieldEditor(
QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) :
DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor,
PartDynamicTextField *text_field,
QWidget *parent) :
ElementItemEditor(editor, parent),
ui(new Ui::DynamicTextFieldEditor) {
ui(new Ui::DynamicTextFieldEditor)
{
ui -> setupUi(this);
ui -> m_composite_text_pb -> setDisabled(true);
ui -> m_elmt_info_cb -> setDisabled(true);
setupWidget();
if(text_field) {
setPart(text_field);
}
fillInfoComboBox();
}
DynamicTextFieldEditor::~DynamicTextFieldEditor()
@@ -73,6 +78,7 @@ bool DynamicTextFieldEditor::setPart(CustomElementPart *part) {
m_text_field = static_cast<PartDynamicTextField *>(qgi);
updateForm();
setUpConnections();
fillInfoComboBox();
return true;
}
@@ -86,7 +92,7 @@ bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
return true;
}
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first())) {
if (PartDynamicTextField *part = static_cast<PartDynamicTextField *>(parts.first())) {
if (m_text_field) {
disconnectConnections();
}
@@ -98,6 +104,7 @@ bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
setUpConnections();
fillInfoComboBox();
updateForm();
return true;
}
@@ -132,7 +139,10 @@ void DynamicTextFieldEditor::updateForm()
ui -> m_frame_cb -> setChecked(m_text_field.data() -> frame());
ui -> m_user_text_le -> setText(m_text_field.data() -> text());
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
ui -> m_color_kpb -> setColor(m_text_field.data() -> color());
#ifdef BUILD_WITHOUT_KF5
#else
m_color_kpb -> setColor(m_text_field.data() -> color());
#endif
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
ui -> m_font_pb -> setText(m_text_field -> font().family());
@@ -156,6 +166,20 @@ void DynamicTextFieldEditor::updateForm()
}
}
void DynamicTextFieldEditor::setupWidget()
{
#ifdef BUILD_WITHOUT_KF5
#else
m_color_kpb = new KColorButton(this);
m_color_kpb->setObjectName(QString::fromUtf8("m_color_kpb"));
connect(m_color_kpb, &KColorButton::changed,
this, &DynamicTextFieldEditor::on_m_color_kpb_changed);
ui->m_main_grid_layout->addWidget(m_color_kpb, 7, 1, 1, 2);
#endif
}
void DynamicTextFieldEditor::setUpConnections()
{
assert(m_connection_list.isEmpty());
@@ -201,19 +225,20 @@ void DynamicTextFieldEditor::fillInfoComboBox()
ui -> m_elmt_info_cb -> clear();
QStringList strl;
QString type = elementEditor() -> elementScene() -> elementType();
auto type = elementEditor()->elementScene()->elementData().m_type;
if(type.contains("report")) {
strl << "function" << "tension_protocol" << "conductor_color" << "conductor_section";
if(type & ElementData::AllReport) {
strl = QETInformation::folioReportInfoKeys();
}
else {
strl = QETApp::elementInfoKeys();
strl = QETInformation::elementInfoKeys();
}
//We use a QMap because the keys of the map are sorted, then no matter the curent local,
//the value of the combo box are always alphabetically sorted
QMap <QString, QString> info_map;
for(const QString& str : strl)
info_map.insert(QETApp::elementTranslatedInfoKey(str), str);
info_map.insert(QETInformation::translatedInfoKey(str), str);
for (const QString& key : info_map.keys())
ui -> m_elmt_info_cb -> addItem(key, info_map.value(key));
@@ -308,8 +333,8 @@ void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i] -> infoName(), info);
undo->setText(tr("Modifier l'information d'un texte"));
undoStack().push(undo);
m_parts[i] -> setPlainText(
elementEditor() -> elementScene() -> elementInformation().value(m_parts[i] -> infoName()).toString());
m_parts[i]->setPlainText(
elementEditor()->elementScene()->elementData().m_informations.value(m_parts[i] -> infoName()).toString());
}
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,8 +18,13 @@
#ifndef DYNAMICTEXTFIELDEDITOR_H
#define DYNAMICTEXTFIELDEDITOR_H
#include "elementitemeditor.h"
#include "partdynamictextfield.h"
#include "../elementitemeditor.h"
#include "../graphicspart/partdynamictextfield.h"
#ifdef BUILD_WITHOUT_KF5
#else
# include <KColorButton>
#endif
namespace Ui {
class DynamicTextFieldEditor;
@@ -43,6 +48,7 @@ class DynamicTextFieldEditor : public ElementItemEditor {
void updateForm() override;
private:
void setupWidget();
void fillInfoComboBox();
void setUpConnections();
void disconnectConnections();
@@ -68,6 +74,11 @@ class DynamicTextFieldEditor : public ElementItemEditor {
QPointer<PartDynamicTextField> m_text_field;
QList<PartDynamicTextField*> m_parts;
QList<QMetaObject::Connection> m_connection_list;
#ifdef BUILD_WITHOUT_KF5
#else
KColorButton* m_color_kpb = nullptr;
#endif
};
#endif // DYNAMICTEXTFIELDEDITOR_H

View File

@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="m_main_grid_layout">
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="m_text_from_cb">
<item>
@@ -206,18 +206,8 @@
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="KColorButton" name="m_color_kpb"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
/*
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,8 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementpropertieseditorwidget.h"
#include "../../qetapp.h"
#include "../../qetinformation.h"
#include "ui_elementpropertieseditorwidget.h"
#include "qetapp.h"
#include "../../qetinformation.h"
#include <QItemDelegate>
@@ -35,7 +38,7 @@ class EditorDelegate : public QItemDelegate
QWidget* createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
const QModelIndex &index) const override
{
if(index.column() == 1)
{
@@ -48,23 +51,14 @@ class EditorDelegate : public QItemDelegate
};
/**
@brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
Default constructor
@param basic_type : QString of the drawed element
@param kind_info : DiagramContext to store kindInfo of drawed element
@param elmt_info : the information of element (label, manufacturer etc...]
@param parent : parent widget
*/
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(
QString &basic_type,
DiagramContext &kind_info,
DiagramContext &elmt_info,
QWidget *parent) :
* @brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
* @param data
* @param parent
*/
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(ElementData data, QWidget *parent) :
QDialog(parent),
ui(new Ui::ElementPropertiesEditorWidget),
m_basic_type(basic_type),
m_kind_info (kind_info),
m_elmt_info (elmt_info)
m_data(data)
{
ui->setupUi(this);
setUpInterface();
@@ -88,22 +82,29 @@ void ElementPropertiesEditorWidget::upDateInterface()
{
ui->m_base_type_cb->setCurrentIndex(
ui->m_base_type_cb->findData(
QVariant(m_basic_type)));
m_data.m_type));
if (m_basic_type == "slave")
if (m_data.m_type == ElementData::Slave)
{
ui->m_state_cb->setCurrentIndex(
ui->m_state_cb->findData(
m_kind_info["state"].toString()));
m_data.m_slave_state));
ui->m_type_cb->setCurrentIndex (
ui->m_type_cb->findData(
m_kind_info["type"].toString()));
ui->m_number_ctc->setValue(m_kind_info["number"].toInt());
m_data.m_slave_type));
ui->m_number_ctc->setValue(m_data.m_contact_count);
}
else if (m_basic_type == "master") {
else if (m_data.m_type == ElementData::Master) {
ui->m_master_type_cb->setCurrentIndex(
ui->m_master_type_cb->findData (
m_kind_info["type"]));
m_data.m_master_type));
} else if (m_data.m_type == ElementData::Terminale) {
ui->m_terminal_type_cb->setCurrentIndex(
ui->m_terminal_type_cb->findData(
m_data.m_terminal_type));
ui->m_terminal_func_cb->setCurrentIndex(
ui->m_terminal_func_cb->findData(
m_data.m_terminal_function));
}
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
@@ -115,33 +116,39 @@ void ElementPropertiesEditorWidget::upDateInterface()
void ElementPropertiesEditorWidget::setUpInterface()
{
// Type combo box
ui->m_base_type_cb->addItem (tr("Simple"), QVariant("simple"));
ui->m_base_type_cb->addItem (tr("Maître"), QVariant("master"));
ui->m_base_type_cb->addItem (tr("Esclave"), QVariant("slave"));
ui->m_base_type_cb->addItem (tr("Renvoi de folio suivant"),
QVariant("next_report"));
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"),
QVariant("previous_report"));
ui->m_base_type_cb->addItem (tr("Bornier"), QVariant("terminal"));
ui->m_base_type_cb->addItem (tr("Simple"), ElementData::Simple);
ui->m_base_type_cb->addItem (tr("Maître"), ElementData::Master);
ui->m_base_type_cb->addItem (tr("Esclave"), ElementData::Slave);
ui->m_base_type_cb->addItem (tr("Renvoi de folio suivant"), ElementData::NextReport);
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"), ElementData::PreviousReport);
ui->m_base_type_cb->addItem (tr("Bornier"), ElementData::Terminale);
// Slave option
ui->m_state_cb->addItem(tr("Normalement ouvert"),QVariant("NO"));
ui->m_state_cb->addItem(tr("Normalement fermé"), QVariant("NC"));
ui->m_state_cb->addItem(tr("Inverseur"), QVariant("SW"));
ui->m_type_cb->addItem(tr("Simple"), QVariant("simple"));
ui->m_type_cb->addItem(tr("Puissance"), QVariant("power"));
ui->m_type_cb->addItem(tr("Temporisé travail"), QVariant("delayOn"));
ui->m_type_cb->addItem(tr("Temporisé repos"), QVariant("delayOff"));
ui->m_type_cb->addItem(tr("Temporisé travail & repos"),
QVariant("delayOnOff"));
ui->m_state_cb->addItem(tr("Normalement ouvert"), ElementData::NO);
ui->m_state_cb->addItem(tr("Normalement fermé"), ElementData::NC);
ui->m_state_cb->addItem(tr("Inverseur"), ElementData::SW);
ui->m_type_cb->addItem(tr("Simple"), ElementData::SSimple);
ui->m_type_cb->addItem(tr("Puissance"), ElementData::Power);
ui->m_type_cb->addItem(tr("Temporisé travail"), ElementData::DelayOn);
ui->m_type_cb->addItem(tr("Temporisé repos"), ElementData::DelayOff);
ui->m_type_cb->addItem(tr("Temporisé travail & repos"), ElementData::delayOnOff);
//Master option
ui->m_master_type_cb->addItem(tr("Bobine"), QVariant("coil"));
ui->m_master_type_cb->addItem(tr("Organe de protection"),
QVariant("protection"));
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"),
QVariant("commutator"));
ui->m_master_type_cb->addItem(tr("Bobine"), ElementData::Coil);
ui->m_master_type_cb->addItem(tr("Organe de protection"), ElementData::Protection);
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"), ElementData::Commutator);
//Terminal option
ui->m_terminal_type_cb->addItem(tr("Générique"), ElementData::TTGeneric);
ui->m_terminal_type_cb->addItem(tr("Fusible"), ElementData::Fuse);
ui->m_terminal_type_cb->addItem(tr("Séctionnable"), ElementData::Sectional);
ui->m_terminal_type_cb->addItem(tr("Diode"), ElementData::Diode);
ui->m_terminal_func_cb->addItem(tr("Générique"), ElementData::TFGeneric);
ui->m_terminal_func_cb->addItem(tr("Phase"), ElementData::Phase);
ui->m_terminal_func_cb->addItem(tr("Neutre"), ElementData::Neutral);
ui->m_terminal_func_cb->addItem(tr("Terre"), ElementData::PE);
//Disable the edition of the first column of the information tree
//by this little workaround
ui->m_tree->setItemDelegate(new EditorDelegate(this));
@@ -151,21 +158,28 @@ void ElementPropertiesEditorWidget::setUpInterface()
void ElementPropertiesEditorWidget::updateTree()
{
QString type = ui->m_base_type_cb->itemData(
ui->m_base_type_cb->currentIndex()).toString();
if (type == "master")
ui->m_tree->setEnabled(true);
else if (type == "slave")
ui->m_tree->setDisabled(true);
else if (type == "simple")
ui->m_tree->setEnabled(true);
else if (type == "next_report")
ui->m_tree->setDisabled(true);
else if (type == "previous_report")
ui->m_tree->setDisabled(true);
else if (type == "terminal")
ui->m_tree->setEnabled(true);
auto type_ = ui->m_base_type_cb->currentData().value<ElementData::Type>();
switch (type_) {
case ElementData::Simple:
ui->m_tree->setEnabled(true);
break;
case ElementData::NextReport:
ui->m_tree->setDisabled(true);
break;
case ElementData::PreviousReport:
ui->m_tree->setDisabled(true);
break;
case ElementData::Master:
ui->m_tree->setEnabled(true);
break;
case ElementData::Slave:
ui->m_tree->setDisabled(true);
break;
case ElementData::Terminale:
ui->m_tree->setEnabled(true);
break;
}
}
/**
@@ -173,20 +187,16 @@ void ElementPropertiesEditorWidget::updateTree()
Create QTreeWidgetItem of the tree widget and populate it
*/
void ElementPropertiesEditorWidget::populateTree()
{
QStringList keys{"label", "plant", "comment", "description",
"designation", "manufacturer",
"manufacturer_reference", "supplier", "quantity",
"unity", "machine_manufacturer_reference"};
{
auto keys = QETInformation::elementEditorElementInfoKeys();
for(const QString& key : keys)
{
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree);
qtwi->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
qtwi->setData(0, Qt::DisplayRole,
QETApp::elementTranslatedInfoKey(key));
QETInformation::translatedInfoKey(key));
qtwi->setData(0, Qt::UserRole, key);
qtwi->setText(1, m_elmt_info.value(key).toString());
qtwi->setText(1, m_data.m_informations.value(key).toString());
}
}
@@ -196,23 +206,21 @@ void ElementPropertiesEditorWidget::populateTree()
*/
void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
{
m_basic_type = ui->m_base_type_cb->itemData(
ui->m_base_type_cb->currentIndex()).toString();
if (m_basic_type == "slave")
m_data.m_type = ui->m_base_type_cb->currentData().value<ElementData::Type>();
if (m_data.m_type == ElementData::Slave)
{
m_kind_info.addValue("state",
ui->m_state_cb->itemData(
ui->m_state_cb->currentIndex()));
m_kind_info.addValue("type",
ui->m_type_cb->itemData(
ui->m_type_cb->currentIndex()));
m_kind_info.addValue("number",
QVariant(ui->m_number_ctc->value()));
m_data.m_slave_state = ui->m_state_cb->currentData().value<ElementData::SlaveState>();
m_data.m_slave_type = ui->m_type_cb->currentData().value<ElementData::SlaveType>();
m_data.m_contact_count = ui->m_number_ctc->value();
}
else if(m_basic_type == "master") {
m_kind_info.addValue("type",
ui->m_master_type_cb->itemData(
ui->m_master_type_cb->currentIndex()));
else if (m_data.m_type == ElementData::Master) {
m_data.m_master_type = ui->m_master_type_cb->currentData().value<ElementData::MasterType>();
}
else if (m_data.m_type == ElementData::Terminale)
{
m_data.m_terminal_type = ui->m_terminal_type_cb->currentData().value<ElementData::TerminalType>();
m_data.m_terminal_function = ui->m_terminal_func_cb->currentData().value<ElementData::TerminalFunction>();
}
for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren())
@@ -222,8 +230,8 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
txt.remove("\r");
txt.remove("\n");
m_elmt_info.addValue(qtwi->data(0, Qt::UserRole).toString(),
txt);
m_data.m_informations.addValue(qtwi->data(0, Qt::UserRole).toString(),
txt);
}
this->close();
@@ -233,18 +241,21 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
@brief ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged
@param index : Action when combo-box base type index change
*/
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(
int index)
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int index)
{
bool slave = false , master = false;
bool slave = false , master = false, terminal = false;
if (ui->m_base_type_cb->itemData(index).toString() == "slave")
auto type_ = ui->m_base_type_cb->itemData(index).value<ElementData::Type>();
if (type_ == ElementData::Slave)
slave = true;
else if (ui->m_base_type_cb->itemData(index).toString() == "master")
else if (type_ == ElementData::Master)
master = true;
else if (type_ == ElementData::Terminale)
terminal = true;
ui->m_slave_gb->setVisible(slave);
ui->m_master_gb->setVisible(master);
ui->m_terminal_gb->setVisible(terminal);
updateTree();
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,9 +18,11 @@
#ifndef ELEMENTPROPERTIESEDITORWIDGET_H
#define ELEMENTPROPERTIESEDITORWIDGET_H
#include <QDialog>
#include "../../diagramcontext.h"
#include "../../properties/elementdata.h"
#include <QAbstractButton>
#include "diagramcontext.h"
#include <QDialog>
namespace Ui {
class ElementPropertiesEditorWidget;
@@ -37,12 +39,13 @@ class ElementPropertiesEditorWidget : public QDialog
//METHODS
public:
explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &kind_info, DiagramContext &elmt_info, QWidget *parent = nullptr);
explicit ElementPropertiesEditorWidget(ElementData data, QWidget *parent = nullptr);
~ElementPropertiesEditorWidget() override;
void upDateInterface();
ElementData editedData() {return m_data;}
private:
void upDateInterface();
void setUpInterface();
void updateTree();
void populateTree();
@@ -55,9 +58,7 @@ class ElementPropertiesEditorWidget : public QDialog
//ATTRIBUTES
private:
Ui::ElementPropertiesEditorWidget *ui;
QString &m_basic_type;
DiagramContext &m_kind_info,
&m_elmt_info;
ElementData m_data;
};
#endif // ELEMENTPROPERTIESEDITORWIDGET_H

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>321</height>
<width>527</width>
<height>442</height>
</rect>
</property>
<property name="windowTitle">
@@ -107,6 +107,35 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_terminal_gb">
<property name="title">
<string>Élément bornier</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Fonction</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_terminal_type_cb"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_terminal_func_cb"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,11 +16,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ellipseeditor.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../elementscene.h"
#include "../graphicspart/partellipse.h"
#include "../styleeditor.h"
#include "ui_ellipseeditor.h"
#include "partellipse.h"
#include "styleeditor.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
/**
* @brief EllipseEditor::EllipseEditor
@@ -148,7 +149,7 @@ void EllipseEditor::updateRect()
if (rect != part->property("rect"))
{
auto undo= new QPropertyUndoCommand(ellipse, "rect", ellipse->property("rect"), rect);
undo->setText("Modifier un arc");
undo->setText("Modifier une ellipse");
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,7 +18,7 @@
#ifndef ELLIPSEEDITOR_H
#define ELLIPSEEDITOR_H
#include "elementitemeditor.h"
#include "../elementitemeditor.h"
namespace Ui {
class EllipseEditor;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,13 +16,14 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lineeditor.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../qeticons.h"
#include "../elementitemeditor.h"
#include "../elementscene.h"
#include "../graphicspart/partline.h"
#include "../styleeditor.h"
#include "ui_lineeditor.h"
#include "elementitemeditor.h"
#include "styleeditor.h"
#include "partline.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
#include "qeticons.h"
/**
@brief LineEditor::LineEditor

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,7 +18,7 @@
#ifndef LINEEDITOR_H
#define LINEEDITOR_H
#include "elementitemeditor.h"
#include "../elementitemeditor.h"
namespace Ui {
class LineEditor;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,12 +16,13 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "polygoneditor.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../qetmessagebox.h"
#include "../elementscene.h"
#include "../graphicspart/partpolygon.h"
#include "../styleeditor.h"
#include "ui_polygoneditor.h"
#include "partpolygon.h"
#include "elementscene.h"
#include "qetmessagebox.h"
#include "styleeditor.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
/**
@brief PolygonEditor::PolygonEditor

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,7 +18,7 @@
#ifndef POLYGONEDITOR_H
#define POLYGONEDITOR_H
#include "elementitemeditor.h"
#include "../elementitemeditor.h"
class StyleEditor;
class PartPolygon;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,163 @@
/*
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 QETELEMENTEDITOR_H
#define QETELEMENTEDITOR_H
#include <QMainWindow>
#include "../../ElementsCollection/elementslocation.h"
class ElementScene;
class QActionGroup;
class ElementItemEditor;
class ElementView;
class QListWidget;
class QStackedWidget;
class QLabel;
namespace Ui {
class QETElementEditor;
}
class QETElementEditor : public QMainWindow
{
Q_OBJECT
signals:
void saveToLocation(ElementsLocation loc);
public:
explicit QETElementEditor(QWidget *parent = nullptr);
~QETElementEditor() override;
void contextMenu(QPoint p, QList<QAction *> actions = QList<QAction *>());
void setNames(const NamesList &name_list);
void setLocation(const ElementsLocation &location);
ElementsLocation location() const;
void setFileName(const QString &file_name);
QString fileName() const;
void setReadOnly(bool ro);
bool isReadOnly() const;
void fromFile(const QString &filepath);
bool toFile(const QString &filepath);
void fromLocation(const ElementsLocation &location);
bool toLocation(const ElementsLocation &location);
bool isEditing(const ElementsLocation &location);
bool isEditing(const QString &filepath);
ElementScene *elementScene() const;
ElementView *elementView() const;
static QPointF pasteOffset();
static QString getOpenElementFileName(QWidget *parent = nullptr, const QString &dir = QString());
void updateTitle();
void fillPartsList();
void UncheckAddPrimitive();
void updateCurrentPartEditor();
void updateInformations();
void updatePartsList();
void updateSelectionFromPartsList();
void openElement(const QString &filepath);
bool checkElement();
protected:
bool event(QEvent *event) override;
void closeEvent(QCloseEvent *) override;
private slots:
bool on_m_save_action_triggered();
bool on_m_save_as_action_triggered();
void on_m_select_all_act_triggered();
void on_m_edit_element_properties_action_triggered();
void on_m_new_action_triggered();
void on_m_open_action_triggered();
void on_m_open_from_file_action_triggered();
void on_m_open_dxf_action_triggered();
bool on_m_save_as_file_action_triggered();
void on_m_reload_action_triggered();
void on_m_quit_action_triggered();
void on_m_deselect_all_action_triggered();
void on_m_cut_action_triggered();
void on_m_copy_action_triggered();
void on_m_paste_action_triggered();
void on_m_paste_in_area_action_triggered();
void on_m_paste_from_file_action_triggered();
void on_m_paste_from_element_action_triggered();
void on_m_revert_selection_action_triggered();
void on_m_delete_action_triggered();
void on_m_edit_names_action_triggered();
void on_m_edit_author_action_triggered();
void on_m_zoom_in_action_triggered();
void on_m_zoom_out_action_triggered();
void on_m_zoom_fit_best_action_triggered();
void on_m_zoom_original_action_triggered();
void on_m_about_qet_action_triggered();
void on_m_online_manual_triggered();
void on_m_youtube_action_triggered();
void on_m_donate_action_triggered();
void on_m_about_qt_action_triggered();
private:
bool canClose();
void readSettings();
void writeSettings() const;
void setupActions();
void updateAction();
void setupConnection();
void initGui();
QWidget *clearToolsDock();
void copyAndPasteXml(const QDomDocument &xml_document);
private:
Ui::QETElementEditor *ui;
bool
m_read_only = false,
m_opened_from_file = false,
m_first_activation = true;
ElementScene *m_elmt_scene = nullptr;
QActionGroup
*m_add_part_action_grp = nullptr,
*m_depth_action_group = nullptr;
QList<QAction *> m_context_menu_action_list;
QAction
*m_undo_action = nullptr,
*m_redo_action = nullptr;
/// Hash associating primitive names with their matching edition widget
QHash<QString, ElementItemEditor *> m_editors;
ElementsLocation m_location;
QString
m_file_name,
m_min_title;
ElementView *m_view = nullptr;
QListWidget *m_parts_list = nullptr;
QStackedWidget *m_tools_dock_stack = nullptr;
QLabel *m_default_informations = nullptr;
};
#endif // QETELEMENTEDITOR_H

View File

@@ -0,0 +1,496 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QETElementEditor</class>
<widget class="QMainWindow" name="QETElementEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>QElectroTech - Éditeur d'élément</string>
</property>
<property name="windowIcon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/qet.png</normaloff>:/ico/16x16/qet.png</iconset>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="m_file_menu">
<property name="title">
<string>&amp;Fichier</string>
</property>
<addaction name="m_new_action"/>
<addaction name="m_open_action"/>
<addaction name="m_open_from_file_action"/>
<addaction name="m_open_dxf_action"/>
<addaction name="m_save_action"/>
<addaction name="m_save_as_action"/>
<addaction name="m_save_as_file_action"/>
<addaction name="separator"/>
<addaction name="m_reload_action"/>
<addaction name="separator"/>
<addaction name="m_quit_action"/>
</widget>
<widget class="QMenu" name="m_edit_menu">
<property name="title">
<string>&amp;Édition</string>
</property>
<widget class="QMenu" name="m_paste_from_menu">
<property name="title">
<string>Coller depuis...</string>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
</property>
<addaction name="m_paste_from_file_action"/>
<addaction name="m_paste_from_element_action"/>
</widget>
<addaction name="separator"/>
<addaction name="m_select_all_act"/>
<addaction name="m_deselect_all_action"/>
<addaction name="m_revert_selection_action"/>
<addaction name="separator"/>
<addaction name="m_cut_action"/>
<addaction name="m_copy_action"/>
<addaction name="m_paste_action"/>
<addaction name="m_paste_in_area_action"/>
<addaction name="m_paste_from_menu"/>
<addaction name="separator"/>
<addaction name="m_delete_action"/>
<addaction name="separator"/>
<addaction name="m_edit_names_action"/>
<addaction name="m_edit_author_action"/>
<addaction name="m_edit_element_properties_action"/>
</widget>
<widget class="QMenu" name="m_display_menu">
<property name="title">
<string>Afficha&amp;ge</string>
</property>
<addaction name="m_zoom_in_action"/>
<addaction name="m_zoom_out_action"/>
<addaction name="m_zoom_fit_best_action"/>
<addaction name="m_zoom_original_action"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_Aide">
<property name="title">
<string>&amp;Aide</string>
</property>
<addaction name="separator"/>
<addaction name="m_about_qet_action"/>
<addaction name="m_online_manual"/>
<addaction name="m_youtube_action"/>
<addaction name="m_donate_action"/>
<addaction name="m_about_qt_action"/>
</widget>
<addaction name="m_file_menu"/>
<addaction name="m_edit_menu"/>
<addaction name="m_display_menu"/>
<addaction name="menu_Aide"/>
</widget>
<widget class="QDockWidget" name="m_undo_dock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Annulations</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents"/>
</widget>
<widget class="QDockWidget" name="m_parts_dock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Parties</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2"/>
</widget>
<widget class="QDockWidget" name="m_tools_dock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Informations</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3"/>
</widget>
<widget class="QToolBar" name="m_main_toolbar">
<property name="windowTitle">
<string>Outils</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="m_new_action"/>
<addaction name="m_open_action"/>
<addaction name="m_save_action"/>
<addaction name="m_save_as_action"/>
<addaction name="m_reload_action"/>
<addaction name="m_delete_action"/>
</widget>
<widget class="QToolBar" name="m_view_toolbar">
<property name="windowTitle">
<string>Affichage</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="m_zoom_in_action"/>
<addaction name="m_zoom_out_action"/>
<addaction name="m_zoom_fit_best_action"/>
<addaction name="m_zoom_original_action"/>
</widget>
<widget class="QToolBar" name="m_element_toolbar">
<property name="windowTitle">
<string>Élément</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="m_edit_names_action"/>
<addaction name="m_edit_element_properties_action"/>
</widget>
<widget class="QToolBar" name="m_undo_toolbar">
<property name="windowTitle">
<string>Annulation</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="m_select_all_act">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-all.png</normaloff>:/ico/16x16/edit-select-all.png</iconset>
</property>
<property name="text">
<string>Tout sélectionner</string>
</property>
</action>
<action name="m_new_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-new.png</normaloff>:/ico/22x22/document-new.png</iconset>
</property>
<property name="text">
<string>&amp;Nouveau</string>
</property>
</action>
<action name="m_open_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
</property>
<property name="text">
<string>&amp;Ouvrir</string>
</property>
</action>
<action name="m_open_from_file_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
</property>
<property name="text">
<string>&amp;Ouvrir depuis un fichier</string>
</property>
</action>
<action name="m_open_dxf_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/run-dxf.png</normaloff>:/ico/16x16/run-dxf.png</iconset>
</property>
<property name="text">
<string>&amp;Lancer le plugin convertisseur DXF</string>
</property>
</action>
<action name="m_save_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-save.png</normaloff>:/ico/22x22/document-save.png</iconset>
</property>
<property name="text">
<string>&amp;Enregistrer</string>
</property>
</action>
<action name="m_save_as_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-save-as.png</normaloff>:/ico/22x22/document-save-as.png</iconset>
</property>
<property name="text">
<string>Enregistrer sous</string>
</property>
</action>
<action name="m_save_as_file_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-save.png</normaloff>:/ico/22x22/document-save.png</iconset>
</property>
<property name="text">
<string>Enregistrer dans un fichier</string>
</property>
</action>
<action name="m_reload_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/view-refresh.png</normaloff>:/ico/22x22/view-refresh.png</iconset>
</property>
<property name="text">
<string>Recharger</string>
</property>
</action>
<action name="m_quit_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/application-exit.png</normaloff>:/ico/16x16/application-exit.png</iconset>
</property>
<property name="text">
<string>&amp;Quitter</string>
</property>
</action>
<action name="m_deselect_all_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-none.png</normaloff>:/ico/16x16/edit-select-none.png</iconset>
</property>
<property name="text">
<string>Désélectionner tout</string>
</property>
</action>
<action name="m_cut_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-cut.png</normaloff>:/ico/16x16/edit-cut.png</iconset>
</property>
<property name="text">
<string>Co&amp;uper</string>
</property>
</action>
<action name="m_copy_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-copy.png</normaloff>:/ico/16x16/edit-copy.png</iconset>
</property>
<property name="text">
<string>Cop&amp;ier</string>
</property>
</action>
<action name="m_paste_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
</property>
<property name="text">
<string>C&amp;oller</string>
</property>
</action>
<action name="m_paste_in_area_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
</property>
<property name="text">
<string>C&amp;oller dans la zone</string>
</property>
</action>
<action name="m_paste_from_file_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/text-xml.png</normaloff>:/ico/16x16/text-xml.png</iconset>
</property>
<property name="text">
<string>Un fichier</string>
</property>
</action>
<action name="m_paste_from_element_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/element.png</normaloff>:/ico/16x16/element.png</iconset>
</property>
<property name="text">
<string>Un élément</string>
</property>
</action>
<action name="m_revert_selection_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-invert.png</normaloff>:/ico/16x16/edit-select-invert.png</iconset>
</property>
<property name="text">
<string>Inverser la sélection</string>
</property>
</action>
<action name="m_delete_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/edit-delete.png</normaloff>:/ico/22x22/edit-delete.png</iconset>
</property>
<property name="text">
<string>&amp;Supprimer</string>
</property>
</action>
<action name="m_edit_names_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/names.png</normaloff>:/ico/22x22/names.png</iconset>
</property>
<property name="text">
<string>Éditer le nom et les traductions de l'élément</string>
</property>
</action>
<action name="m_edit_author_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/preferences-desktop-user.png</normaloff>:/ico/16x16/preferences-desktop-user.png</iconset>
</property>
<property name="text">
<string>Éditer les informations sur l'auteur</string>
</property>
</action>
<action name="m_edit_element_properties_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/element-edit.png</normaloff>:/ico/22x22/element-edit.png</iconset>
</property>
<property name="text">
<string>Éditer les propriétés de l'élément</string>
</property>
</action>
<action name="m_zoom_in_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-in.png</normaloff>:/ico/22x22/zoom-in.png</iconset>
</property>
<property name="text">
<string>Zoom avant</string>
</property>
</action>
<action name="m_zoom_out_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-out.png</normaloff>:/ico/22x22/zoom-out.png</iconset>
</property>
<property name="text">
<string>Zoom arrière</string>
</property>
</action>
<action name="m_zoom_fit_best_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-fit-best.png</normaloff>:/ico/22x22/zoom-fit-best.png</iconset>
</property>
<property name="text">
<string>Zoom adapté</string>
</property>
</action>
<action name="m_zoom_original_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-original.png</normaloff>:/ico/22x22/zoom-original.png</iconset>
</property>
<property name="text">
<string>Pas de zoom</string>
</property>
</action>
<action name="m_about_qet_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/qet.png</normaloff>:/ico/16x16/qet.png</iconset>
</property>
<property name="text">
<string>À &amp;propos de QElectroTech</string>
</property>
<property name="statusTip">
<string>Affiche des informations sur QElectroTech</string>
</property>
</action>
<action name="m_online_manual">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/help-contents.png</normaloff>:/ico/16x16/help-contents.png</iconset>
</property>
<property name="text">
<string>Manuel en ligne</string>
</property>
<property name="statusTip">
<string>Lance le navigateur par défaut vers le manuel en ligne de QElectroTech</string>
</property>
</action>
<action name="m_youtube_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/kdenlive-show-video.png</normaloff>:/ico/16x16/kdenlive-show-video.png</iconset>
</property>
<property name="text">
<string>Chaine Youtube</string>
</property>
<property name="statusTip">
<string>Lance le navigateur par défaut vers la chaine Youtube de QElectroTech</string>
</property>
</action>
<action name="m_donate_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/help-donate.png</normaloff>:/ico/16x16/help-donate.png</iconset>
</property>
<property name="text">
<string>Soutenir le projet par un don</string>
</property>
<property name="statusTip">
<string>Soutenir le projet QElectroTech par un don</string>
</property>
</action>
<action name="m_about_qt_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/qt.png</normaloff>:/ico/16x16/qt.png</iconset>
</property>
<property name="text">
<string>À propos de &amp;Qt</string>
</property>
<property name="statusTip">
<string>Affiche des informations sur la bibliothèque Qt</string>
</property>
</action>
</widget>
<resources>
<include location="../../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,12 +16,13 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rectangleeditor.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../qeticons.h"
#include "../elementscene.h"
#include "../graphicspart/partrectangle.h"
#include "../styleeditor.h"
#include "ui_rectangleeditor.h"
#include "styleeditor.h"
#include "partrectangle.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "elementscene.h"
#include "qeticons.h"
/**
@brief RectangleEditor::RectangleEditor

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,7 +18,8 @@
#ifndef RECTANGLEEDITOR_H
#define RECTANGLEEDITOR_H
#include "elementitemeditor.h"
#include "../elementitemeditor.h"
#include <QWidget>
class StyleEditor;

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,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "texteditor.h"
#include "ui_texteditor.h"
#include "parttext.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../graphicspart/parttext.h"
#include <cassert>
/**
@@ -29,9 +30,8 @@
@param parent : the parent widget
*/
TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) :
ElementItemEditor(editor, parent),
ui(new Ui::TextEditor) {
ui -> setupUi(this);
ElementItemEditor(editor, parent){
setUpWidget(parent);
setUpEditConnection();
if (text) {
setPart(text);
@@ -42,10 +42,7 @@ TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *paren
/**
@brief TextEditor::~TextEditor
*/
TextEditor::~TextEditor()
{
delete ui;
}
TextEditor::~TextEditor() {}
/**
@brief TextEditor::updateForm
@@ -59,13 +56,16 @@ void TextEditor::updateForm()
disconnectEditConnection();
ui -> m_line_edit -> setText(m_text -> toPlainText());
ui -> m_x_sb -> setValue(m_text -> pos().x());
ui -> m_y_sb -> setValue(m_text -> pos().y());
ui -> m_rotation_sb -> setValue(m_text -> rotation());
ui -> m_size_sb -> setValue(m_text -> font().pointSize());
ui -> m_font_pb -> setText(m_text -> font().family());
ui -> m_color_pb -> setColor(m_text -> defaultTextColor());
m_line_edit -> setText(m_text -> toPlainText());
m_x_sb -> setValue(m_text -> pos().x());
m_y_sb -> setValue(m_text -> pos().y());
m_rotation_sb -> setValue(m_text -> rotation());
m_size_sb -> setValue(m_text -> font().pointSize());
m_font_pb -> setText(m_text -> font().family());
#ifdef BUILD_WITHOUT_KF5
#else
m_color_pb -> setColor(m_text -> defaultTextColor());
#endif
setUpEditConnection();
}
@@ -109,7 +109,7 @@ bool TextEditor::setPart(CustomElementPart *part) {
disconnectChangeConnection();
return true;
}
if (PartText *part_text = static_cast<PartText *>(part)) {
if (part_text == m_text) {
return true;
@@ -176,8 +176,8 @@ void TextEditor::setUpEditConnection()
{
disconnectEditConnection();
m_edit_connection << connect(ui -> m_line_edit, &QLineEdit::editingFinished, [this]() {
QString text_ = ui -> m_line_edit -> text();
m_edit_connection << connect(m_line_edit, &QLineEdit::editingFinished, [this]() {
QString text_ = m_line_edit -> text();
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (text_ != partText -> toPlainText()) {
@@ -187,8 +187,9 @@ void TextEditor::setUpEditConnection()
}
}
});
m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
QPointF pos(ui -> m_x_sb -> value(), 0);
m_edit_connection << connect(m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
QPointF pos(m_x_sb -> value(), 0);
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
pos.setY(partText -> pos().y());
@@ -199,9 +200,11 @@ void TextEditor::setUpEditConnection()
undoStack().push(undo);
}
}
m_x_sb->setFocus();
});
m_edit_connection << connect(ui -> m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
QPointF pos(0, ui -> m_y_sb -> value());
m_edit_connection << connect(m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
QPointF pos(0, m_y_sb -> value());
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
pos.setX(partText -> pos().x());
@@ -212,30 +215,35 @@ void TextEditor::setUpEditConnection()
undoStack().push(undo);
}
}
m_y_sb->setFocus();
});
m_edit_connection << connect(ui -> m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
m_edit_connection << connect(m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (ui -> m_rotation_sb -> value() != partText -> rotation()) {
if (m_rotation_sb -> value() != partText -> rotation()) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(
partText, "rotation", partText -> rotation(), ui -> m_rotation_sb -> value());
partText, "rotation", partText -> rotation(), m_rotation_sb -> value());
undo -> setText(tr("Pivoter un champ texte"));
undo -> setAnimated(true, false);
undoStack().push(undo);
}
}
m_rotation_sb->setFocus();
});
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
m_edit_connection << connect(m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (partText -> font().pointSize() != ui -> m_size_sb -> value()) {
if (partText -> font().pointSize() !=m_size_sb -> value()) {
QFont font_ = partText -> font();
font_.setPointSize(ui -> m_size_sb -> value());
font_.setPointSize(m_size_sb -> value());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText -> font(), font_);
undo -> setText(tr("Modifier la police d'un texte"));
undoStack().push(undo);
}
}
m_size_sb->setFocus();
});
}
@@ -248,11 +256,11 @@ void TextEditor::on_m_font_pb_clicked()
QFont font_ = QFontDialog::getFont(&ok, m_text -> font(), this);
if (ok && font_ != m_text -> font()) {
ui -> m_size_sb -> blockSignals(true);
ui -> m_size_sb -> setValue(font_.pointSize());
ui -> m_size_sb -> blockSignals(false);
m_size_sb -> blockSignals(true);
m_size_sb -> setValue(font_.pointSize());
m_size_sb -> blockSignals(false);
ui -> m_font_pb -> setText(font_.family());
m_font_pb -> setText(font_.family());
}
for (int i=0; i < m_parts.length(); i++) {
@@ -278,5 +286,91 @@ void TextEditor::on_m_color_pb_changed(const QColor &newColor) {
undo -> setText(tr("Modifier la couleur d'un texte"));
undoStack().push(undo);
}
}
}
}
void TextEditor::setUpWidget(QWidget *parent)
{
setWindowTitle(tr("Form"));
resize(378, 133);
QGridLayout *gridLayout = new QGridLayout(parent);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
m_y_sb = new QSpinBox(parent);
m_y_sb->setObjectName(QString::fromUtf8("m_y_sb"));
m_y_sb->setMinimum(-10000);
m_y_sb->setMaximum(10000);
gridLayout->addWidget(m_y_sb, 1, 3, 1, 1);
QLabel*label_2 = new QLabel(tr("Y :"),parent);
gridLayout->addWidget(label_2, 1, 2, 1, 1);
QLabel*label_4 = new QLabel(tr("Police :"),parent);
gridLayout->addWidget(label_4, 2, 0, 1, 1);
m_rotation_sb = new QSpinBox(parent);
m_rotation_sb->setSuffix(tr("\302\260"));
m_rotation_sb->setWrapping(true);
m_rotation_sb->setMaximum(360);
gridLayout->addWidget(m_rotation_sb, 1, 5, 1, 1);
QLabel *label_3 = new QLabel(tr("Rotation :"),parent);
gridLayout->addWidget(label_3, 1, 4, 1, 1);
m_x_sb = new QSpinBox(parent);
m_x_sb->setObjectName(QString::fromUtf8("m_x_sb"));
m_x_sb->setMinimum(-10000);
m_x_sb->setMaximum(10000);
gridLayout->addWidget(m_x_sb, 1, 1, 1, 1);
QLabel *label = new QLabel(tr("X :"),parent);
gridLayout->addWidget(label, 1, 0, 1, 1);
m_size_sb = new QSpinBox(parent);
m_size_sb->setObjectName(QString::fromUtf8("m_size_sb"));
gridLayout->addWidget(m_size_sb, 2, 1, 1, 1);
m_line_edit = new QLineEdit(parent);
m_line_edit->setObjectName(QString::fromUtf8("m_line_edit"));
m_line_edit->setClearButtonEnabled(true);
m_line_edit->setPlaceholderText(tr("Entrer votre texte ici"));
gridLayout->addWidget(m_line_edit, 0, 0, 1, 6);
#ifdef BUILD_WITHOUT_KF5
#else
m_color_pb = new KColorButton(parent);
m_color_pb->setObjectName(QString::fromUtf8("m_color_pb"));
connect(
m_color_pb,
&KColorButton::changed,
this,
&TextEditor::on_m_color_pb_changed);
gridLayout->addWidget(m_color_pb, 2, 5, 1, 1);
#endif
QLabel *label_5 = new QLabel(parent);
label_5->setObjectName(QString::fromUtf8("label_5"));
gridLayout->addWidget(label_5, 2, 4, 1, 1);
m_font_pb = new QPushButton(tr("Couleur :"),parent);
connect(m_font_pb,
&QPushButton::pressed,
this,
&TextEditor::on_m_font_pb_clicked);
gridLayout->addWidget(m_font_pb, 2, 2, 1, 2);
QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout->addItem(verticalSpacer, 3, 2, 1, 1);
setLayout(gridLayout);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2020 The QElectroTech Team
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -18,17 +18,19 @@
#ifndef TEXTEDITOR_H
#define TEXTEDITOR_H
#include "elementitemeditor.h"
#include "../elementitemeditor.h"
#include <QWidget>
#include <QPointer>
#include <QWidget>
#include <QSpinBox>
#include <QLineEdit>
#include <QPushButton>
#ifdef BUILD_WITHOUT_KF5
#else
#include <KColorButton>
#endif
class PartText;
namespace Ui {
class TextEditor;
}
class TextEditor : public ElementItemEditor {
Q_OBJECT
@@ -46,18 +48,27 @@ class TextEditor : public ElementItemEditor {
void on_m_font_pb_clicked();
void on_m_color_pb_changed(const QColor &newColor);
private:
void setUpWidget(QWidget* parent = nullptr);
void setUpEditConnection();
void setUpChangeConnection(QPointer<PartText> part);
void disconnectChangeConnection();
void disconnectEditConnection();
private:
Ui::TextEditor *ui;
QPointer <PartText> m_text;
QList<PartText*> m_parts;
QList <QMetaObject::Connection> m_edit_connection;
QList <QMetaObject::Connection> m_change_connection;
QSpinBox *m_y_sb;
QSpinBox *m_rotation_sb;
QSpinBox *m_x_sb;
QSpinBox *m_size_sb;
QLineEdit *m_line_edit;
QPushButton *m_font_pb;
#ifdef BUILD_WITHOUT_KF5
#else
KColorButton *m_color_pb;
#endif
};
#endif // TEXTEDITOR_H

View File

@@ -1,132 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TextEditor</class>
<widget class="QWidget" name="TextEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>133</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="3">
<widget class="QSpinBox" name="m_y_sb">
<property name="minimum">
<number>-10000</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Y :</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Police :</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QSpinBox" name="m_rotation_sb">
<property name="wrapping">
<bool>true</bool>
</property>
<property name="suffix">
<string>°</string>
</property>
<property name="maximum">
<number>360</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Rotation :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_x_sb">
<property name="minimum">
<number>-10000</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>X :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="m_size_sb"/>
</item>
<item row="0" column="0" colspan="6">
<widget class="QLineEdit" name="m_line_edit">
<property name="placeholderText">
<string>Entrer votre texte ici</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="KColorButton" name="m_color_pb"/>
</item>
<item row="2" column="4">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Couleur :</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QPushButton" name="m_font_pb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<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>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>