QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
elementtextitemgroup.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 ELEMENTTEXTITEMGROUP_H
19#define ELEMENTTEXTITEMGROUP_H
20
21#include <QGraphicsItemGroup>
22#include <QObject>
23#include <QDomElement>
24
25class Element;
27class Diagram;
28class CrossRefItem;
29
35class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
36{
37 Q_OBJECT
38
39 Q_PROPERTY(QPointF pos READ pos WRITE setPos)
40 Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
42 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
43 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
45 Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
46
47 public:
48 signals:
49 void rotationChanged(qreal);
51 void alignmentChanged(Qt::Alignment);
52 void nameChanged(QString);
54 void xChanged();
55 void yChanged();
56 void frameChanged(bool frame);
57
58 public:
59 ElementTextItemGroup(const QString &name, Element *parent);
60 ~ElementTextItemGroup() override;
61 void addToGroup(QGraphicsItem *item);
62 void removeFromGroup(QGraphicsItem *item);
63 void blockAlignmentUpdate(bool block);
64
65 void setAlignment(Qt::Alignment alignement);
66 Qt::Alignment alignment() const;
67 void updateAlignment();
69 void setVerticalAdjustment(int v);
70 void setName(QString name);
71 QString name() const {return m_name;}
72 void setHoldToBottomPage(bool hold);
74 void setFrame(const bool frame);
75 bool frame() const;
76 QList<DynamicElementTextItem *> texts() const;
77 Diagram *diagram() const;
78 Element *parentElement() const;
79
80 QDomElement toXml(QDomDocument &dom_document) const;
81 void fromXml(QDomElement &dom_element);
82 static QString xmlTaggName() {return QString("texts_group");}
83
84 void paint(QPainter *painter,
85 const QStyleOptionGraphicsItem *option,
86 QWidget *widget) override;
87 QRectF boundingRect() const override;
88 void setRotation(qreal angle);
89 void setPos(const QPointF &pos);
90 void setPos(qreal x, qreal y);
91
92 protected:
93 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
94 void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
96 QGraphicsSceneMouseEvent *event) override;
98 QGraphicsSceneMouseEvent *event) override;
99 void keyPressEvent(QKeyEvent *event) override;
100 void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
101 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
102
103 private:
104 void updateXref();
105 void adjustSlaveXrefPos();
106 void autoPos();
107
108 private:
109 Qt::Alignment m_alignment = Qt::AlignJustify;
110 QString m_name;
111 bool m_first_move = true,
114 m_frame = false;
119 QList<QMetaObject::Connection> m_update_slave_Xref_connection;
120 QGraphicsTextItem *m_slave_Xref_item = nullptr;
121 QMetaObject::Connection m_XrefChanged_timer,
123};
124
125#endif // ELEMENTTEXTITEMGROUP_H
The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts lin...
Definition crossrefitem.h:47
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:56
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition dynamicelementtextitem.h:40
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
void setPos(const QPointF &pos)
Definition elementtextitemgroup.cpp:580
bool holdToBottomPage
Definition elementtextitemgroup.h:44
QList< DynamicElementTextItem * > texts() const
ElementTextItemGroup::texts.
Definition elementtextitemgroup.cpp:370
QPointF m_initial_position
Definition elementtextitemgroup.h:115
static QString xmlTaggName()
Definition elementtextitemgroup.h:82
int verticalAdjustment
Definition elementtextitemgroup.h:41
QGraphicsTextItem * m_slave_Xref_item
Definition elementtextitemgroup.h:120
void setAlignment(Qt::Alignment alignement)
ElementTextItemGroup::setAlignement Set the alignement of this group.
Definition elementtextitemgroup.cpp:166
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
Definition elementtextitemgroup.cpp:736
Element * parentElement() const
ElementTextItemGroup::parentElement.
Definition elementtextitemgroup.cpp:397
void setVerticalAdjustment(int v)
ElementTextItemGroup::setVerticalAdjustment Set the value of the vertical adjustment to v....
Definition elementtextitemgroup.cpp:278
void updateAlignment()
ElementTextItemGroup::setAlignment Update the alignement of the items in this group,...
Definition elementtextitemgroup.cpp:184
QRectF boundingRect() const override
ElementTextItemGroup::boundingRect.
Definition elementtextitemgroup.cpp:557
void setFrame(const bool frame)
Definition elementtextitemgroup.cpp:354
void alignmentChanged(Qt::Alignment)
QPointF pos
Definition elementtextitemgroup.h:39
Element * m_parent_element
Definition elementtextitemgroup.h:118
Qt::Alignment alignment
Definition elementtextitemgroup.h:42
QMetaObject::Connection m_XrefChanged_timer
Definition elementtextitemgroup.h:121
void setRotation(qreal angle)
Definition elementtextitemgroup.cpp:574
QList< QMetaObject::Connection > m_update_slave_Xref_connection
Definition elementtextitemgroup.h:119
QDomElement toXml(QDomDocument &dom_document) const
ElementTextItemGroup::toXml Export data of this group to xml.
Definition elementtextitemgroup.cpp:411
void frameChanged(bool frame)
QString m_name
Definition elementtextitemgroup.h:110
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
ElementTextItemGroup::mousePressEvent.
Definition elementtextitemgroup.cpp:604
CrossRefItem * m_Xref_item
Definition elementtextitemgroup.h:117
void rotationChanged(qreal)
void blockAlignmentUpdate(bool block)
ElementTextItemGroup::blockAlignmentUpdate If true, the texts in this group are never aligned,...
Definition elementtextitemgroup.cpp:156
void autoPos()
Definition elementtextitemgroup.cpp:844
Qt::Alignment m_alignment
Definition elementtextitemgroup.h:109
void setHoldToBottomPage(bool hold)
Definition elementtextitemgroup.cpp:296
QString name
Definition elementtextitemgroup.h:43
void fromXml(QDomElement &dom_element)
ElementTextItemGroup::fromXml Import data of this group from xml.
Definition elementtextitemgroup.cpp:446
Diagram * diagram() const
ElementTextItemGroup::diagram.
Definition elementtextitemgroup.cpp:385
void addToGroup(QGraphicsItem *item)
ElementTextItemGroup::addToGroup.
Definition elementtextitemgroup.cpp:71
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
ElementTextItemGroup::mouseReleaseEvent.
Definition elementtextitemgroup.cpp:657
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
Definition elementtextitemgroup.cpp:747
void setName(QString name)
ElementTextItemGroup::setName.
Definition elementtextitemgroup.cpp:290
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
ElementTextItemGroup::mouseMoveEvent.
Definition elementtextitemgroup.cpp:620
void holdToBottomPageChanged(bool)
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition elementtextitemgroup.cpp:670
qreal rotation
Definition elementtextitemgroup.h:40
bool m_hold_to_bottom_of_page
Definition elementtextitemgroup.h:112
void keyPressEvent(QKeyEvent *event) override
ElementTextItemGroup::keyPressEvent.
Definition elementtextitemgroup.cpp:707
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
ElementTextItemGroup::paint.
Definition elementtextitemgroup.cpp:501
bool holdToBottomPage() const
Definition elementtextitemgroup.h:73
bool m_block_alignment_update
Definition elementtextitemgroup.h:113
void nameChanged(QString)
bool m_frame
Definition elementtextitemgroup.h:114
bool m_first_move
Definition elementtextitemgroup.h:111
void verticalAdjustmentChanged(int)
void removeFromGroup(QGraphicsItem *item)
ElementTextItemGroup::removeFromGroup.
Definition elementtextitemgroup.cpp:111
int m_vertical_adjustment
Definition elementtextitemgroup.h:116
QMetaObject::Connection m_linked_changed_timer
Definition elementtextitemgroup.h:122
QString name() const
Definition elementtextitemgroup.h:71
void updateXref()
Definition elementtextitemgroup.cpp:755
void adjustSlaveXrefPos()
Definition elementtextitemgroup.cpp:836
bool frame
Definition elementtextitemgroup.h:45