|
Quark
0.1
|
An abstract implementation of a quad-tree data model. More...
#include <QuadTreeModel.h++>

Signals | |
| void | dataChanged () |
| Emitted when the model has changed in some significant way. More... | |
| void | itemAdded (const QPoint &location) |
| Emitted when a new item has been added to the model. More... | |
| void | itemModified (const QPoint &location) |
| Emitted when an item in the model has changed. More... | |
| void | itemRemoved (const QPoint &location) |
| Emitted when an item has been removed from the model. More... | |
Public Member Functions | |
| QuadTreeModel (const QRect ®ion, uint maxItemsPerQuad=1) | |
| Constructs a new QuadTreeModel with the given range and density. More... | |
| virtual | ~QuadTreeModel () |
| Destructor. More... | |
| void | clear () |
| Removes all items from the model. More... | |
| bool | addItem (T *item) |
| Adds an item to the model. More... | |
| bool | removeItem (T *item) |
| Removes an item from the model. More... | |
| void | updateItem (T *item) |
| Notifies the model that the given item has changed. More... | |
| T * | itemAtLocation (const QPoint &location) const |
| Returns the item at the given location in the model. More... | |
| QList< T * > | itemsInRegion (const QRect ®ion) const |
| Returns a list of all items in the model that are within the given region. More... | |
| QList< T * > | items () const |
| Returns all of the items in the model. More... | |
| QRect | region () const |
| Returns the region covered by this model. More... | |
| uint | itemCount () const |
| Returns the number of items in the model. More... | |
| bool | isEmpty () const |
| Tests if the model is empty. More... | |
| bool | setVisibleRegion (const QRect &visibleRegion) |
| Sets the visible region for the model. More... | |
| QRect | visibleRegion () const |
| Returns the current visible region. More... | |
Protected Attributes | |
| uint | _maxItemsPerQuad |
| QRect | _region |
| QRect | _visibleRegion |
| uint | _itemCount |
An abstract implementation of a quad-tree data model.
A quad-tree is a data structure that represents a collection of objects which have locations within a 2-D plane. It provides fast lookup of items by coordinate or by rectangular region. Subclasses must implement locationForItem() to return the location (that is, the 2-D coordinates) of a data item.
| T | The type of the objects contained in this model. This type must define a location() method that takes no arguments and returns a QPoint. |
| QuadTreeModel | ( | const QRect & | region, |
| uint | maxItemsPerQuad = 1 |
||
| ) |
Constructs a new QuadTreeModel with the given range and density.
| region | The region covered by this model. |
| maxItemsPerQuad | The maximum number of items that a quad can contain before it is subdivided. |
|
virtual |
Destructor.
| bool addItem | ( | T * | item | ) |
Adds an item to the model.
| item | The item to add. |
| void clear | ( | ) |
Removes all items from the model.
|
signalinherited |
Emitted when the model has changed in some significant way.
|
inlineinherited |
Tests if the model is empty.
|
signalinherited |
Emitted when a new item has been added to the model.
| location | The item's location. |
| T* itemAtLocation | ( | const QPoint & | location | ) | const |
Returns the item at the given location in the model.
| point | The location. |
NULL if there is none.
|
inlineinherited |
Returns the number of items in the model.
|
signalinherited |
Emitted when an item in the model has changed.
| location | The item's location. |
|
signalinherited |
Emitted when an item has been removed from the model.
| location | The item's location. |
| QList<T *> items | ( | ) | const |
Returns all of the items in the model.
| QList<T *> itemsInRegion | ( | const QRect & | region | ) | const |
Returns a list of all items in the model that are within the given region.
| region | The region. |
|
inlineinherited |
Returns the region covered by this model.
| bool removeItem | ( | T * | item | ) |
Removes an item from the model.
| item | The item to remove. |
|
inherited |
Sets the visible region for the model.
When a data item is added to, removed from, or changed in the model, the corresponding notification signal will only be emitted if that item's location was within the visible region.
| The | new visible region. |
| void updateItem | ( | T * | item | ) |
Notifies the model that the given item has changed.
The model will emit the appropriate signal to notifiy views of the change.
| item | The item that changed. |
|
inlineinherited |
Returns the current visible region.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |