QElectroTech  0.70
dynamicelementtextitem.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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 "diagramtextitem.h"
22 #include "element.h"
23 #include <QUuid>
24 #include <QPointer>
25 
26 class Element;
27 class Conductor;
29 class CrossRefItem;
30 
38 {
41  friend class Element;
42 
43  Q_OBJECT
44 
45  Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
46  Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
47  Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
48  Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
49  Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
50  Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
51 
52  public:
53 
54  enum TextFrom {
58  };
59  Q_ENUM (TextFrom)
60  enum {Type = UserType + 1010};
61  int type() const override {return Type;}
62 
63  signals:
64  void textChanged(QString text);
66  void infoNameChanged(QString info);
67  void compositeTextChanged(QString text);
68  void frameChanged(bool frame);
69  void plainTextChanged();
70  void textWidthChanged(qreal width);
71 
72  public:
73  DynamicElementTextItem(Element *parent_element);
74  ~DynamicElementTextItem() override;
75  static QMetaEnum textFromMetaEnum();
76  private:
79 
80  public:
81  QDomElement toXml(QDomDocument &dom_doc) const override;
82  void fromXml(const QDomElement &dom_elmt) override;
83 
84  Element *parentElement() const;
86  Element *elementUseForInfo() const;
88 
91  QString text() const;
92  void setText(const QString &text);
93  static QString xmlTaggName() {return QString("dynamic_elmt_text");}
94  void setInfoName(const QString &info_name);
95  QString infoName() const;
96  void setCompositeText(const QString &text);
97  QString compositeText() const;
98  void setFrame(const bool frame);
99  bool frame() const;
100  QUuid uuid() const;
101  void updateXref();
102  void setPlainText(const QString &text);
103  void setTextWidth(qreal width);
104 
105  protected:
106  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
107  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
108  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
109  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
110  void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
111  void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
112  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
113  QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
114  bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
115 
116  private:
117  void elementInfoChanged();
118  void masterChanged();
119  void reportChanged();
120  void reportFormulaChanged();
121  void setConnectionForReportFormula(const QString &formula);
122  void removeConnectionForReportFormula(const QString &formula);
123  void setupFormulaConnection();
124  void clearFormulaConnection();
126  void updateReportText();
127  void updateLabel();
128  void conductorWasAdded(Conductor *conductor);
129  void conductorWasRemoved(Conductor *conductor);
130  void setPotentialConductor();
132  QString reportReplacedCompositeText() const;
133  void zoomToLinkedElement();
134 
135 
136  private:
137  QPointer <Element> m_parent_element,
140  QPointer <Conductor> m_watched_conductor;
141  QString m_text,
142  m_info_name,
145  m_F_str;
147  QUuid m_uuid;
148  QMetaObject::Connection m_report_formula_con;
149  QList<QMetaObject::Connection> m_formula_connection,
151  QColor m_user_color;
152  bool m_frame = false,
155  QGraphicsTextItem *m_slave_Xref_item = nullptr;
156  qreal m_text_width = -1;
158 };
159 
160 #endif // DYNAMICELEMENTTEXTITEM_H
The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts lin...
Definition: crossrefitem.h:40
void refreshLabelConnection()
DynamicElementTextItem::refreshLabelConnection Refresh the connection of this text when the source of...
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
ElementTextItemGroup * parentGroup() const
DynamicElementTextItem::parentGroup.
QPointer< Conductor > m_watched_conductor
The CompositeTextEditDialog class CompositeTextEditDialog display a dialog use to write the complex t...
QString infoName() const
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
QMetaObject::Connection m_report_formula_con
QList< QMetaObject::Connection > m_formula_connection
void textFromChanged(DynamicElementTextItem::TextFrom text_from)
void setPotentialConductor()
DynamicElementTextItem::setPotentialConductor This function is only used when the parent element of t...
void conductorWasAdded(Conductor *conductor)
DynamicElementTextItem::conductorWasAdded Function only use when parent element is a folio report...
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
DynamicElementTextItem::hoverLeaveEvent.
void setCompositeText(const QString &text)
DynamicElementTextItem::setCompositeText Set the composite text of this text item to ...
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mouseMoveEvent.
QGraphicsTextItem * m_slave_Xref_item
void setPlainText(const QString &text)
void reportFormulaChanged()
DynamicElementTextItem::reportFormulaChanged The report formula use in the project was changed...
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Element * elementUseForInfo() const
DynamicElementTextItem::elementUseForInfo.
QDomElement toXml(QDomDocument &dom_doc) const override
DynamicElementTextItem::toXml Export this text to xml.
void frameChanged(bool frame)
void setFrame(const bool frame)
void reportChanged()
DynamicElementTextItem::reportChanged This function is only use when parent element of this text is a...
void masterChanged()
DynamicElementTextItem::masterChanged This function is only use when the parent element is a slave...
void updateXref()
DynamicElementTextItem::updateXref Create or delete the Xref according to the current properties of t...
void updateReportText()
DynamicElementTextItem::updateReportText This function is only use when this text is owned by a repor...
void conductorWasRemoved(Conductor *conductor)
DynamicElementTextItem::conductorWasRemoved Function only use when parent element is a folio report...
QPointer< Element > m_parent_element
int type() const override
QPointer< Element > m_other_report
void conductorPropertiesChanged()
DynamicElementTextItem::conductorPropertiesChanged This function is only used when the parent element...
void setInfoName(const QString &info_name)
DynamicElementTextItem::setInfoName Set the information name of the parent element.
void zoomToLinkedElement()
DynamicElementTextItem::zoomToLinkedElement If the parent element is a folio report or a slave elemen...
QString compositeText() const
static QMetaEnum textFromMetaEnum()
DynamicElementTextItem::textFromMetaEnum.
QPointer< Element > m_master_element
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mouseDoubleClickEvent Reimplemented functions, for add extra feature when thi...
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mouseReleaseEvent.
void removeConnectionForReportFormula(const QString &formula)
Element * parentElement() const
DynamicElementTextItem::ParentElement.
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DynamicElementTextItem::mousePressEvent.
void setConnectionForReportFormula(const QString &formula)
void textWidthChanged(qreal width)
DynamicElementTextItem::TextFrom textFrom() const
void textChanged(QString text)
void setTextFrom(DynamicElementTextItem::TextFrom text_from)
DynamicElementTextItem::setTextFrom Set the final text is created from.
void infoNameChanged(QString info)
QString reportReplacedCompositeText() const
DynamicElementTextItem::reportReplacedCompositeText This function is only used when the parent elemen...
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
DynamicElementTextItem::hoverEnterEvent If the parent element of this text is a folio report or a sla...
void compositeTextChanged(QString text)
QString text() const
QList< QMetaObject::Connection > m_update_slave_Xref_connection
void fromXml(const QDomElement &dom_elmt) override
DynamicElementTextItem::fromXml Import this text from xml.
DynamicElementTextItem::TextFrom m_text_from
void setupFormulaConnection()
DynamicElementTextItem::setupFormulaConnection Setup the required connection for the formula of the l...
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void setText(const QString &text)
DynamicElementTextItem::setText Set the text of this text.
void updateLabel()
DynamicElementTextItem::updateLabel Update the displayed text, when this dynamic text is based on the...