Represents arbitrary data as a hierarchy of tables.
This class can be used to represent data as a single item, a list, a table or a tree - depending on how that data is stored and interpreted within the model.
Each index in the model can hold onto a piece of data in the form of a CYIAny instance.
#include <datamodel/YiAbstractDataModel.h>
Public Member Functions | |
| CYIAbstractDataModel (int32_t nRows, int32_t nColumns=1) | |
| virtual | ~CYIAbstractDataModel () |
| virtual bool | IsMoreDataAvailable (const CYIDataModelIndex &parent) const |
| virtual bool | FetchMoreData (const CYIDataModelIndex &parent) |
| void | Clear () |
| int32_t | GetRowCount (const CYIDataModelIndex &parent=CYIDataModelIndex()) const |
| int32_t | GetColumnCount (const CYIDataModelIndex &parent=CYIDataModelIndex()) const |
| CYIDataModelIndex | GetParent (const CYIDataModelIndex &child) const |
| virtual CYIDataModelIndex | GetIndex (int32_t nRow, int32_t nColumn, const CYIDataModelIndex &parent=CYIDataModelIndex()) const |
| bool | HasChildren (const CYIDataModelIndex &parent) const |
| bool | HasIndex (int32_t nRow, int32_t nColumn, const CYIDataModelIndex &parent=CYIDataModelIndex()) const |
| virtual bool | InsertColumn (int32_t nColumn, const CYIDataModelIndex &parent=CYIDataModelIndex()) |
| virtual bool | InsertColumns (int32_t nColumn, int32_t nCount, const CYIDataModelIndex &parent=CYIDataModelIndex()) |
| virtual bool | InsertRow (int32_t nRow, const CYIDataModelIndex &parent=CYIDataModelIndex()) |
| virtual bool | InsertRows (int32_t nRow, int32_t nCount, const CYIDataModelIndex &parent=CYIDataModelIndex()) |
| virtual bool | RemoveColumn (int32_t nColumn, const CYIDataModelIndex &parent=CYIDataModelIndex()) |
| virtual bool | RemoveRow (int32_t nRow, const CYIDataModelIndex &parent=CYIDataModelIndex()) |
| bool | SetItemData (const CYIDataModelIndex &index, const CYIAny &pData) |
| const CYIAny & | GetItemData (const CYIDataModelIndex &index) const |
Public Attributes | |
| CYISignal | ModelCleared |
| CYISignal< const CYIDataModelIndex & > | ModelChanged |
| CYISignal< const CYIDataModelIndex &, int32_t, int32_t > | ColumnsInserted |
| CYISignal< const CYIDataModelIndex &, int32_t, int32_t > | RowsInserted |
| CYISignal< const CYIDataModelIndex &, int32_t, int32_t > | ColumnsRemoved |
| CYISignal< const CYIDataModelIndex &, int32_t, int32_t > | RowsRemoved |
Protected Member Functions | |
| void | NotifyModelChanged (const CYIDataModelIndex &pIndex) |
| void | NotifyColumnsInserted (const CYIDataModelIndex &index, int32_t nColumn, int32_t nCount) |
| void | NotifyRowsInserted (const CYIDataModelIndex &index, int32_t nRow, int32_t nCount) |
| void | NotifyColumnsRemoved (const CYIDataModelIndex &parent, int32_t nColumn, int32_t nCount) |
| void | NotifyRowsRemoved (const CYIDataModelIndex &parent, int32_t nRow, int32_t nCount) |
Protected Attributes | |
| CYIAbstractDataModelPriv * | m_pPriv |
Friends | |
| class | CYIDataModelItem |
| CYIAbstractDataModel::CYIAbstractDataModel | ( | int32_t | nRows, |
| int32_t | nColumns = 1 |
||
| ) |
Create a new blank data model initialized with nRows and nColumns.
|
virtual |
| void CYIAbstractDataModel::Clear | ( | ) |
Clears the root data model item contained by this model.
|
virtual |
Subclasses should implement this function for custom data fetching behaviour. The default implementation does nothing and returns false.
| int32_t CYIAbstractDataModel::GetColumnCount | ( | const CYIDataModelIndex & | parent = CYIDataModelIndex() | ) | const |
Returns the number of columns at the index specified by parent. If no index is specified the number of columns at the root of the model will be returned.
|
virtual |
Returns an index for the item at nRow and nColumn under parent.
An invalid index will be returned if no such item exists.
| const CYIAny& CYIAbstractDataModel::GetItemData | ( | const CYIDataModelIndex & | index | ) | const |
Returns the data associated with index. Will return an empty CYIAny if the index could not be found.
| CYIDataModelIndex CYIAbstractDataModel::GetParent | ( | const CYIDataModelIndex & | child | ) | const |
Returns the index to the parent of the item index specified by child.
If child is an invalid index (representing the root item), an invalid index will be returned. An invalid index will also be returned to represent the root item, which may be a true parent index for child.
| int32_t CYIAbstractDataModel::GetRowCount | ( | const CYIDataModelIndex & | parent = CYIDataModelIndex() | ) | const |
Returns the number of rows at the index specified by parent. If no index is specified the number of rows at the root of the model will be returned.
| bool CYIAbstractDataModel::HasChildren | ( | const CYIDataModelIndex & | parent | ) | const |
Returns true if parent has any children.
| bool CYIAbstractDataModel::HasIndex | ( | int32_t | nRow, |
| int32_t | nColumn, | ||
| const CYIDataModelIndex & | parent = CYIDataModelIndex() |
||
| ) | const |
Returns true if there is a valid index for nRow and nColumn under parent.
|
virtual |
Inserts a new blank column at index nColumn to the item associated with parent.
Returns true if the column was successfully inserted.
Returns false if the parent data item does not exist, or if nColumn is not a valid column index.
|
virtual |
Inserts a range of blank columns starting at index nColumn with size nCount to the item associated with parent.
Returns true if the columns were successfully inserted.
Returns false if the parent data item does not exist, if nColumn is not a valid column index, or if nCount is < 1.
|
virtual |
Inserts a new blank row at index nRow to the item associated with parent.
Returns true if the row was successfully inserted.
Returns false if the parent data item does not exist, or if nRow is not a valid row index.
|
virtual |
Inserts a range of blank rows starting at index nRow with size nCount to the item associated with parent.
Returns true if the rows were successfully inserted.
Returns false if the parent data item does not exist, if nRow is not a valid row index, or if nCount is < 1.
|
virtual |
Returns true if there is more data available at index parent.
Subclasses should implement this function for custom behaviour. The default implementation always returns false.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
virtual |
Removes the column spefied by nColumn from the item associated with parent.
Returns true if the column was sucessfully removed.
Returns false if the parent data item does not exist, or if nColumn is not a valid column index.
|
virtual |
Removes the row spefied by nRow from the item associated with parent.
Returns true if the row was sucessfully removed.
Returns false if the parent data item does not exist, or if nRow is not a valid row index.
| bool CYIAbstractDataModel::SetItemData | ( | const CYIDataModelIndex & | index, |
| const CYIAny & | pData | ||
| ) |
Sets the data for the item associated with index.
Returns true if the data was set successfully.
Returns false if index is not a valid item index.
|
friend |
| CYISignal<const CYIDataModelIndex & , int32_t , int32_t > CYIAbstractDataModel::ColumnsInserted |
| CYISignal<const CYIDataModelIndex & , int32_t , int32_t > CYIAbstractDataModel::ColumnsRemoved |
|
protected |
| CYISignal<const CYIDataModelIndex & > CYIAbstractDataModel::ModelChanged |
| CYISignal CYIAbstractDataModel::ModelCleared |
| CYISignal<const CYIDataModelIndex & , int32_t , int32_t > CYIAbstractDataModel::RowsInserted |
| CYISignal<const CYIDataModelIndex & , int32_t , int32_t > CYIAbstractDataModel::RowsRemoved |