mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-10 00:29:58 +02:00
Add initial support of texts group
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5117 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
73
sources/qetgraphicsitem/elementtextitemgroup.h
Normal file
73
sources/qetgraphicsitem/elementtextitemgroup.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright 2006-2017 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ELEMENTTEXTITEMGROUP_H
|
||||
#define ELEMENTTEXTITEMGROUP_H
|
||||
|
||||
#include <QGraphicsItemGroup>
|
||||
#include <QObject>
|
||||
#include <QDomElement>
|
||||
|
||||
class Element;
|
||||
class DynamicElementTextItem;
|
||||
class Diagram;
|
||||
|
||||
/**
|
||||
* @brief The ElementTextItemGroup class
|
||||
* This class represent a group of element text
|
||||
* Texts in the group can be aligned left / center /right
|
||||
*/
|
||||
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ElementTextItemGroup(const QString &name, Element *parent);
|
||||
~ElementTextItemGroup() override;
|
||||
void addToGroup(QGraphicsItem *item);
|
||||
void removeFromGroup(QGraphicsItem *item);
|
||||
|
||||
void setAlignement(Qt::Alignment alignement);
|
||||
Qt::Alignment alignment() const;
|
||||
void updateAlignement();
|
||||
void setName(QString name);
|
||||
QString name() const {return m_name;}
|
||||
QList<DynamicElementTextItem *> texts() const;
|
||||
Diagram *diagram() const;
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_document) const;
|
||||
void fromXml(QDomElement &dom_element);
|
||||
static QString xmlTaggName() {return QString("text_group");}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private:
|
||||
Qt::Alignment m_alignement = Qt::AlignJustify;
|
||||
QString m_name;
|
||||
bool m_first_move = true;
|
||||
QPointF m_mouse_to_origin_movement;
|
||||
Element *m_element = nullptr;
|
||||
};
|
||||
|
||||
#endif // ELEMENTTEXTITEMGROUP_H
|
||||
Reference in New Issue
Block a user