Quark  0.1
QuadTreeModelBase.h++
Go to the documentation of this file.
1 #ifndef __libquark_gui_QuadTreeModelBase_hxx
2 #define __libquark_gui_QuadTreeModelBase_hxx
3 
4 #include <QObject>
5 #include <QPoint>
6 #include <QRect>
7 
8 namespace quark {
9 namespace gui {
10 
17 class QuadTreeModelBase : public QObject
18 {
19  Q_OBJECT;
20 
21  public:
22 
24  virtual ~QuadTreeModelBase();
25 
27  QRect region() const
28  { return(_region); }
29 
31  uint itemCount() const
32  { return(_itemCount); }
33 
35  bool isEmpty() const
36  { return(_itemCount == 0); }
37 
48  bool setVisibleRegion(const QRect &visibleRegion);
49 
51  QRect visibleRegion() const
52  { return(_visibleRegion); }
53 
54  signals:
55 
57  void dataChanged();
58 
64  void itemAdded(const QPoint &location);
65 
71  void itemModified(const QPoint &location);
72 
78  void itemRemoved(const QPoint &location);
79 
80  protected:
81 
83  QuadTreeModelBase(const QRect &region, uint maxItemsPerQuad = 1);
84 
86  QRect _region;
88  uint _itemCount;
89 };
90 
91 } // namespace gui
92 } // namespace quark
93 
94 #endif // __libquark_gui_QuadTreeModelBase_hxx
bool isEmpty() const
Tests if the model is empty.
Definition: QuadTreeModelBase.h++:35
QRect _visibleRegion
Definition: QuadTreeModelBase.h++:87
bool setVisibleRegion(const QRect &visibleRegion)
Sets the visible region for the model.
void dataChanged()
Emitted when the model has changed in some significant way.
QRect visibleRegion() const
Returns the current visible region.
Definition: QuadTreeModelBase.h++:51
A non-parameterized abstract base class for quad-tree models.
Definition: QuadTreeModelBase.h++:17
uint itemCount() const
Returns the number of items in the model.
Definition: QuadTreeModelBase.h++:31
QRect _region
Definition: QuadTreeModelBase.h++:86
QRect region() const
Returns the region covered by this model.
Definition: QuadTreeModelBase.h++:27
QuadTreeModelBase(const QRect &region, uint maxItemsPerQuad=1)
Constructs a QuadTreeModelBase with the given region and density.
Definition: BarChartView.h++:6
uint _itemCount
Definition: QuadTreeModelBase.h++:88
void itemAdded(const QPoint &location)
Emitted when a new item has been added to the model.
virtual ~QuadTreeModelBase()
Destructor.
uint _maxItemsPerQuad
Definition: QuadTreeModelBase.h++:85
void itemModified(const QPoint &location)
Emitted when an item in the model has changed.
void itemRemoved(const QPoint &location)
Emitted when an item has been removed from the model.