Contents Up Previous Next

wxDataViewListModel

wxDataViewListModel is currently the only existing variant of a wxDataViewModel. It allows to define a table like data model to be displayed by a wxDataViewCtrl. You need to derive from this class to define your own data model.

You need to override GetNumberOfRows, GetNumberOfCols, GetColType and GetValue in order to define the data model (which acts as an interface between your actual data and the wxDataViewCtrl). Since you will usually also allow the wxDataViewCtrl to change your data through its graphical interface, you will also have to override SetValue which the wxDataViewCtrl will call when a change to some data has been commited.

The data that is presented through this data model is expected to change at run-time. You need to inform the data model that a change happens. Depending on what happened you need to call one of the following methods: ValueChanged, RowChanged, RowAppended, RowPrepended, RowInserted, RowDeleted, RowsReordered or RowsCleared.

wxDataViewModel and this class (as indeed the entire wxDataViewCtrl code) is using wxVariant to store data and its type in a generic way. wxVariant can be extended to contain almost any data without changes to the original class.

This class maintains a list of wxDataListViewListModelNotifier which link this class to the specific implementations on the supported platforms so that e.g. calling ValueChanged on this model will just call wxDataListViewListModelNotifier::ValueChanged for each notifier that has been added. This is used both for informing the native controls to redraw themselves and for informing e.g. the wxDataViewSortedListModel to resort itself. You can also add your own notifier in order to get informed about any changes to the data in the list model.

Additionally, this class maintains a list of all wxDataViewColumns which display a certain column of this list model. This is mostly used internally.

Derived from

wxDataViewModel
wxObject

Include files

<wx/dataview.h>

wxDataViewListModel::wxDataViewListModel
wxDataViewListModel::~wxDataViewListModel
wxDataViewListModel::AddNotifier
wxDataViewListModel::AddViewingColumn
wxDataViewListModel::Cleared
wxDataViewListModel::GetColType
wxDataViewListModel::GetNumberOfCols
wxDataViewListModel::GetNumberOfRows
wxDataViewListModel::GetValue
wxDataViewListModel::RemoveNotifier
wxDataViewListModel::RemoveViewingColumn
wxDataViewListModel::RowAppended
wxDataViewListModel::RowChanged
wxDataViewListModel::RowDeleted
wxDataViewListModel::RowInserted
wxDataViewListModel::RowPrepended
wxDataViewListModel::RowsReordered
wxDataViewListModel::SetValue
wxDataViewListModel::ValueChanged


wxDataViewListModel::wxDataViewListModel

wxDataViewListModel()

Constructor.


wxDataViewListModel::~wxDataViewListModel

~wxDataViewListModel()

Destructor.


wxDataViewListModel::AddNotifier

void AddNotifier(wxDataViewListModelNotifier* notifier)

Adds notifier to the internal list of notifers.

See also RemoveNotifier.


wxDataViewListModel::AddViewingColumn

void AddViewingColumn(wxDataViewColumn* view_column, unsigned int model_column)

Used internally. Used for maintaining a list of wxDataViewColumn that display a certain column of this model.


wxDataViewListModel::Cleared

bool virtual Cleared()

Call this if all data in your model has been cleared.


wxDataViewListModel::GetColType

virtual wxString GetColType(unsigned int col)

Override this to indicate what type of data is stored in the column specified by col. This should return a string indicating the type of data as reported by wxVariant.


wxDataViewListModel::GetNumberOfCols

virtual unsigned int GetNumberOfCols()

Override this to indicate, how many columns the list model has.


wxDataViewListModel::GetNumberOfRows

virtual unsigned int GetNumberOfRows()

Override this to indicate, how many rows the list model has.


wxDataViewListModel::GetValue

virtual void GetValue(wxVariant& variant, unsigned int col, unsigned int row)

Override this to indicate the value of a given value in the list model. A wxVariant is used to store the data.


wxDataViewListModel::RemoveNotifier

void RemoveNotifier(wxDataViewListModelNotifier* notifier)

Removes the notifier from the list of notifiers.

See also AddNotifier.


wxDataViewListModel::RemoveViewingColumn

void RemoveViewingColumn(wxDataViewColumn* column)

Used internally. Used for maintaining a list of wxDataViewColumn that display a certain column of this model.


wxDataViewListModel::RowAppended

virtual bool RowAppended()

Call this if a row has been appended to the list model.


wxDataViewListModel::RowChanged

virtual bool RowChanged(unsigned int row)

Call this if the values of this row have been changed.


wxDataViewListModel::RowDeleted

virtual bool RowDeleted(unsigned int row)

Call this if this row has been deleted.


wxDataViewListModel::RowInserted

virtual bool RowInserted(unsigned int before)

Call this if a row has been inserted.


wxDataViewListModel::RowPrepended

virtual bool RowPrepended()

Call this if a row has been prepended.


wxDataViewListModel::RowsReordered

virtual bool RowsReordered(unsigned int* new_order)

Call this if the rows have been reorderd.


wxDataViewListModel::SetValue

virtual bool SetValue(wxVariant& variant, unsigned int col, unsigned int row)

This method gets called by e.g. the wxDataViewCtrl class if a value has been changed through its graphical interface. You need to override this method in order to update the data in the underlying data structur. Afterwards, ValueChanged is called.


wxDataViewListModel::ValueChanged

virtual bool ValueChanged(unsigned int col, unsigned int row)

Call this if a value in the model has been changed.