GobChartsWidget  1.0
gobchartsgraphitems.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 GOBCHARTSGRAPHITEMS_H
25 #define GOBCHARTSGRAPHITEMS_H
26 
27 #include <QObject>
28 #include <QMap>
29 #include <QModelIndex>
30 #include "utils/gobchartsnocopy.h"
31 
32 class QGraphicsScene;
33 class QGraphicsItem;
34 
36 
42 class GobChartsGraphItems : public QObject,
43  public GobChartsNoCopy
44 {
45  Q_OBJECT
46 
47 public:
49  explicit GobChartsGraphItems( QObject *parent = 0 );
50 
52  virtual ~GobChartsGraphItems();
53 
56  void addItemsToScene( QGraphicsScene *scene );
57 
60  void removeItemsFromScene( QGraphicsScene *scene );
61 
67  void setSelected( int categoryRow );
68 
71  void clearSelection();
72 
76  void addItem( const QModelIndex &valueIndex, QGraphicsItem *item, const QString &legendText );
77 
80  void deleteItems();
81 
83  QModelIndex getModelIndex( QGraphicsItem *item ) const;
84 
86  QModelIndex getModelIndex( const QString &text ) const;
87 
89  QRectF getItemRectF( const QModelIndex &index ) const;
90 
92  QRectF getItemRectF( const QString &text ) const;
93 
95  QString getItemLegend( QGraphicsItem *item ) const;
96 
99  void setDebugLoggingOn( bool logging );
100 
101 signals:
105  void lastDebugLogMsg( QString );
106 
107 private:
108  QMap< QModelIndex, QGraphicsItem* > m_graphItemMap;
109  QMap< QString, QGraphicsItem* > m_legendItemMap;
110  bool m_loggingOn;
111 };
112 
113 #endif // GOBCHARTSGRAPHITEMS_H