You.i Engine
CYIAbstractDataModel Class Reference

Detailed Description

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.

See also
CYIDataModelIndex

#include <datamodel/YiAbstractDataModel.h>

Public Member Functions

 CYIAbstractDataModel (size_t rows, size_t columns=1)
 
virtual ~CYIAbstractDataModel ()
 
virtual bool IsMoreDataAvailable (const CYIDataModelIndex &parent) const
 
virtual bool FetchMoreData (const CYIDataModelIndex &parent)
 
void Clear ()
 
size_t GetRowCount (const CYIDataModelIndex &parent=CYIDataModelIndex()) const
 
size_t GetColumnCount (const CYIDataModelIndex &parent=CYIDataModelIndex()) const
 
CYIDataModelIndex GetParent (const CYIDataModelIndex &child) const
 
virtual CYIDataModelIndex GetIndex (size_t row, size_t column, const CYIDataModelIndex &parent=CYIDataModelIndex()) const
 
bool HasChildren (const CYIDataModelIndex &parent) const
 
bool HasIndex (size_t row, size_t column, const CYIDataModelIndex &parent=CYIDataModelIndex()) const
 
virtual bool InsertColumn (size_t column, const CYIDataModelIndex &parent=CYIDataModelIndex())
 
virtual bool InsertColumns (size_t column, size_t count, const CYIDataModelIndex &parent=CYIDataModelIndex())
 
virtual bool InsertRow (size_t row, const CYIDataModelIndex &parent=CYIDataModelIndex())
 
virtual bool InsertRows (size_t row, size_t count, const CYIDataModelIndex &parent=CYIDataModelIndex())
 
virtual bool RemoveColumn (size_t column, const CYIDataModelIndex &parent=CYIDataModelIndex())
 
virtual bool RemoveRow (size_t row, const CYIDataModelIndex &parent=CYIDataModelIndex())
 
bool SetItemData (const CYIDataModelIndex &index, const CYIAny &pData)
 
const CYIAnyGetItemData (const CYIDataModelIndex &index) const
 

Public Attributes

CYISignal ModelCleared
 
CYISignal< CYIDataModelIndexModelChanged
 
CYISignal< CYIDataModelIndex, size_t, size_tColumnsInserted
 
CYISignal< CYIDataModelIndex, size_t, size_tRowsInserted
 
CYISignal< CYIDataModelIndex, size_t, size_tColumnsRemoved
 
CYISignal< CYIDataModelIndex, size_t, size_tRowsRemoved
 

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
 

Constructor & Destructor Documentation

◆ CYIAbstractDataModel()

CYIAbstractDataModel::CYIAbstractDataModel ( size_t  rows,
size_t  columns = 1 
)

Create a new blank data model initialized with rows and columns.

◆ ~CYIAbstractDataModel()

virtual CYIAbstractDataModel::~CYIAbstractDataModel ( )
virtual

Member Function Documentation

◆ Clear()

void CYIAbstractDataModel::Clear ( )

Clears the root data model item contained by this model.

Warning
This removes and deletes all children recursively.

◆ FetchMoreData()

virtual bool CYIAbstractDataModel::FetchMoreData ( const CYIDataModelIndex parent)
virtual

Subclasses should implement this function for custom data fetching behaviour. The default implementation does nothing and returns false.

◆ GetColumnCount()

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.

◆ GetIndex()

virtual CYIDataModelIndex CYIAbstractDataModel::GetIndex ( size_t  row,
size_t  column,
const CYIDataModelIndex parent = CYIDataModelIndex() 
) const
virtual

Returns an index for the item at row and column under parent.

An invalid index will be returned if no such item exists.

See also
HasIndex

◆ GetItemData()

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.

◆ GetParent()

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.

◆ GetRowCount()

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.

◆ HasChildren()

bool CYIAbstractDataModel::HasChildren ( const CYIDataModelIndex parent) const

Returns true if parent has any children.

◆ HasIndex()

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.

◆ InsertColumn()

virtual bool CYIAbstractDataModel::InsertColumn ( size_t  column,
const CYIDataModelIndex parent = CYIDataModelIndex() 
)
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.

◆ InsertColumns()

virtual bool CYIAbstractDataModel::InsertColumns ( size_t  column,
size_t  count,
const CYIDataModelIndex parent = CYIDataModelIndex() 
)
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.

◆ InsertRow()

virtual bool CYIAbstractDataModel::InsertRow ( size_t  row,
const CYIDataModelIndex parent = CYIDataModelIndex() 
)
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.

◆ InsertRows()

virtual bool CYIAbstractDataModel::InsertRows ( size_t  row,
size_t  count,
const CYIDataModelIndex parent = CYIDataModelIndex() 
)
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.

◆ IsMoreDataAvailable()

virtual bool CYIAbstractDataModel::IsMoreDataAvailable ( const CYIDataModelIndex parent) const
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.

◆ NotifyColumnsInserted()

void CYIAbstractDataModel::NotifyColumnsInserted ( const CYIDataModelIndex index,
size_t  column,
size_t  count 
)
protected

◆ NotifyColumnsRemoved()

void CYIAbstractDataModel::NotifyColumnsRemoved ( const CYIDataModelIndex parent,
size_t  column,
size_t  count 
)
protected

◆ NotifyModelChanged()

void CYIAbstractDataModel::NotifyModelChanged ( const CYIDataModelIndex pIndex)
protected

◆ NotifyRowsInserted()

void CYIAbstractDataModel::NotifyRowsInserted ( const CYIDataModelIndex index,
size_t  row,
size_t  count 
)
protected

◆ NotifyRowsRemoved()

void CYIAbstractDataModel::NotifyRowsRemoved ( const CYIDataModelIndex parent,
size_t  row,
size_t  count 
)
protected

◆ RemoveColumn()

virtual bool CYIAbstractDataModel::RemoveColumn ( size_t  column,
const CYIDataModelIndex parent = CYIDataModelIndex() 
)
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.

◆ RemoveRow()

virtual bool CYIAbstractDataModel::RemoveRow ( size_t  row,
const CYIDataModelIndex parent = CYIDataModelIndex() 
)
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.

◆ SetItemData()

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.

Friends And Related Function Documentation

◆ CYIDataModelItem

friend class CYIDataModelItem
friend

Member Data Documentation

◆ ColumnsInserted

CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::ColumnsInserted

◆ ColumnsRemoved

CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::ColumnsRemoved

◆ m_pPriv

std::unique_ptr<CYIAbstractDataModelPriv> CYIAbstractDataModel::m_pPriv
protected

◆ ModelChanged

CYISignal<CYIDataModelIndex > CYIAbstractDataModel::ModelChanged

◆ ModelCleared

CYISignal CYIAbstractDataModel::ModelCleared

◆ RowsInserted

CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::RowsInserted

◆ RowsRemoved

CYISignal<CYIDataModelIndex , size_t , size_t > CYIAbstractDataModel::RowsRemoved

The documentation for this class was generated from the following file: