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 QElectroTech Team
Copyright 2006-2021 QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -16,10 +16,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "projectdbmodel.h"
#include "projectdatabase.h"
#include "qetproject.h"
#include "qetxml.h"
#include "qetapp.h"
#include "../../dataBase/projectdatabase.h"
#include "../../qetapp.h"
#include "../../qetinformation.h"
#include "../../qetproject.h"
#include "../../qetxml.h"
#include <QSqlError>
#include <QSqlRecord>
@@ -348,10 +350,7 @@ void ProjectDBModel::setHeaderString()
} else if (field_name == "diagram_position") {
header_name = tr("Position du folio");
} else {
header_name = QETApp::elementTranslatedInfoKey(field_name);
if (header_name.isEmpty()) {
header_name = QETApp::diagramTranslatedInfoKey(field_name);
}
header_name = QETInformation::translatedInfoKey(field_name);
if (header_name.isEmpty()) {
header_name = field_name;
}

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 "qetgraphicsheaderitem.h"
#include "../../createdxf.h"
#include "../../qetxml.h"
#include "../../utils/qetutils.h"
#include "qabstractitemmodel.h"
#include "qetxml.h"
#include "qetutils.h"
#include "createdxf.h"
#include <QFontMetrics>
#include <QPainter>
@@ -441,5 +442,7 @@ void QetGraphicsHeaderItem::adjustSize()
void QetGraphicsHeaderItem::modelReseted()
{
setUpMinimumSectionsSize();
m_current_sections_width.clear();
m_current_sections_width.resize(m_sections_minimum_width.size());
adjustSize();
}

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,10 +18,10 @@
#ifndef QETGRAPHICSHEADERITEM_H
#define QETGRAPHICSHEADERITEM_H
#include "qetapp.h"
#include "../../qetapp.h"
#include <QGraphicsObject>
#include <QFont>
#include <QGraphicsObject>
#include <QMargins>
class QAbstractItemModel;

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,20 +16,21 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qetgraphicstableitem.h"
#include "diagram.h"
#include "qetgraphicsheaderitem.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "qetxml.h"
#include "elementprovider.h"
#include "qetutils.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../createdxf.h"
#include "../../diagram.h"
#include "../../elementprovider.h"
#include "../../qetxml.h"
#include "../../utils/qetutils.h"
#include "projectdbmodel.h"
#include "createdxf.h"
#include "qetgraphicsheaderitem.h"
#include <QAbstractItemModel>
#include <QFontMetrics>
#include <QPainter>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
static int no_model_height = 20;
static int no_model_width = 40;

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,11 +18,11 @@
#ifndef QetGraphicsTableItem_H
#define QetGraphicsTableItem_H
#include <QFont>
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "../../qetapp.h"
#include "../../qetgraphicsitem/qetgraphicsitem.h"
#include "qetgraphicsitem.h"
#include "qetapp.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include <QFont>
class QAbstractItemModel;
class QetGraphicsHeaderItem;

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,16 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "graphicstablepropertieseditor.h"
#include "../../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../../diagram.h"
#include "../../../elementprovider.h"
#include "../../../factory/propertieseditorfactory.h"
#include "../../../undocommand/itemmodelcommand.h"
#include "../../../utils/qetutils.h"
#include "../qetgraphicsheaderitem.h"
#include "../qetgraphicstableitem.h"
#include "ui_graphicstablepropertieseditor.h"
#include "qetgraphicstableitem.h"
#include "qetgraphicsheaderitem.h"
#include "diagram.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "itemmodelcommand.h"
#include "propertieseditorfactory.h"
#include "elementprovider.h"
#include "qetutils.h"
#include <QAbstractItemModel>
#include <QFontDialog>

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,10 @@
#ifndef GRAPHICSTABLEPROPERTIESEDITOR_H
#define GRAPHICSTABLEPROPERTIESEDITOR_H
#include "PropertiesEditor/propertieseditorwidget.h"
#include <QPointer>
#include "../../../PropertiesEditor/propertieseditorwidget.h"
#include <QButtonGroup>
#include <QPointer>
namespace Ui {
class GraphicsTablePropertiesEditor;

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 "projectdbmodelpropertieswidget.h"
#include "../../../dataBase/ui/elementquerywidget.h"
#include "../../../dataBase/ui/summaryquerywidget.h"
#include "../../../qetproject.h"
#include "../projectdbmodel.h"
#include "ui_projectdbmodelpropertieswidget.h"
#include "projectdbmodel.h"
#include "qetproject.h"
#include "elementquerywidget.h"
#include "summaryquerywidget.h"
#include <QDialogButtonBox>

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 PROJECTDBMODELPROPERTIESWIDGET_H
#define PROJECTDBMODELPROPERTIESWIDGET_H
#include "PropertiesEditor/propertieseditorwidget.h"
#include "../../../PropertiesEditor/propertieseditorwidget.h"
class ProjectDBModel;

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,22 +15,24 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtDebug>
#include <QMultiHash>
#include "../qetgraphicsitem/conductor.h"
#include "conductor.h"
#include "conductorsegment.h"
#include "conductorsegmentprofile.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../autoNum/numerotationcontextcommands.h"
#include "../conductorautonumerotation.h"
#include "../conductorsegment.h"
#include "../conductorsegmentprofile.h"
#include "../diagram.h"
#include "../diagramcommands.h"
#include "../qetdiagrameditor.h"
#include "../qetgraphicsitem/terminal.h"
#include "../ui/conductorpropertiesdialog.h"
#include "conductortextitem.h"
#include "element.h"
#include "diagram.h"
#include "diagramcommands.h"
#include "qetdiagrameditor.h"
#include "terminal.h"
#include "conductorautonumerotation.h"
#include "conductorpropertiesdialog.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "numerotationcontextcommands.h"
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include <QMultiHash>
#include <QtDebug>
#define PR(x) qDebug() << #x " = " << x;

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,12 @@
*/
#ifndef CONDUCTOR_H
#define CONDUCTOR_H
#include "../autoNum/assignvariables.h"
#include "../conductorproperties.h"
#include "conductorproperties.h"
#include "propertiesinterface.h"
#include <QGraphicsPathItem>
#include "assignvariables.h"
class ConductorProfile;
class ConductorSegmentProfile;

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 "conductortextitem.h"
#include "conductor.h"
#include "diagramcommands.h"
#include "diagram.h"
#include "../diagram.h"
#include "../diagramcommands.h"
#include "../qetgraphicsitem/conductor.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

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,14 +16,15 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "crossrefitem.h"
#include "element.h"
#include "qetapp.h"
#include "diagramposition.h"
#include "diagram.h"
#include "qgraphicsitemutility.h"
#include "assignvariables.h"
#include "../autoNum/assignvariables.h"
#include "../diagram.h"
#include "../diagramposition.h"
#include "../qetapp.h"
#include "dynamicelementtextitem.h"
#include "element.h"
#include "elementtextitemgroup.h"
#include "qgraphicsitemutility.h"
//define the height of the header.
static int header = 5;

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,11 +18,11 @@
#ifndef CROSSREFITEM_H
#define CROSSREFITEM_H
#include <QGraphicsObject>
#include <QPicture>
#include <QMultiMap>
#include "../properties/xrefproperties.h"
#include"properties/xrefproperties.h"
#include <QGraphicsObject>
#include <QMultiMap>
#include <QPicture>
class Element;
class DynamicElementTextItem;

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 "diagramimageitem.h"
#include "diagram.h"
#include "PropertiesEditor/propertieseditordialog.h"
#include "imagepropertieswidget.h"
#include "../PropertiesEditor/propertieseditordialog.h"
#include "../diagram.h"
#include "../ui/imagepropertieswidget.h"
/**
@brief DiagramImageItem::DiagramImageItem

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 QElectroTech Team
Copyright 2006-2021 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 "diagramtextitem.h"
#include "diagramcommands.h"
#include "qetapp.h"
#include "richtext/richtexteditor_p.h"
#include "diagram.h"
#include "../diagram.h"
#include "../diagramcommands.h"
#include "../qetapp.h"
#include "../richtext/richtexteditor_p.h"
/**
@brief DiagramTextItem::DiagramTextItem

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,16 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dynamicelementtextitem.h"
#include "qet.h"
#include "element.h"
#include "qetapp.h"
#include "diagram.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "terminal.h"
#include "conductor.h"
#include "elementtextitemgroup.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../diagram.h"
#include "../qetapp.h"
#include "../qetgraphicsitem/conductor.h"
#include "../qetgraphicsitem/terminal.h"
#include "../qetinformation.h"
#include "crossrefitem.h"
#include "element.h"
#include "elementtextitemgroup.h"
#include <QDomDocument>
#include <QDomElement>
@@ -44,6 +45,7 @@ DynamicElementTextItem::DynamicElementTextItem(Element *parent_element) :
setParentItem(parent_element);
QSettings settings;
setRotation(settings.value("dynamic_text_rotation", 0).toInt());
setKeepVisualRotation(true);
setTextWidth(settings.value("dynamic_text_widht", -1).toInt());
connect(this, &DynamicElementTextItem::textEdited, [this](const QString &old_str, const QString &new_str)
{
@@ -95,6 +97,7 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
root_element.setAttribute("frame", m_frame? "true" : "false");
root_element.setAttribute("text_width", QString::number(m_text_width));
root_element.setAttribute("font", font().toString());
root_element.setAttribute("keep_visual_rotation", m_keep_visual_rotation ? "true" : "false");
QMetaEnum me = textFromMetaEnum();
root_element.setAttribute("text_from", me.valueToKey(m_text_from));
@@ -159,6 +162,7 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
}
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
setKeepVisualRotation(dom_elmt.attribute("keep_visual_rotation", "true") == "true"? true : false);
if (dom_elmt.hasAttribute("font"))
{
@@ -1150,13 +1154,13 @@ void DynamicElementTextItem::conductorPropertiesChanged()
{
if(m_text_from == ElementInfo)
{
if(m_info_name == "function")
if(m_info_name == QETInformation::COND_FUNCTION)
setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_function : "");
else if (m_info_name == "tension_protocol")
else if (m_info_name == QETInformation::COND_TENSION_PROTOCOL)
setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_tension_protocol : "");
else if (m_info_name == "conductor_color")
else if (m_info_name == QETInformation::COND_COLOR)
setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_wire_color : "");
else if (m_info_name == "conductor_section")
else if (m_info_name == QETInformation::COND_SECTION)
setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_wire_section : "");
}
else if (m_text_from == CompositeText) {
@@ -1248,6 +1252,32 @@ void DynamicElementTextItem::zoomToLinkedElement()
}
}
/**
* @brief DynamicElementTextItem::parentElementRotationChanged
* Called when the parent element is rotated
*/
void DynamicElementTextItem::parentElementRotationChanged()
{
if (m_parent_element && m_keep_visual_rotation)
{
//We temporally disconnect for not change m_visual_rotation value.
//We don't use block signal, because rotationChanged signal is used in other place.
disconnect(this, &DynamicElementTextItem::rotationChanged, this, &DynamicElementTextItem::thisRotationChanged);
this->setRotation(QET::correctAngle(m_visual_rotation_ref - m_parent_element->rotation(), true));
connect(this, &DynamicElementTextItem::rotationChanged, this, &DynamicElementTextItem::thisRotationChanged);
}
}
/**
* @brief DynamicElementTextItem::thisRotationChanged
* This function is called when user change the rotation of the text
* and "keep visual rotation" is to true
* to keep in memory the visual rotation wanted by the user.
*/
void DynamicElementTextItem::thisRotationChanged() {
m_visual_rotation_ref = this->rotation() + m_parent_element->rotation();
}
/**
@brief DynamicElementTextItem::updateXref
Create or delete the Xref according to the current properties of the project
@@ -1422,3 +1452,22 @@ void DynamicElementTextItem::setXref_item(Qt::AlignmentFlag m_exHrefPos)
return;
}
void DynamicElementTextItem::setKeepVisualRotation(bool set)
{
m_keep_visual_rotation = set;
emit keepVisualRotationChanged(set);
if (set) {
m_visual_rotation_ref = this->rotation() + m_parent_element->rotation();
connect(m_parent_element, &Element::rotationChanged, this, &DynamicElementTextItem::parentElementRotationChanged);
connect(this, &DynamicElementTextItem::rotationChanged, this, &DynamicElementTextItem::thisRotationChanged);
}
else {
disconnect(m_parent_element, &Element::rotationChanged, this, &DynamicElementTextItem::parentElementRotationChanged);
disconnect(this, &DynamicElementTextItem::rotationChanged, this, &DynamicElementTextItem::thisRotationChanged);
}
}
bool DynamicElementTextItem::keepVisualRotation() const {
return m_keep_visual_rotation;
}

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,11 +18,12 @@
#ifndef DYNAMICELEMENTTEXTITEM_H
#define DYNAMICELEMENTTEXTITEM_H
#include "../properties/xrefproperties.h"
#include "diagramtextitem.h"
#include "xrefproperties.h"
#include "element.h"
#include <QUuid>
#include <QPointer>
#include <QUuid>
class Element;
class Conductor;
@@ -49,6 +50,7 @@ class DynamicElementTextItem : public DiagramTextItem
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
Q_PROPERTY(bool keepVisualRotation READ keepVisualRotation WRITE setKeepVisualRotation NOTIFY keepVisualRotationChanged)
public:
@@ -69,6 +71,7 @@ class DynamicElementTextItem : public DiagramTextItem
void frameChanged(bool frame);
void plainTextChanged();
void textWidthChanged(qreal width);
void keepVisualRotationChanged(bool keep);
public:
DynamicElementTextItem(Element *parent_element);
@@ -104,6 +107,9 @@ class DynamicElementTextItem : public DiagramTextItem
void setTextWidth(qreal width);
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
void setKeepVisualRotation(bool set);
bool keepVisualRotation() const;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
@@ -133,6 +139,8 @@ class DynamicElementTextItem : public DiagramTextItem
void conductorPropertiesChanged();
QString reportReplacedCompositeText() const;
void zoomToLinkedElement();
void parentElementRotationChanged();
void thisRotationChanged();
private:
QPointer <Element>
@@ -160,6 +168,8 @@ class DynamicElementTextItem : public DiagramTextItem
QGraphicsTextItem *m_slave_Xref_item = nullptr;
qreal m_text_width = -1;
QPointF m_initial_position;
bool m_keep_visual_rotation = true;
qreal m_visual_rotation_ref = 0;
};
#endif // DYNAMICELEMENTTEXTITEM_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
@@ -16,24 +16,26 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "element.h"
#include "diagram.h"
#include "conductor.h"
#include "diagramcommands.h"
#include <utility>
#include "elementprovider.h"
#include "diagramposition.h"
#include "terminal.h"
#include "terminaldata.h"
#include "PropertiesEditor/propertieseditordialog.h"
#include "elementpropertieswidget.h"
#include "numerotationcontextcommands.h"
#include "diagramcontext.h"
#include "changeelementinformationcommand.h"
#include "../PropertiesEditor/propertieseditordialog.h"
#include "../autoNum/numerotationcontextcommands.h"
#include "../diagram.h"
#include "../diagramcommands.h"
#include "../diagramcontext.h"
#include "../diagramposition.h"
#include "../elementprovider.h"
#include "../factory/elementpicturefactory.h"
#include "../properties/terminaldata.h"
#include "../qetgraphicsitem/conductor.h"
#include "../qetgraphicsitem/terminal.h"
#include "../ui/elementpropertieswidget.h"
#include "../undocommand/changeelementinformationcommand.h"
#include "dynamicelementtextitem.h"
#include "elementtextitemgroup.h"
#include "elementpicturefactory.h"
#include "iostream"
#include <QDomElement>
#include <utility>
class ElementXmlRetroCompatibility
{
@@ -212,6 +214,16 @@ void Element::paint(
drawHighlight(painter, options);
}
//Set default pen and brush to QPainter
//for avoid a strange bug when the Qt theme is a "dark" theme.
//Some part of an element are gray or white instead of black.
//This bug seems append only when the QPainter use drawPicture method.
//See bug 175. https://qelectrotech.org/bugtracker/view.php?id=175
painter->save();
QPen pen;
QBrush brush;
painter->setPen(pen);
painter->setBrush(brush);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (options && options -> levelOfDetail < 1.0)
#else
@@ -226,6 +238,8 @@ void Element::paint(
painter->drawPicture(0, 0, m_picture);
}
painter->restore(); //Restor the QPainter after use drawPicture
//Draw the selection rectangle
if ( isSelected() || m_mouse_over ) {
drawSelection(painter, options);
@@ -451,8 +465,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
m_state = QET::GIOK;
return(false);
}
//Extract the names
m_names.fromXml(xml_def_elmt);
m_data.fromXml(xml_def_elmt);
setToolTip(name());
//load kind informations
@@ -460,7 +474,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
xml_def_elmt.firstChildElement("kindInformations"),
"kindInformation");
//load element information
m_element_informations.fromXml(
m_data.m_informations.fromXml(
xml_def_elmt.firstChildElement("elementInformations"),
"elementInformation");
@@ -878,7 +892,7 @@ bool Element::fromXml(
//when element text with tagg "label" is not null, but the element information "label" is.
if((deti->textFrom() == DynamicElementTextItem::ElementInfo)
&& (deti->infoName() == "label"))
m_element_informations.addValue(
m_data.m_informations.addValue(
"label",
dom_input.attribute("text"));
@@ -975,8 +989,8 @@ bool Element::fromXml(
}
//retrocompatibility with older version
if(dc.value("label").toString().isEmpty() &&
!m_element_informations.value("label").toString().isEmpty())
dc.addValue("label", m_element_informations.value("label"));
!m_data.m_informations.value("label").toString().isEmpty())
dc.addValue("label", m_data.m_informations.value("label"));
//We must to block the update of the alignment when load the information
//otherwise the pos of the text will not be the same as it was at save time.
@@ -1002,15 +1016,15 @@ bool Element::fromXml(
{
//#2 the element information must have label not empty and visible
//and a least comment or location not empty and visible
QString label = m_element_informations.value(
QString label = m_data.m_informations.value(
"label").toString();
QString comment = m_element_informations.value(
QString comment = m_data.m_informations.value(
"comment").toString();
QString location = m_element_informations.value(
QString location = m_data.m_informations.value(
"location").toString();
bool la = m_element_informations.keyMustShow("label");
bool c = m_element_informations.keyMustShow("comment");
bool lo = m_element_informations.keyMustShow("location");
bool la = m_data.m_informations.keyMustShow("label");
bool c = m_data.m_informations.keyMustShow("comment");
bool lo = m_data.m_informations.keyMustShow("location");
if((m_link_type != Master) ||
((m_link_type == Master) &&
@@ -1030,12 +1044,13 @@ bool Element::fromXml(
if(deti->textFrom()== DynamicElementTextItem::ElementInfo
&& deti->infoName() == "label")
{
qDebug() << "see 'Mod overlapping comparisons' in git";
qreal rotation = deti->rotation();
//Create the comment item
DynamicElementTextItem *comment_text = nullptr;
if (m_link_type !=PreviousReport
|| m_link_type !=NextReport)
if (m_link_type != PreviousReport
&& m_link_type != NextReport)
{
m_state = QET::GIOK;
return(true);
@@ -1056,7 +1071,8 @@ bool Element::fromXml(
}
//create the location item
DynamicElementTextItem *location_text = nullptr;
if (m_link_type !=PreviousReport || m_link_type !=NextReport)
if (m_link_type != PreviousReport
&& m_link_type != NextReport)
{
m_state = QET::GIOK;
return(true);
@@ -1076,9 +1092,8 @@ bool Element::fromXml(
}
QPointF pos = deti->pos();
// TODO: check
if (m_link_type !=PreviousReport
|| m_link_type !=NextReport)
if (m_link_type != PreviousReport
&& m_link_type != NextReport)
{
m_state = QET::GIOK;
return(true);
@@ -1242,10 +1257,10 @@ QDomElement Element::toXml(
}
//save information of this element
if (! m_element_informations.keys().isEmpty()) {
if (! m_data.m_informations.keys().isEmpty()) {
QDomElement infos =
document.createElement("elementInformations");
m_element_informations.toXml(infos, "elementInformation");
m_data.m_informations.toXml(infos, "elementInformation");
element.appendChild(infos);
}
@@ -1589,14 +1604,14 @@ QString Element::linkTypeToString() const
*/
void Element::setElementInformations(DiagramContext dc)
{
if (m_element_informations == dc) {
if (m_data.m_informations == dc) {
return;
}
DiagramContext old_info = m_element_informations;
m_element_informations = dc;
m_element_informations.addValue("label", actualLabel()); //Update the label if there is a formula
emit elementInfoChange(old_info, m_element_informations);
DiagramContext old_info = m_data.m_informations;
m_data.m_informations = dc;
m_data.m_informations.addValue("label", actualLabel()); //Update the label if there is a formula
emit elementInfoChange(old_info, m_data.m_informations);
}
/**
@@ -1710,7 +1725,7 @@ void Element::setUpFormula(bool code_letter)
->project()
->elementAutoNumCurrentFormula();
m_element_informations.addValue("formula", formula);
m_data.m_informations.addValue("formula", formula);
QString element_currentAutoNum = diagram()
->project()
@@ -1731,9 +1746,9 @@ void Element::setUpFormula(bool code_letter)
if(!m_freeze_label && !formula.isEmpty())
{
DiagramContext dc = m_element_informations;
m_element_informations.addValue("label", actualLabel());
emit elementInfoChange(dc, m_element_informations);
DiagramContext dc = m_data.m_informations;
m_data.m_informations.addValue("label", actualLabel());
emit elementInfoChange(dc, m_data.m_informations);
}
}
}
@@ -1786,11 +1801,11 @@ void Element::freezeNewAddedElement()
*/
QString Element::actualLabel()
{
if (m_element_informations.value("formula").toString().isEmpty()) {
return m_element_informations.value("label").toString();
if (m_data.m_informations.value("formula").toString().isEmpty()) {
return m_data.m_informations.value("label").toString();
} else {
return autonum::AssignVariables::formulaToLabel(
m_element_informations.value(
m_data.m_informations.value(
"formula").toString(),
m_autoNum_seq,
diagram(),
@@ -1802,9 +1817,8 @@ QString Element::actualLabel()
@brief Element::name
@return the human name of this element
*/
QString Element::name() const
{
return m_names.name(m_location.baseName());
QString Element::name() const {
return m_data.m_names_list.name(m_location.baseName());
}
ElementsLocation Element::location() 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,16 +18,17 @@
#ifndef ELEMENT_H
#define ELEMENT_H
#include <algorithm>
#include <QPicture>
#include <QHash>
#include "qet.h"
#include "../ElementsCollection/elementslocation.h"
#include "../NameList/nameslist.h"
#include "../autoNum/assignvariables.h"
#include "../diagramcontext.h"
#include "../qet.h"
#include "qetgraphicsitem.h"
#include "diagramcontext.h"
#include "assignvariables.h"
#include "elementslocation.h"
#include "nameslist.h"
#include "../properties/elementdata.h"
#include <QHash>
#include <QPicture>
#include <algorithm>
class QETProject;
class Terminal;
@@ -100,7 +101,7 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
//METHODS related to information
DiagramContext elementInformations()const
{return m_element_informations;}
{return m_data.m_informations;}
virtual void setElementInformations(DiagramContext dc);
DiagramContext kindInformations() const
{return m_kind_informations;}
@@ -214,16 +215,16 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
kind m_link_type = Element::Simple;
//ATTRIBUTES related to informations
DiagramContext m_element_informations, m_kind_informations;
DiagramContext m_kind_informations;
autonum::sequentialNumbers m_autoNum_seq;
bool m_freeze_label = false;
QString m_F_str;
ElementsLocation m_location;
NamesList m_names;
QList <Terminal *> m_terminals;
const QPicture m_picture;
const QPicture m_low_zoom_picture;
ElementData m_data;
private:
bool m_must_highlight = 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
@@ -16,18 +16,19 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementtextitemgroup.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../diagram.h"
#include "../qetapp.h"
#include "../undocommand/addelementtextcommand.h"
#include "crossrefitem.h"
#include "dynamicelementtextitem.h"
#include "element.h"
#include "diagram.h"
#include "addelementtextcommand.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "crossrefitem.h"
#include "qetapp.h"
#include "masterelement.h"
#include "qgraphicsitemutility.h"
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <utility>
/**

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 "independenttextitem.h"
#include "qet.h"
#include "diagram.h"
#include "diagramcommands.h"
#include "qetapp.h"
#include "../diagram.h"
#include "../diagramcommands.h"
#include "../qet.h"
#include "../qetapp.h"
#include <QDomElement>
#include <QSettings>

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,9 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "masterelement.h"
#include "../diagram.h"
#include "crossrefitem.h"
#include "diagram.h"
#include "dynamicelementtextitem.h"
#include <QRegularExpression>
/**

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 "qetgraphicsitem.h"
#include "diagram.h"
#include "../diagram.h"
/**
@brief QetGraphicsItem::QetGraphicsItem

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 QETGRAPHICSITEM_H
#define QETGRAPHICSITEM_H
#include "../qet.h"
#include <QGraphicsObject>
#include "qet.h"
class Diagram;

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,16 +16,17 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qetshapeitem.h"
#include "createdxf.h"
#include "diagram.h"
#include "qet.h"
#include "shapegraphicsitempropertieswidget.h"
#include "PropertiesEditor/propertieseditordialog.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "qetxml.h"
#include "diagramview.h"
#include "qeticons.h"
#include "../PropertiesEditor/propertieseditordialog.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../createdxf.h"
#include "../diagram.h"
#include "../diagramview.h"
#include "../qet.h"
#include "../qeticons.h"
#include "../qetxml.h"
#include "../ui/shapegraphicsitempropertieswidget.h"
/**
@brief QetShapeItem::QetShapeItem

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,10 @@
#ifndef QETSHAPEITEM_H
#define QETSHAPEITEM_H
#include <QPen>
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include "qetgraphicsitem.h"
#include "QetGraphicsItemModeler/qetgraphicshandleritem.h"
#include <QPen>
class QDomElement;
class QDomDocument;

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,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qgraphicsitemutility.h"
#include "../diagram.h"
#include "element.h"
#include "diagram.h"
#include <QGraphicsItem>
#include <QDebug>
#include <QGraphicsItem>
/**
@brief centerToParentBottom

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 "reportelement.h"
#include "diagramposition.h"
#include "qetproject.h"
#include "diagram.h"
#include "terminal.h"
#include "conductor.h"
#include "../diagram.h"
#include "../diagramposition.h"
#include "../qetgraphicsitem/conductor.h"
#include "../qetgraphicsitem/terminal.h"
#include "../qetproject.h"
#include "dynamicelementtextitem.h"
ReportElement::ReportElement(const ElementsLocation &location, const QString& link_type,QGraphicsItem *qgi, int *state) :

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 "simpleelement.h"
#include "diagram.h"
#include "../diagram.h"
/**
@brief SimpleElement::SimpleElement

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,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "slaveelement.h"
#include "diagramposition.h"
#include "qetapp.h"
#include "diagram.h"
#include "../diagram.h"
#include "../diagramposition.h"
#include "../qetapp.h"
#include "dynamicelementtextitem.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
@@ -18,8 +18,8 @@
#ifndef SLAVEELEMENT_H
#define SLAVEELEMENT_H
#include "../properties/xrefproperties.h"
#include "element.h"
#include"properties/xrefproperties.h"
class SlaveElement : public Element
{

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,22 +15,23 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "terminal.h"
#include "../qetgraphicsitem/terminal.h"
#include "../conductorautonumerotation.h"
#include "../diagram.h"
#include "../undocommand/addgraphicsobjectcommand.h"
#include "../properties/terminaldata.h"
#include "../qetgraphicsitem/conductor.h"
#include "../qetgraphicsitem/element.h"
#include "conductortextitem.h"
#include <utility>
#include "diagram.h"
#include "qetgraphicsitem/element.h"
#include "qetgraphicsitem/conductor.h"
#include "diagramcommands.h"
#include "conductorautonumerotation.h"
#include "conductortextitem.h"
#include "terminaldata.h"
QColor Terminal::neutralColor = QColor(Qt::blue);
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
QColor Terminal::warningColor = QColor("#ff8000");
QColor Terminal::forbiddenColor = QColor(Qt::red);
const qreal Terminal::terminalSize = 4.0; // TODO: store terminalSize in terminaldata, because in PartTerminal there is the same parameter. So only one is needed
QColor Terminal::neutralColor = QColor(Qt::blue);
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
QColor Terminal::warningColor = QColor("#ff8000");
QColor Terminal::forbiddenColor = QColor(Qt::red);
const qreal Terminal::terminalSize = 4.0;
const qreal Terminal::Z = 1000;
/**
@@ -40,28 +41,29 @@ const qreal Terminal::Z = 1000;
@param name of terminal
@param hiddenName
*/
void Terminal::init(
QString number, QString name, bool hiddenName)
void Terminal::init()
{
// calcul de la position du point d'amarrage a l'element
//Calcul the docking point of the element
//m_pos of d is the docking point of conductor
dock_elmt_ = d->m_pos;
switch(d->m_orientation) {
case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
case Qet::South:
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
case Qet::South: dock_elmt_ += QPointF(0, -Terminal::terminalSize); break;
}
// Number of terminal
number_terminal_ = std::move(number);
// Name of terminal
d->m_name = std::move(name);
name_terminal_hidden = hiddenName;
// par defaut : pas de conducteur
// QRectF null
br_ = new QRectF();
// divers
//Calcul the bounding rect
qreal dcx = d->m_pos.x();
qreal dcy = d->m_pos.y();
qreal dex = dock_elmt_.x();
qreal dey = dock_elmt_.y();
QPointF origin = (dcx <= dex && dcy <= dey ? d->m_pos : dock_elmt_);
origin += QPointF(-3.0, -3.0);
qreal w = qAbs(dcx - dex) + 7;
qreal h = qAbs(dcy - dey) + 7;
m_br = QRectF(origin, QSizeF(w, h));
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::LeftButton);
setToolTip(QObject::tr("Borne", "tooltip"));
@@ -151,23 +153,16 @@ Terminal::Terminal(TerminalData* data, Element* e) :
d(data),
parent_element_(e)
{
#if TODO_LIST
#pragma message("@TODO what is when multiple parents exist. So the other relation is lost.")
#endif
// TODO: what is when multiple parents exist. So the other relation is lost.
d->setParent(this);
init("_", "_", false);
init();
}
/**
Destructeur
La destruction de la borne entraine la destruction des conducteurs
associes.
*/
Terminal::~Terminal()
{
foreach(Conductor *c, conductors_) delete c;
delete br_;
* @brief Terminal::~Terminal
* Destruction of the terminal, and also docked conductor
*/
Terminal::~Terminal() {
qDeleteAll(m_conductors_list);
}
/**
@@ -193,7 +188,6 @@ Qet::Orientation Terminal::orientation() const
} else return(d->m_orientation);
}
/**
@brief Terminal::setNumber
@param number
@@ -241,11 +235,11 @@ bool Terminal::addConductor(Conductor *conductor)
? conductor->terminal2 : conductor->terminal1;
//Check if this terminal isn't already linked with other_terminal
foreach (Conductor* cond, conductors_)
foreach (Conductor* cond, m_conductors_list)
if (cond -> terminal1 == other_terminal || cond -> terminal2 == other_terminal)
return false; //They already a conductor linked to this and other_terminal
conductors_.append(conductor);
m_conductors_list.append(conductor);
emit conductorWasAdded(conductor);
return(true);
}
@@ -257,9 +251,9 @@ bool Terminal::addConductor(Conductor *conductor)
*/
void Terminal::removeConductor(Conductor *conductor)
{
int index = conductors_.indexOf(conductor);
int index = m_conductors_list.indexOf(conductor);
if (index == -1) return;
conductors_.removeAt(index);
m_conductors_list.removeAt(index);
emit conductorWasRemoved(conductor);
}
@@ -316,10 +310,10 @@ void Terminal::paint(
painter -> drawLine(c, e);
// dessin du point d'amarrage au conducteur en bleu
t.setColor(hovered_color_);
t.setColor(m_hovered_color);
painter -> setPen(t);
painter -> setBrush(hovered_color_);
if (hovered_) {
painter -> setBrush(m_hovered_color);
if (m_hovered) {
painter -> setRenderHint(QPainter::Antialiasing, true);
painter -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
} else painter -> drawPoint(c);
@@ -451,21 +445,8 @@ QLineF Terminal::HelpLine() const
@brief Terminal::boundingRect
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
*/
QRectF Terminal::boundingRect() const
{
if (br_ -> isNull())
{
qreal dcx = d->m_pos.x();
qreal dcy = d->m_pos.y();
qreal dex = dock_elmt_.x();
qreal dey = dock_elmt_.y();
QPointF origin = (dcx <= dex && dcy <= dey ? d->m_pos : dock_elmt_);
origin += QPointF(-3.0, -3.0);
qreal w = qAbs((int)(dcx - dex)) + 7;
qreal h = qAbs((int)(dcy - dey)) + 7;
*br_ = QRectF(origin, QSizeF(w, h));
}
return(*br_);
QRectF Terminal::boundingRect() const {
return m_br;
}
/**
@@ -536,7 +517,7 @@ Terminal* Terminal::alignedWithTerminal() const
*/
void Terminal::hoverEnterEvent(QGraphicsSceneHoverEvent *)
{
hovered_ = true;
m_hovered = true;
update();
}
@@ -552,7 +533,7 @@ void Terminal::hoverMoveEvent(QGraphicsSceneHoverEvent *) {}
*/
void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
{
hovered_ = false;
m_hovered = false;
update();
}
@@ -582,11 +563,11 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
//setCursor(Qt::CrossCursor);
// d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
if (previous_terminal_) {
if (previous_terminal_ == this) hovered_ = true;
else previous_terminal_ -> hovered_ = false;
previous_terminal_ -> hovered_color_ = previous_terminal_ -> neutralColor;
previous_terminal_ -> update();
if (m_previous_terminal) {
if (m_previous_terminal == this) m_hovered = true;
else m_previous_terminal -> m_hovered = false;
m_previous_terminal -> m_hovered_color = m_previous_terminal -> neutralColor;
m_previous_terminal -> update();
}
Diagram *diag = diagram();
@@ -613,18 +594,18 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
// si le qgi est une borne...
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
if (!other_terminal) return;
previous_terminal_ = other_terminal;
m_previous_terminal = other_terminal;
// s'il s'agit d'une borne, on lui applique l'effet hover approprie
if (!canBeLinkedTo(other_terminal)) {
other_terminal -> hovered_color_ = forbiddenColor;
other_terminal -> m_hovered_color = forbiddenColor;
} else if (other_terminal -> conductorsCount()) {
other_terminal -> hovered_color_ = warningColor;
other_terminal -> m_hovered_color = warningColor;
} else {
other_terminal -> hovered_color_ = allowedColor;
other_terminal -> m_hovered_color = allowedColor;
}
other_terminal -> hovered_ = true;
other_terminal -> m_hovered = true;
other_terminal -> update();
}
@@ -635,8 +616,8 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
*/
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{
previous_terminal_ = nullptr;
hovered_color_ = neutralColor;
m_previous_terminal = nullptr;
m_hovered_color = neutralColor;
if (!diagram()) return;
@@ -651,8 +632,8 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
if (!other_terminal) return;
other_terminal -> hovered_color_ = neutralColor;
other_terminal -> hovered_ = false;
other_terminal -> m_hovered_color = neutralColor;
other_terminal -> m_hovered = false;
//We stop her if we can't link this terminal with other terminal
if (!canBeLinkedTo(other_terminal)) return;
@@ -679,7 +660,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
QUndoCommand *undo = new QUndoCommand();
QUndoCommand *aic = new AddItemCommand<Conductor *>(new_conductor, diagram(), QPointF(), undo);
QUndoCommand *aic = new AddGraphicsObjectCommand(new_conductor, diagram(), QPointF(), undo);
undo->setText(aic->text());
if (use_properties)
@@ -709,7 +690,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
*/
void Terminal::updateConductor()
{
foreach (Conductor *conductor, conductors_)
foreach (Conductor *conductor, m_conductors_list)
conductor->updatePath();
}
@@ -722,7 +703,7 @@ bool Terminal::isLinkedTo(Terminal *other_terminal) {
if (other_terminal == this) return(false);
bool already_linked = false;
foreach (Conductor *c, conductors_) {
foreach (Conductor *c, m_conductors_list) {
if (c -> terminal1 == other_terminal || c -> terminal2 == other_terminal) {
already_linked = true;
break;
@@ -759,7 +740,7 @@ void Terminal::setID(int id) {
*/
QList<Conductor *> Terminal::conductors() const
{
return(conductors_);
return(m_conductors_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
@@ -17,6 +17,8 @@
*/
#ifndef TERMINAL_H
#define TERMINAL_H
#include "../qet.h"
#include <QtWidgets>
#include <QtXml>
#include "qet.h"
@@ -86,10 +88,6 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
QList<Conductor *> conductors() const;
Qet::Orientation orientation() const;
QPointF dockConductor() const;
QString number() const;
QString name() const;
void setNumber(QString number);
void setName(QString name, bool hiddenName);
void updateConductor();
bool isLinkedTo(Terminal *);
bool canBeLinkedTo(Terminal *);
@@ -165,9 +163,8 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
int m_id{-1};
private:
void init(QString number, QString name, bool hiddenName);
void init(QPointF pf, Qet::Orientation o, QString number,
QString name, bool hiddenName);
void init();
void init(QPointF pf, Qet::Orientation o);
};
/**
@@ -176,7 +173,7 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
*/
inline int Terminal::conductorsCount() const
{
return(conductors_.size());
return(m_conductors_list.size());
}
/**

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