QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
dynamicelementtextitem.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef DYNAMICELEMENTTEXTITEM_H
19#define DYNAMICELEMENTTEXTITEM_H
20
21#include "../properties/xrefproperties.h"
22#include "diagramtextitem.h"
23#include "element.h"
24
25#include <QPointer>
26#include <QUuid>
27
28class Element;
29class Conductor;
31class CrossRefItem;
32
40{
43 friend class Element;
44
45 Q_OBJECT
46
47 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
49 Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
51 Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
52 Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
54
55 public:
56
62 Q_ENUM (TextFrom)
63 enum {Type = UserType + 1010};
64 int type() const override {return Type;}
65
66 signals:
67 void textChanged(QString text);
69 void infoNameChanged(QString info);
71 void frameChanged(bool frame);
73 void textWidthChanged(qreal width);
75
76 public:
77 DynamicElementTextItem(Element *parent_element);
78 ~DynamicElementTextItem() override;
79 static QMetaEnum textFromMetaEnum();
80 private:
83
84 public:
85 QDomElement toXml(QDomDocument &dom_doc) const override;
86 void fromXml(const QDomElement &dom_elmt) override;
87
88 Element *parentElement() const;
92
95 QString text() const;
96 void setText(const QString &text);
97 static QString xmlTagName() {return QString("dynamic_elmt_text");}
98 void setInfoName(const QString &info_name);
99 QString infoName() const;
100 void setCompositeText(const QString &text);
101 QString compositeText() const;
102 void setFrame(const bool frame);
103 bool frame() const;
104 QUuid uuid() const;
105 void updateXref();
106 void setPlainText(const QString &text);
107 void setTextWidth(qreal width);
108 void setXref_item(Qt::AlignmentFlag m_exHrefPos);
109
110 void setKeepVisualRotation(bool set);
111 bool keepVisualRotation() const;
112
113 protected:
114 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
115 void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
116 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
117 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
118 void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
119 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
120 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
121 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
122 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
123
124 private:
125 void elementInfoChanged();
126 void masterChanged();
127 void reportChanged();
129 void setConnectionForReportFormula(const QString &formula);
130 void removeConnectionForReportFormula(const QString &formula);
134 void updateReportText();
135 void updateLabel();
136 void conductorWasAdded(Conductor *conductor);
137 void conductorWasRemoved(Conductor *conductor);
140 QString reportReplacedCompositeText() const;
141 void zoomToLinkedElement();
143 void thisRotationChanged();
144
145 private:
146 QPointer <Element>
150 QPointer <Conductor> m_watched_conductor;
151 QString
158 QUuid m_uuid;
159 QMetaObject::Connection m_report_formula_con;
160 QList<QMetaObject::Connection>
164 bool
165 m_frame = false,
168 QGraphicsTextItem *m_slave_Xref_item = nullptr;
169 qreal m_text_width = -1;
173};
174
175#endif // DYNAMICELEMENTTEXTITEM_H
The CompositeTextEditDialog class CompositeTextEditDialog display a dialog use to write the complex t...
Definition compositetexteditdialog.h:20
Definition conductor.h:43
The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts lin...
Definition crossrefitem.h:47
Definition diagramtextitem.h:34
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition dynamicelementtextitem.h:40
void textFromChanged(DynamicElementTextItem::TextFrom text_from)
void textChanged(QString text)
void parentElementRotationChanged()
DynamicElementTextItem::parentElementRotationChanged Called when the parent element is rotated.
Definition dynamicelementtextitem.cpp:1261
qreal m_text_width
Definition dynamicelementtextitem.h:169
QString text
Definition dynamicelementtextitem.h:47
void keepVisualRotationChanged(bool keep)
void clearFormulaConnection()
Definition dynamicelementtextitem.cpp:1001
void setConnectionForReportFormula(const QString &formula)
Definition dynamicelementtextitem.cpp:904
void setupFormulaConnection()
DynamicElementTextItem::setupFormulaConnection Setup the required connection for the formula of the l...
Definition dynamicelementtextitem.cpp:963
void setInfoName(const QString &info_name)
DynamicElementTextItem::setInfoName Set the information name of the parent element.
Definition dynamicelementtextitem.cpp:409
QString m_composite_text
Definition dynamicelementtextitem.h:154
bool m_keep_visual_rotation
Definition dynamicelementtextitem.h:171
void setPotentialConductor()
DynamicElementTextItem::setPotentialConductor This function is only used when the parent element of t...
Definition dynamicelementtextitem.cpp:1104
Element * parentElement() const
DynamicElementTextItem::ParentElement.
Definition dynamicelementtextitem.cpp:231
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
DynamicElementTextItem::hoverLeaveEvent.
Definition dynamicelementtextitem.cpp:648
void updateReportText()
DynamicElementTextItem::updateReportText This function is only use when this text is owned by a repor...
Definition dynamicelementtextitem.cpp:1022
QList< QMetaObject::Connection > m_update_slave_Xref_connection
Definition dynamicelementtextitem.h:162
Element * elementUseForInfo() const
DynamicElementTextItem::elementUseForInfo.
Definition dynamicelementtextitem.cpp:263
QString m_report_formula
Definition dynamicelementtextitem.h:155
QPointer< Conductor > m_watched_conductor
Definition dynamicelementtextitem.h:150
void removeConnectionForReportFormula(const QString &formula)
Definition dynamicelementtextitem.cpp:933
static QMetaEnum textFromMetaEnum()
DynamicElementTextItem::textFromMetaEnum.
Definition dynamicelementtextitem.cpp:74
void setCompositeText(const QString &text)
DynamicElementTextItem::setCompositeText Set the composite text of this text item to text.
Definition dynamicelementtextitem.cpp:464
QString m_info_name
Definition dynamicelementtextitem.h:153
QMetaObject::Connection m_report_formula_con
Definition dynamicelementtextitem.h:159
QUuid uuid() const
Definition dynamicelementtextitem.cpp:528
DynamicElementTextItem()
Definition dynamicelementtextitem.cpp:80
TextFrom textFrom
Definition dynamicelementtextitem.h:48
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition dynamicelementtextitem.cpp:660
QString m_F_str
Definition dynamicelementtextitem.h:156
int type() const override
Definition dynamicelementtextitem.h:64
bool frame
Definition dynamicelementtextitem.h:51
QString reportReplacedCompositeText() const
DynamicElementTextItem::reportReplacedCompositeText This function is only used when the parent elemen...
Definition dynamicelementtextitem.cpp:1180
QList< QMetaObject::Connection > m_formula_connection
Definition dynamicelementtextitem.h:161
QPointF m_initial_position
Definition dynamicelementtextitem.h:170
QGraphicsTextItem * m_slave_Xref_item
Definition dynamicelementtextitem.h:168
QString m_text
Definition dynamicelementtextitem.h:152
void conductorWasAdded(Conductor *conductor)
DynamicElementTextItem::conductorWasAdded Function only use when parent element is a folio report.
Definition dynamicelementtextitem.cpp:1078
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mousePressEvent.
Definition dynamicelementtextitem.cpp:537
QString infoName
Definition dynamicelementtextitem.h:49
void textWidthChanged(qreal width)
void compositeTextChanged(QString text)
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mouseMoveEvent.
Definition dynamicelementtextitem.cpp:556
DynamicElementTextItem(const DynamicElementTextItem &)
qreal m_visual_rotation_ref
Definition dynamicelementtextitem.h:172
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
DynamicElementTextItem::hoverEnterEvent If the parent element of this text is a folio report or a sla...
Definition dynamicelementtextitem.cpp:624
void refreshLabelConnection()
DynamicElementTextItem::refreshLabelConnection Refresh the connection of this text when the source of...
Definition dynamicelementtextitem.cpp:300
@ Type
Definition dynamicelementtextitem.h:63
static QString xmlTagName()
Definition dynamicelementtextitem.h:97
void thisRotationChanged()
DynamicElementTextItem::thisRotationChanged This function is called when user change the rotation of ...
Definition dynamicelementtextitem.cpp:1279
bool keepVisualRotation
Definition dynamicelementtextitem.h:53
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mouseReleaseEvent.
Definition dynamicelementtextitem.cpp:592
void setTextFrom(DynamicElementTextItem::TextFrom text_from)
DynamicElementTextItem::setTextFrom Set the final text is created from.
Definition dynamicelementtextitem.cpp:332
void elementInfoChanged()
Definition dynamicelementtextitem.cpp:775
QString compositeText
Definition dynamicelementtextitem.h:50
void conductorPropertiesChanged()
DynamicElementTextItem::conductorPropertiesChanged This function is only used when the parent element...
Definition dynamicelementtextitem.cpp:1153
QDomElement toXml(QDomDocument &dom_doc) const override
DynamicElementTextItem::toXml Export this text to xml.
Definition dynamicelementtextitem.cpp:89
void setPlainText(const QString &text)
Definition dynamicelementtextitem.cpp:1359
DynamicElementTextItem::TextFrom m_text_from
Definition dynamicelementtextitem.h:157
void setTextWidth(qreal width)
Definition dynamicelementtextitem.cpp:1406
void fromXml(const QDomElement &dom_elmt) override
DynamicElementTextItem::fromXml Import this text from xml.
Definition dynamicelementtextitem.cpp:157
QPointer< Element > m_master_element
Definition dynamicelementtextitem.h:148
void infoNameChanged(QString info)
void updateReportFormulaConnection()
Definition dynamicelementtextitem.cpp:1008
QUuid m_uuid
Definition dynamicelementtextitem.h:158
bool m_frame
Definition dynamicelementtextitem.h:165
void updateLabel()
DynamicElementTextItem::updateLabel Update the displayed text, when this dynamic text is based on the...
Definition dynamicelementtextitem.cpp:1052
void setFrame(const bool frame)
Definition dynamicelementtextitem.cpp:516
TextFrom
Definition dynamicelementtextitem.h:57
@ CompositeText
Definition dynamicelementtextitem.h:60
@ ElementInfo
Definition dynamicelementtextitem.h:59
@ UserText
Definition dynamicelementtextitem.h:58
void setKeepVisualRotation(bool set)
Definition dynamicelementtextitem.cpp:1458
void masterChanged()
DynamicElementTextItem::masterChanged This function is only use when the parent element is a slave....
Definition dynamicelementtextitem.cpp:823
CrossRefItem * m_Xref_item
Definition dynamicelementtextitem.h:167
bool m_first_scene_change
Definition dynamicelementtextitem.h:166
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
Definition dynamicelementtextitem.cpp:754
void frameChanged(bool frame)
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Definition dynamicelementtextitem.cpp:692
void setText(const QString &text)
DynamicElementTextItem::setText Set the text of this text.
Definition dynamicelementtextitem.cpp:396
~DynamicElementTextItem() override
Definition dynamicelementtextitem.cpp:67
void zoomToLinkedElement()
DynamicElementTextItem::zoomToLinkedElement If the parent element is a folio report or a slave elemen...
Definition dynamicelementtextitem.cpp:1216
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mouseDoubleClickEvent Reimplemented functions, for add extra feature when thi...
Definition dynamicelementtextitem.cpp:611
qreal textWidth
Definition dynamicelementtextitem.h:52
ElementTextItemGroup * parentGroup() const
DynamicElementTextItem::parentGroup.
Definition dynamicelementtextitem.cpp:241
void conductorWasRemoved(Conductor *conductor)
DynamicElementTextItem::conductorWasRemoved Function only use when parent element is a folio report.
Definition dynamicelementtextitem.cpp:1089
void reportFormulaChanged()
DynamicElementTextItem::reportFormulaChanged The report formula use in the project was changed.
Definition dynamicelementtextitem.cpp:896
void updateXref()
DynamicElementTextItem::updateXref Create or delete the Xref according to the current properties of t...
Definition dynamicelementtextitem.cpp:1287
QPointer< Element > m_parent_element
Definition dynamicelementtextitem.h:147
QPointer< Element > m_other_report
Definition dynamicelementtextitem.h:149
QColor m_user_color
Definition dynamicelementtextitem.h:163
void reportChanged()
DynamicElementTextItem::reportChanged This function is only use when parent element of this text is a...
Definition dynamicelementtextitem.cpp:851
void setXref_item(Qt::AlignmentFlag m_exHrefPos)
Definition dynamicelementtextitem.cpp:1413
Definition dynamicelementtextmodel.h:138
Definition element.h:43
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition elementtextitemgroup.h:36