Quark
0.1
|
A default concrete implementation of AbstractGridModel that stores items in a QVector. More...
#include <BasicGridModel.h++>
Public Member Functions | |
BasicGridModel (int rows=0, int columns=0, QObject *parent=NULL) | |
Constructs a new BasicGridModel with the given dimensions. More... | |
virtual | ~BasicGridModel () |
Destructor. More... | |
virtual QPoint | positionOf (const T *item) const |
Returns the row and column position of the given item in the model. 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... | |
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 | |
virtual void | resizeData (int rows, int columns) |
Resizes the model. More... | |
virtual T * | getAt (int row, int column) const |
Returns the item at the given row and column. More... | |
virtual T * | takeAt (int row, int column) |
Removes and returns the item at the given row and column. More... | |
virtual void | setAt (T *item, int row, int column) |
Sets the item at the given row and column. More... | |
virtual void | removeAll () |
Removes all items from the model. More... | |
virtual bool | isEditable (const T &item) const |
Tests if a given item is editable. 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 | 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 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... | |
A default concrete implementation of AbstractGridModel that stores items in a QVector.
T | The type of the objects contained in this model. |
IS | A subclass of QDataStream for deserializing objects of type T. |
OS | A subclass of QDataStream for serializing objects of type T. |
BasicGridModel | ( | int | rows = 0 , |
int | columns = 0 , |
||
QObject * | parent = NULL |
||
) |
Constructs a new BasicGridModel with the given dimensions.
rows | The number of rows for the model. |
columns | The number of columns for the model. |
|
virtual |
Destructor.
|
inherited |
Removes all items from the model.
All items in the model are automatically deleted.
|
virtualinherited |
Specified by QAbstractItemModel.
|
inherited |
Returns the number of columns in the model.
|
virtualinherited |
Specified by QAbstractItemModel.
|
virtualinherited |
Specified by QAbstractItemModel.
|
protectedvirtualinherited |
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.
|
virtualinherited |
Specified by QAbstractItemModel.
|
protectedvirtual |
Returns the item at the given row and column.
Implements AbstractGridModel< T, IS, OS >.
|
protectedvirtualinherited |
Returns the preferred column (horizontal) header label alignment.
|
virtualinherited |
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. |
|
protectedvirtualinherited |
Returns the icon for a given item, if any.
|
inherited |
Returns the item at the specified row and column.
row | The row. |
column | The column. |
NULL
if there is no item at that position.
|
protectedvirtualinherited |
Returns the preferred row (vertical) header label alignment.
|
virtualinherited |
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. |
|
protectedvirtualinherited |
Returns the preferred display size of a given item, if any.
|
pure virtualinherited |
Returns the display object for the given item.
|
protectedvirtualinherited |
Returns the preferred alignment of a given item.
|
virtualinherited |
Specified by QAbstractItemModel.
|
virtualinherited |
Specified by QAbstractItemModel.
|
virtualinherited |
Specified by QAbstractItemModel.
|
inherited |
Tests if the given cell of the model is empty.
row | The row. |
column | The column. |
|
protectedvirtualinherited |
Tests if a given item is checkable.
|
protectedvirtualinherited |
Tests if a given item is currently checked.
|
protectedvirtualinherited |
Tests if a given item can be dragged.
|
protectedvirtualinherited |
Tests if a given item can be dropped onto.
|
inherited |
Tests the editability of the model.
|
protectedvirtualinherited |
Tests if a given item is editable.
|
inherited |
Tests if the model is empty.
|
protectedvirtualinherited |
Tests if an empty cell can be dropped onto.
|
protectedvirtualinherited |
Called when an item has been added to the model.
The default implementation is a no-op.
|
inherited |
Returns the number of items in the model.
|
protectedpure virtualinherited |
Returns the model's native MIME-type.
|
protectedvirtualinherited |
Called when an item is about to be removed from the model.
The default implementation is a no-op.
|
protectedvirtualinherited |
Called when an item has been updated in the model.
The default implementation is a no-op.
|
virtualinherited |
Specified by QAbstractItemModel.
|
virtualinherited |
Specified by QAbstractItemModel.
|
protectedvirtualinherited |
Returns a list of additional MIME-types that can be dropped onto the model.
The default implementation returns an empty list.
|
virtualinherited |
Specified by QAbstractItemModel.
|
virtual |
Returns the row and column position of the given item in the model.
item | The item. |
Implements AbstractGridModel< T, IS, OS >.
|
protectedvirtualinherited |
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. |
|
protectedvirtualinherited |
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. |
|
protectedvirtualinherited |
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. |
|
protectedvirtual |
Removes all items from the model.
All cells become empty.
Implements AbstractGridModel< T, IS, OS >.
|
inherited |
Removes and deletes the item at the specified row and column.
row | The row. |
column | The column. |
|
inherited |
Resizes the model.
rows | The new row count. |
columns | The new column count. |
|
protectedvirtual |
Resizes the model.
Implements AbstractGridModel< T, IS, OS >.
|
virtualinherited |
Specified by QAbstractItemModel.
|
inherited |
Returns the number of rows in the model.
|
protectedvirtual |
Sets the item at the given row and column.
Implements AbstractGridModel< T, IS, OS >.
|
protectedvirtualinherited |
Sets the checked state of a checkable item.
|
virtualinherited |
Specified by QAbstractItemModel.
|
inherited |
Sets the editability of the model.
|
inherited |
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. |
|
inherited |
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.
|
protectedvirtualinherited |
Sets the value of an edited item.
|
protectedvirtual |
Removes and returns the item at the given row and column.
Implements AbstractGridModel< T, IS, OS >.
|
inherited |
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.
|
inherited |
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. |
|
inherited |
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. |
|
protectedvirtualinherited |
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. |
|
protectedvirtualinherited |
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. |
|
protectedvirtualinherited |
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. |