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>
Protected Member Functions | |
void | NotifyModelChanged (const CYIDataModelIndex &pIndex) |
void | NotifyColumnsInserted (const CYIDataModelIndex &index, size_t column, size_t count) |
void | NotifyRowsInserted (const CYIDataModelIndex &index, size_t row, size_t count) |
void | NotifyColumnsRemoved (const CYIDataModelIndex &parent, size_t column, size_t count) |
void | NotifyRowsRemoved (const CYIDataModelIndex &parent, size_t row, size_t count) |
Protected Attributes | |
std::unique_ptr< CYIAbstractDataModelPriv > | m_pPriv |
Friends | |
class | CYIDataModelItem |
Create a new blank data model initialized with rows and columns.
|
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.
size_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 row and column 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.
size_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 | ( | size_t | row, |
size_t | column, | ||
const CYIDataModelIndex & | parent = CYIDataModelIndex() |
||
) | const |
Returns true if there is a valid index for row and column under parent.
|
virtual |
Inserts a new blank column at index column 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 column is not a valid column index.
|
virtual |
Inserts a range of blank columns starting at index column with size count 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 column is not a valid column index, or if count is < 1.
|
virtual |
Inserts a new blank row at index row 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 row is not a valid row index.
|
virtual |
Inserts a range of blank rows starting at index row with size count 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 row is not a valid row index, or if count 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 column 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 column is not a valid column index.
|
virtual |
Removes the row spefied by row 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 row 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<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::ColumnsInserted |
CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::ColumnsRemoved |
|
protected |
CYISignal<CYIDataModelIndex > CYIAbstractDataModel::ModelChanged |
CYISignal CYIAbstractDataModel::ModelCleared |
CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::RowsInserted |
CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::RowsRemoved |