GobChartsWidget  1.0
gobchartstextitem.h
1 /* Copyright (C) 2012 by William Hallatt.
2  *
3  * This file forms part of the "GobChartsWidget" library.
4  *
5  * This library 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 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This library 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 downloaded a copy of the GNU General Public License
16  * (GNUGPL.txt) and GNU Lesser General Public License (GNULGPL.txt)
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * The official website for this project is www.goblincoding.com and,
20  * although not compulsory, it would be appreciated if all works of whatever
21  * nature referring to or using this library include a reference to this site.
22  */
23 
24 #ifndef GOBCHARTSTEXTITEM_H
25 #define GOBCHARTSTEXTITEM_H
26 
27 #include <QGraphicsTextItem>
28 #include "utils/gobchartsnocopy.h"
29 
30 class QTextDocument;
31 class QDomNode;
32 
34 
38 class GobChartsTextItem : public QGraphicsTextItem,
39  public GobChartsNoCopy
40 {
41  Q_OBJECT
42 
43 public:
45  explicit GobChartsTextItem( Qt::Orientation orientation, QString uniqueID, QGraphicsItem *parent = 0 );
46 
50  void setMaxFontSize( const QFont &font );
51 
54  void setAlignment( Qt::Alignment alignment );
55 
58  Qt::Alignment alignment() const;
59 
61  void receiveKeyEvent( QKeyEvent *event );
62 
67  QString getStateXML() const;
68 
73  bool setStateXML( const QDomNode &node );
74 
76  void setPlainText( const QString &text );
77 
78 public slots:
83  void setRectF( const QRectF &rect );
84 
85 signals:
87  void identity( const QString& );
88 
89 protected:
91  void mousePressEvent( QGraphicsSceneMouseEvent *event );
92 
94  void setFont( const QFont &font );
95 
96 private slots:
97  void resize();
98 
99 private:
100  Qt::Orientation m_orientation;
101  Qt::Alignment m_alignment;
102  QTextDocument *m_textDocument;
103  QString m_identity;
104  QRectF m_rectF;
105  bool m_busyResizing;
106  int m_maxFontSize;
107 };
108 
109 #endif // GOBCHARTSTEXTITEM_H