Quark
0.1
|
An abstract base class for grid data models, i.e., models in which every cell contains the same type of object. More...
#include <AbstractGridModel.h++>
Public Member Functions | |
virtual | ~AbstractGridModel () |
Destructor. More... | |
virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const |
Specified by QAbstractItemModel. More... | |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
Specified by QAbstractItemModel. More... | |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
Specified by QAbstractItemModel. More... | |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
Specified by QAbstractItemModel. More... | |
virtual bool | hasChildren (const QModelIndex &parent=QModelIndex()) const |
Specified by QAbstractItemModel. More... | |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
Specified by QAbstractItemModel. More... | |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
Specified by QAbstractItemModel. More... | |
virtual QModelIndex | parent (const QModelIndex &index) const |
Specified by QAbstractItemModel. More... | |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const |
Specified by QAbstractItemModel. More... | |
virtual QStringList | mimeTypes () const |
Specified by QAbstractItemModel. More... | |
virtual QMimeData * | mimeData (const QModelIndexList &indexes) const |
Specified by QAbstractItemModel. More... | |
virtual bool | dropMimeData (const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Specified by QAbstractItemModel. More... | |
void | resize (int rows, int columns) |
Resizes the model. More... | |
int | rows () const |
Returns the number of rows in the model. More... | |
int | columns () const |
Returns the number of columns in the model. More... | |
int | itemCount () const |
Returns the number of items in the model. More... | |
void | clear () |
Removes all items from the model. More... | |
bool | isEmpty () const |
Tests if the model is empty. More... | |
bool | setItems (QList< T *> items) |
Populates the model with items from a QList. More... | |
void | setItemAt (T *item, int row, int column) |
Sets an item at the specified row and column. More... | |
T * | getItemAt (int row, int column) const |
Returns the item at the specified row and column. More... | |
T * | takeItemAt (int row, int column) |
Removes and returns the item at the specified row and column. More... | |
void | removeItemAt (int row, int column) |
Removes and deletes the item at the specified row and column. More... | |
void | updateItem (T *item) |
Notifies the model that the given item has changed in some way. More... | |
void | updateItemAt (int row, int column) |
Notifies the model that the item at the given position has changed in some way. More... | |
virtual QPoint | positionOf (const T *item) const =0 |
Returns the row and column position of the given item in the model. More... | |
bool | isCellEmpty (int row, int column) const |
Tests if the given cell of the model is empty. More... | |
void | setEditable (bool editable) |
Sets the editability of the model. More... | |
bool | isEditable () const |
Tests the editability of the model. More... | |
virtual QVariant | getValue (const T &item) const =0 |
Returns the display object for the given item. More... | |
virtual QString | getRowName (int row) const |
Returns the name of the given row. More... | |
virtual QString | getColumnName (int column) const |
Returns the name of the given column. More... | |
Protected Member Functions | |
AbstractGridModel (QObject *parent=NULL) | |
Constructor. More... | |
virtual QIcon | getIcon (const T &item) const |
Returns the icon for a given item, if any. More... | |
virtual QSize | getSize (const T &item) const |
Returns the preferred display size of a given item, if any. More... | |
virtual Qt::AlignmentFlag | getValueAlignment (const T &item) const |
Returns the preferred alignment of a given item. More... | |
virtual Qt::AlignmentFlag | getRowHeaderAlignment () const |
Returns the preferred row (vertical) header label alignment. More... | |
virtual Qt::AlignmentFlag | getColumnHeaderAlignment () const |
Returns the preferred column (horizontal) header label alignment. More... | |
virtual void | setValue (T *item, const QVariant &value) |
Sets the value of an edited item. More... | |
virtual void | setChecked (T *item, bool checked) |
Sets the checked state of a checkable item. More... | |
virtual bool | isEditable (const T &item) const |
Tests if a given item is editable. More... | |
virtual bool | isCheckable (const T &item) const |
Tests if a given item is checkable. More... | |
virtual bool | isChecked (const T &item) const |
Tests if a given item is currently checked. More... | |
virtual bool | isDraggable (const T &item) const |
Tests if a given item can be dragged. More... | |
virtual bool | isDroppable (const T &item) const |
Tests if a given item can be dropped onto. More... | |
virtual bool | isEmptyDroppable () const |
Tests if an empty cell can be dropped onto. More... | |
virtual void | itemAdded (const T *item) |
Called when an item has been added to the model. More... | |
virtual void | itemUpdated (const T &item) |
Called when an item has been updated in the model. More... | |
virtual void | itemRemoved (const T &item) |
Called when an item is about to be removed from the model. More... | |
virtual T * | getAt (int row, int column) const =0 |
Returns the item at the given row and column. More... | |
virtual T * | takeAt (int row, int column)=0 |
Removes and returns the item at the given row and column. More... | |
virtual void | setAt (T *item, int row, int column)=0 |
Sets the item at the given row and column. More... | |
virtual void | removeAll ()=0 |
Removes all items from the model. More... | |
virtual void | resizeData (int rows, int columns)=0 |
Resizes the model. More... | |
virtual bool | dropOtherMimeData (const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Handles the dropping of MIME data with a MIME-type that is supported by (but not native to) this model. More... | |
virtual QStringList | otherMimeTypes () const |
Returns a list of additional MIME-types that can be dropped onto the model. More... | |
virtual QString | itemMimeType () const =0 |
Returns the model's native MIME-type. More... | |
virtual void | writeProlog (OS &stream) const |
Writes any necessary prolog (e.g., an XML open-tag) when serializing items to be dragged out of the model. More... | |
virtual void | writeItem (const T &item, OS &stream) const |
Serializes an item that is being dragged out of the model. More... | |
virtual void | writeEpilog (OS &stream) const |
Writes any necessary epilog (e.g., an XML close-tag) when serializing items to be dragged out of the model. More... | |
virtual void | readProlog (IS &stream) |
Reads any necessary prolog (e.g., an XML open-tag) when deserializing items that are being dropped into the model. More... | |
virtual T * | readItem (IS &stream) |
Deserializes an item that is being dropped into the model. More... | |
virtual void | readEpilog (IS &stream) |
Reads any necessary epilog (e.g., an XML close-tag) when deserializing items that are being dropped into the model. More... | |
An abstract base class for grid data models, i.e., models in which every cell contains the same type of object.
This class does not specify the data structure for storing the model's contents; see BasicGridModel for a default implementation that stores items in a QVector.
If the model supports drag and/or drop, data streams of the specified type will be instantiated to serialize/deserialize the dragged objects.
T | The type of the objects contained in this model. |
IS | A class for deserializing objects of type T. |
OS | A class for serializing objects of type T. |
|
virtual |
Destructor.
All items in the model are automatically deleted.
|
protected |
Constructor.
void clear | ( | ) |
Removes all items from the model.
All items in the model are automatically deleted.
|
virtual |
Specified by QAbstractItemModel.
int columns | ( | ) | const |
Returns the number of columns in the model.
|
virtual |
Specified by QAbstractItemModel.
|
virtual |
Specified by QAbstractItemModel.
|
protectedvirtual |
Handles the dropping of MIME data with a MIME-type that is supported by (but not native to) this model.
The default implementation is a no-op that returns false
.
mimeData | The MIME data. |
action | The drop action. |
row | The row onto which the data is being dropped. |
column | The column onto which the data is being dropped. |
parent | The parent index. |
true
if the drop was handled successfully, false
otherwise.
|
virtual |
Specified by QAbstractItemModel.
|
protectedpure virtual |
Returns the item at the given row and column.
Implemented in BasicGridModel< T, IS, OS >.
|
protectedvirtual |
Returns the preferred column (horizontal) header label alignment.
|
virtual |
Returns the name of the given column.
This name will be used for the corresponding label in a view's horizontal header.
column | The column. |
|
protectedvirtual |
Returns the icon for a given item, if any.
T* getItemAt | ( | int | row, |
int | column | ||
) | const |
Returns the item at the specified row and column.
row | The row. |
column | The column. |
NULL
if there is no item at that position.
|
protectedvirtual |
Returns the preferred row (vertical) header label alignment.
|
virtual |
Returns the name of the given row.
This name will be used for the corresponding label in a view's vertical header.
row | The row. |
|
protectedvirtual |
Returns the preferred display size of a given item, if any.
|
pure virtual |
Returns the display object for the given item.
|
protectedvirtual |
Returns the preferred alignment of a given item.
|
virtual |
Specified by QAbstractItemModel.
|
virtual |
Specified by QAbstractItemModel.
|
virtual |
Specified by QAbstractItemModel.
bool isCellEmpty | ( | int | row, |
int | column | ||
) | const |
Tests if the given cell of the model is empty.
row | The row. |
column | The column. |
|
protectedvirtual |
Tests if a given item is checkable.
|
protectedvirtual |
Tests if a given item is currently checked.
|
protectedvirtual |
Tests if a given item can be dragged.
|
protectedvirtual |
Tests if a given item can be dropped onto.
bool isEditable | ( | ) | const |
Tests the editability of the model.
|
protectedvirtual |
Tests if a given item is editable.
bool isEmpty | ( | ) | const |
Tests if the model is empty.
|
protectedvirtual |
Tests if an empty cell can be dropped onto.
|
protectedvirtual |
Called when an item has been added to the model.
The default implementation is a no-op.
int itemCount | ( | ) | const |
Returns the number of items in the model.
|
protectedpure virtual |
Returns the model's native MIME-type.
|
protectedvirtual |
Called when an item is about to be removed from the model.
The default implementation is a no-op.
|
protectedvirtual |
Called when an item has been updated in the model.
The default implementation is a no-op.
|
virtual |
Specified by QAbstractItemModel.
|
virtual |
Specified by QAbstractItemModel.
|
protectedvirtual |
Returns a list of additional MIME-types that can be dropped onto the model.
The default implementation returns an empty list.
|
virtual |
Specified by QAbstractItemModel.
|
pure virtual |
Returns the row and column position of the given item in the model.
item | The item. |
Implemented in BasicGridModel< T, IS, OS >.
|
protectedvirtual |
Reads any necessary epilog (e.g., an XML close-tag) when deserializing items that are being dropped into the model.
This method is called at the end of a drop operation. The default implementation is a no-op.
stream | The stream from which items are being deserialized. |
|
protectedvirtual |
Deserializes an item that is being dropped into the model.
This method is called once for each item that is being dropped during a drop operation. The default implementation is a no-op.
stream | The stream from which items are being deserialized. |
|
protectedvirtual |
Reads any necessary prolog (e.g., an XML open-tag) when deserializing items that are being dropped into the model.
This method is called at the beginning of a drop operation. The default implementation is a no-op.
stream | The stream from which items are being deserialized. |
|
protectedpure virtual |
Removes all items from the model.
All cells become empty.
Implemented in BasicGridModel< T, IS, OS >.
void removeItemAt | ( | int | row, |
int | column | ||
) |
Removes and deletes the item at the specified row and column.
row | The row. |
column | The column. |
void resize | ( | int | rows, |
int | columns | ||
) |
Resizes the model.
rows | The new row count. |
columns | The new column count. |
|
protectedpure virtual |
Resizes the model.
Implemented in BasicGridModel< T, IS, OS >.
|
virtual |
Specified by QAbstractItemModel.
int rows | ( | ) | const |
Returns the number of rows in the model.
|
protectedpure virtual |
Sets the item at the given row and column.
Implemented in BasicGridModel< T, IS, OS >.
|
protectedvirtual |
Sets the checked state of a checkable item.
|
virtual |
Specified by QAbstractItemModel.
void setEditable | ( | bool | editable | ) |
Sets the editability of the model.
void setItemAt | ( | T * | item, |
int | row, | ||
int | column | ||
) |
Sets an item at the specified row and column.
Any old item at the given position is deleted.
item | The item. The model takes ownership of the object. |
row | The row at which to place the item. |
column | The column at which to place the item. |
bool setItems | ( | QList< T *> | items | ) |
Populates the model with items from a QList.
The model is filled row by row, starting with the first row.
items | The items. |
true
on success, or false
if the model is too small to accommodate the items.
|
protectedvirtual |
Sets the value of an edited item.
|
protectedpure virtual |
Removes and returns the item at the given row and column.
Implemented in BasicGridModel< T, IS, OS >.
T* takeItemAt | ( | int | row, |
int | column | ||
) |
Removes and returns the item at the specified row and column.
The model relinquishes ownership of the returned item, so it must eventually be deleted by the caller.
row | The row. |
column | The column. |
NULL
if there is no item at that position. void updateItem | ( | T * | item | ) |
Notifies the model that the given item has changed in some way.
The model will invoke the appropriate signal(s) to notify any attached views that the corresponding cell needs to be redrawn.
item | The item that changed. If this item is not actually in the model, the call will be a no-op. |
void updateItemAt | ( | int | row, |
int | column | ||
) |
Notifies the model that the item at the given position has changed in some way.
The model will invoke the appropriate signal(s) to notify any attached views that the corresponding cell needs to be redrawn.
row | The row of the item that changed. |
column | The column of the item that changed. |
|
protectedvirtual |
Writes any necessary epilog (e.g., an XML close-tag) when serializing items to be dragged out of the model.
This method is called at the end of a drag operation. The default implementation is a no-op.
stream | The stream to which items are being serialized. |
|
protectedvirtual |
Serializes an item that is being dragged out of the model.
This method is called once for each item that is being dragged during a drag operation. The default implementation is a no-op.
item | The item to serialize. |
stream | The stream to which items are being serialized. |
|
protectedvirtual |
Writes any necessary prolog (e.g., an XML open-tag) when serializing items to be dragged out of the model.
This method is called at the beginning of a drag operation. The default implementation is a no-op.
stream | The stream to which items are being serialized. |