QElectroTech  0.8-dev
elementtextitemgroup.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 
25 class Element;
27 class Diagram;
28 class CrossRefItem;
29 
35 class 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;
95  void mouseReleaseEvent(
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
Element::linkType
virtual kind linkType() const
Definition: element.h:159
ElementTextItemGroup::m_first_move
bool m_first_move
Definition: elementtextitemgroup.h:111
Element::addTextToGroup
bool addTextToGroup(DynamicElementTextItem *text, ElementTextItemGroup *group)
Element::addTextToGroup Add the text text to the group group; If group isn't owned by this element re...
Definition: element.cpp:1432
DynamicElementTextItem
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition: dynamicelementtextitem.h:39
ElementTextsMover::continueMovement
void continueMovement(QGraphicsSceneMouseEvent *event)
Definition: elementtextsmover.cpp:82
CrossRefItem::autoPos
void autoPos()
CrossRefItem::autoPos Calculate and set position automaticaly.
Definition: crossrefitem.cpp:235
QETProject::projectDiagramsOrderChanged
void projectDiagramsOrderChanged(QETProject *, int, int)
Element::linkedElements
QList< Element * > linkedElements()
Element::linkedElements.
Definition: element.h:258
ElementTextItemGroup::verticalAdjustment
int verticalAdjustment() const
Definition: elementtextitemgroup.h:68
ElementTextItemGroup::boundingRect
QRectF boundingRect() const override
ElementTextItemGroup::boundingRect.
Definition: elementtextitemgroup.cpp:503
ElementTextItemGroup::holdToBottomPageChanged
void holdToBottomPageChanged(bool)
QetGraphicsItem::diagram
Diagram * diagram() const
Definition: qetgraphicsitem.cpp:40
ElementTextItemGroup::mouseDoubleClickEvent
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition: elementtextitemgroup.cpp:614
ElementTextItemGroup::m_block_alignment_update
bool m_block_alignment_update
Definition: elementtextitemgroup.h:113
ElementTextItemGroup::pos
QPointF pos
Definition: elementtextitemgroup.h:39
ElementTextItemGroup::parentElement
Element * parentElement() const
ElementTextItemGroup::parentElement.
Definition: elementtextitemgroup.cpp:357
Diagram::elementTextsMover
ElementTextsMover & elementTextsMover()
Diagram::elementTextsMover.
Definition: diagram.cpp:2065
ElementTextItemGroup::verticalAdjustment
int verticalAdjustment
Definition: elementtextitemgroup.h:41
ElementTextItemGroup::~ElementTextItemGroup
~ElementTextItemGroup() override
Definition: elementtextitemgroup.cpp:63
ElementTextItemGroup::adjustSlaveXrefPos
void adjustSlaveXrefPos()
Definition: elementtextitemgroup.cpp:779
Element::setHighlighted
virtual void setHighlighted(bool)
Definition: element.cpp:178
QETProject::diagramRemoved
void diagramRemoved(QETProject *, Diagram *)
Diagram::showMe
void showMe()
Definition: diagram.h:161
elementtextitemgroup.h
ElementTextItemGroup::fromXml
void fromXml(QDomElement &dom_element)
ElementTextItemGroup::fromXml Import data of this group from xml.
Definition: elementtextitemgroup.cpp:405
ElementTextItemGroup::setName
void setName(QString name)
ElementTextItemGroup::setName.
Definition: elementtextitemgroup.cpp:268
ElementTextItemGroup::updateAlignment
void updateAlignment()
ElementTextItemGroup::setAlignment Update the alignement of the items in this group,...
Definition: elementtextitemgroup.cpp:162
Element::elementInfoChange
void elementInfoChange(DiagramContext old_info, DiagramContext new_info)
Element::linkedElementChanged
void linkedElementChanged()
ElementTextItemGroup::xmlTaggName
static QString xmlTaggName()
Definition: elementtextitemgroup.h:82
centerToBottomDiagram
bool centerToBottomDiagram(QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset)
centerToBottomDiagram Set item pos to the bottom of diagram and centered vertically to element_to_fol...
Definition: qgraphicsitemutility.cpp:54
DynamicElementTextItem::compositeTextChanged
void compositeTextChanged(QString text)
Element::Slave
@ Slave
Definition: element.h:56
Element::Type
@ Type
Definition: element.h:74
addelementtextcommand.h
QET::findInDomElement
QList< QDomElement > findInDomElement(const QDomElement &, const QString &)
Definition: qet.cpp:333
XRefProperties::Label
@ Label
Definition: xrefproperties.h:40
ElementTextItemGroup::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
ElementTextItemGroup::mouseReleaseEvent.
Definition: elementtextitemgroup.cpp:601
DynamicElementTextItem::plainTextChanged
void plainTextChanged()
Diagram::project
QETProject * project() const
Diagram::project.
Definition: diagram.cpp:2326
qetapp.h
ElementTextItemGroup::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
ElementTextItemGroup::paint.
Definition: elementtextitemgroup.cpp:451
ElementTextItemGroup::alignment
Qt::Alignment alignment
Definition: elementtextitemgroup.h:42
ElementTextItemGroup::m_alignment
Qt::Alignment m_alignment
Definition: elementtextitemgroup.h:109
ElementTextItemGroup::m_hold_to_bottom_of_page
bool m_hold_to_bottom_of_page
Definition: elementtextitemgroup.h:112
XRefProperties::offset
int offset() const
Definition: xrefproperties.h:76
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
DynamicElementTextItem::Type
@ Type
Definition: dynamicelementtextitem.h:61
ElementTextItemGroup::holdToBottomPage
bool holdToBottomPage
Definition: elementtextitemgroup.h:44
XRefProperties
The XRefProperties class this class store properties used by XrefItem.
Definition: xrefproperties.h:29
ElementTextItemGroup::frameChanged
void frameChanged(bool frame)
ElementTextItemGroup::m_linked_changed_timer
QMetaObject::Connection m_linked_changed_timer
Definition: elementtextitemgroup.h:122
Element::kindInformations
DiagramContext kindInformations() const
Definition: element.h:100
ElementTextsMover::beginMovement
int beginMovement(Diagram *diagram, QGraphicsItem *driver_item=nullptr)
ElementTextsMover::beginMovement Begin a movement.
Definition: elementtextsmover.cpp:46
DynamicElementTextItem::textWidthChanged
void textWidthChanged(qreal width)
ElementTextItemGroup::setPos
void setPos(const QPointF &pos)
Definition: elementtextitemgroup.cpp:525
XRefProperties::slaveLabel
QString slaveLabel() const
Definition: xrefproperties.h:73
ElementTextsMover::endMovement
void endMovement()
ElementTextsMover::endMovement Finish the movement by pushing an undo command to the parent diagram o...
Definition: elementtextsmover.cpp:107
ElementTextItemGroup::setRotation
void setRotation(qreal angle)
Definition: elementtextitemgroup.cpp:519
ElementTextItemGroup::yChanged
void yChanged()
ElementTextItemGroup::m_parent_element
Element * m_parent_element
Definition: elementtextitemgroup.h:118
ElementTextItemGroup::toXml
QDomElement toXml(QDomDocument &dom_document) const
ElementTextItemGroup::toXml Export data of this group to xml.
Definition: elementtextitemgroup.cpp:371
Element::Master
@ Master
Definition: element.h:55
ElementTextItemGroup::texts
QList< DynamicElementTextItem * > texts() const
ElementTextItemGroup::texts.
Definition: elementtextitemgroup.cpp:330
crossrefitem.h
ElementTextItemGroup::ElementTextItemGroup
ElementTextItemGroup(const QString &name, Element *parent)
ElementTextItemGroup::ElementTextItemGroup.
Definition: elementtextitemgroup.cpp:49
DiagramTextItem::fontChanged
void fontChanged(QFont font)
DynamicElementTextItem::textFromChanged
void textFromChanged(DynamicElementTextItem::TextFrom text_from)
element.h
ElementTextItemGroup::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
ElementTextItemGroup::keyPressEvent.
Definition: elementtextitemgroup.cpp:650
DynamicElementTextItem::CompositeText
@ CompositeText
Definition: dynamicelementtextitem.h:58
qpropertyundocommand.h
AlignmentTextsGroupCommand
The AlignmentTextsGroupCommand class.
Definition: addelementtextcommand.h:145
ElementTextItemGroup::removeFromGroup
void removeFromGroup(QGraphicsItem *item)
ElementTextItemGroup::removeFromGroup.
Definition: elementtextitemgroup.cpp:101
ElementTextItemGroup::mouseMoveEvent
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
ElementTextItemGroup::mouseMoveEvent.
Definition: elementtextitemgroup.cpp:565
ElementTextItemGroup::nameChanged
void nameChanged(QString)
sorting
bool sorting(QGraphicsItem *qgia, QGraphicsItem *qgib)
sorting
Definition: elementtextitemgroup.cpp:39
Element
Definition: element.h:41
Diagram::undoStack
QUndoStack & undoStack()
Diagram::undoStack.
Definition: diagram.h:397
ElementTextItemGroup::alignmentChanged
void alignmentChanged(Qt::Alignment)
ElementTextItemGroup::m_vertical_adjustment
int m_vertical_adjustment
Definition: elementtextitemgroup.h:116
MasterElement
The MasterElement class This class is a custom element, with extended behavior to be a master element...
Definition: masterelement.h:32
autonum::AssignVariables::formulaToLabel
static QString formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
AssignVariables::formulaToLabel Return the formula with variable assigned (ready to be displayed)
Definition: assignvariables.cpp:187
ElementTextItemGroup::m_Xref_item
CrossRefItem * m_Xref_item
Definition: elementtextitemgroup.h:117
DynamicElementTextItem::infoNameChanged
void infoNameChanged(QString info)
ElementTextItemGroup::setFrame
void setFrame(const bool frame)
Definition: elementtextitemgroup.cpp:315
ElementTextItemGroup::name
QString name() const
Definition: elementtextitemgroup.h:71
ElementTextItemGroup::addToGroup
void addToGroup(QGraphicsItem *item)
ElementTextItemGroup::addToGroup.
Definition: elementtextitemgroup.cpp:70
ElementTextItemGroup::m_initial_position
QPointF m_initial_position
Definition: elementtextitemgroup.h:115
ElementTextItemGroup::holdToBottomPage
bool holdToBottomPage() const
Definition: elementtextitemgroup.h:73
ElementTextItemGroup::autoPos
void autoPos()
Definition: elementtextitemgroup.cpp:787
ElementTextItemGroup::m_update_slave_Xref_connection
QList< QMetaObject::Connection > m_update_slave_Xref_connection
Definition: elementtextitemgroup.h:119
QETProject
Definition: qetproject.h:51
ElementTextItemGroup::xChanged
void xChanged()
ElementTextItemGroup::setAlignment
void setAlignment(Qt::Alignment alignement)
ElementTextItemGroup::setAlignement Set the alignement of this group.
Definition: elementtextitemgroup.cpp:144
ElementTextItemGroup
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition: elementtextitemgroup.h:36
ElementTextItemGroup::m_name
QString m_name
Definition: elementtextitemgroup.h:110
ElementTextItemGroup::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
ElementTextItemGroup::mousePressEvent.
Definition: elementtextitemgroup.cpp:549
QET::Icons::ro
QIcon ro
Definition: qeticons.cpp:200
masterelement.h
ElementTextItemGroup::hoverLeaveEvent
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
Definition: elementtextitemgroup.cpp:690
ElementTextItemGroup::hoverEnterEvent
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
Definition: elementtextitemgroup.cpp:679
ElementTextItemGroup::updateXref
void updateXref()
Definition: elementtextitemgroup.cpp:698
Diagram::snapToGrid
static QPointF snapToGrid(const QPointF &p)
Diagram::snapToGrid Return a nearest snap point of p.
Definition: diagram.cpp:2240
QETApp::diagramTextsFont
static QFont diagramTextsFont(qreal=-1.0)
QETApp::diagramTextsFont The font to use By default the font is "sans Serif" and size 9.
Definition: qetapp.cpp:1111
XRefProperties::Bottom
@ Bottom
Definition: xrefproperties.h:39
ElementTextItemGroup::setHoldToBottomPage
void setHoldToBottomPage(bool hold)
Definition: elementtextitemgroup.cpp:274
ElementTextItemGroup::m_frame
bool m_frame
Definition: elementtextitemgroup.h:114
QETProject::XRefPropertiesChanged
void XRefPropertiesChanged()
ElementTextItemGroup::verticalAdjustmentChanged
void verticalAdjustmentChanged(int)
dynamicelementtextitem.h
ElementTextItemGroup::setVerticalAdjustment
void setVerticalAdjustment(int v)
ElementTextItemGroup::setVerticalAdjustment Set the value of the vertical adjustment to v....
Definition: elementtextitemgroup.cpp:256
ElementTextItemGroup::name
QString name
Definition: elementtextitemgroup.h:43
qgraphicsitemutility.h
MasterElement::XrefBoundingRect
QRectF XrefBoundingRect() const
MasterElement::XrefBoundingRect.
Definition: masterelement.cpp:118
XRefProperties::snapTo
SnapTo snapTo() const
Definition: xrefproperties.h:62
Element::rSequenceStruct
autonum::sequentialNumbers & rSequenceStruct()
Definition: element.h:108
ElementTextItemGroup::m_XrefChanged_timer
QMetaObject::Connection m_XrefChanged_timer
Definition: elementtextitemgroup.h:121
ElementTextItemGroup::blockAlignmentUpdate
void blockAlignmentUpdate(bool block)
ElementTextItemGroup::blockAlignmentUpdate If true, the texts in this group are never aligned,...
Definition: elementtextitemgroup.cpp:134
ElementTextItemGroup::frame
bool frame
Definition: elementtextitemgroup.h:45
QETProject::defaultXRefProperties
XRefProperties defaultXRefProperties(const QString &type) const
Definition: qetproject.h:106
DynamicElementTextItem::ElementInfo
@ ElementInfo
Definition: dynamicelementtextitem.h:57
ElementTextItemGroup::diagram
Diagram * diagram() const
ElementTextItemGroup::diagram.
Definition: elementtextitemgroup.cpp:345
ElementTextItemGroup::m_slave_Xref_item
QGraphicsTextItem * m_slave_Xref_item
Definition: elementtextitemgroup.h:120
diagram.h
DynamicElementTextItem::textChanged
void textChanged(QString text)
CrossRefItem
The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts lin...
Definition: crossrefitem.h:47
ElementTextItemGroup::rotation
qreal rotation
Definition: elementtextitemgroup.h:40
ElementTextItemGroup::rotationChanged
void rotationChanged(qreal)