]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewmodel.tex
Use const
[wxWidgets.git] / docs / latex / wx / dataviewmodel.tex
CommitLineData
b6b9d556
RR
1
2\section{\class{wxDataViewModel}}\label{wxdataviewmodel}
3
4wxDataViewModel is the base class for all data model to be
5displayed by a \helpref{wxDataViewCtrl}{wxdataviewctrl}.
1ab4aff2
RR
6All other models derive from it and must implement its
7pure virtual functions in order to define a complete
8data model. In detail, you need to override
9\helpref{IsContainer}{wxdataviewmodeliscontainer},
10\helpref{GetParent}{wxdataviewmodelgetparent},
11\helpref{GetColumnCount}{wxdataviewmodelgetcolumncount},
12\helpref{GetColumnType}{wxdataviewmodelgetcolumntype} and
13\helpref{GetValue}{wxdataviewmodelgetvalue} in order to
14define the data model which acts as an interface between
15your actual data and the wxDataViewCtrl. Since you will
aa0576fe
RR
16usually also allow the wxDataViewCtrl to change your data
17through its graphical interface, you will also have to override
61cec318 18\helpref{SetValue}{wxdataviewmodelsetvalue} which the
aa0576fe
RR
19wxDataViewCtrl will call when a change to some data has been
20commited.
21
1ab4aff2 22wxDataViewModel (as indeed the entire wxDataViewCtrl
b19add95
RR
23code) is using \helpref{wxVariant}{wxvariant} to store data and
24its type in a generic way. wxVariant can be extended to contain
25almost any data without changes to the original class.
26
1ab4aff2
RR
27The data that is presented through this data model is expected
28to change at run-time. You need to inform the data model when
29a change happened. Depending on what happened you need to call
30one of the following methods:
31\helpref{ValueChanged}{wxdataviewmodelvaluechanged},
32\helpref{ItemAdded}{wxdataviewmodelitemadded},
33\helpref{ItemDeleted}{wxdataviewmodelitemdeleted},
34\helpref{ItemChanged}{wxdataviewmodelitemchanged},
35\helpref{Cleared}{wxdataviewmodelcleared}.
36
37Note that wxDataViewModel does not define the position or
38index of any item in the control since several control might
39display the data differently, but wxDataViewModel does
40provide a \helpref{Compare}{wxdataviewmodelcompare} method
0bd26819
RR
41which the wxDataViewCtrl may use to sort the data either
42in conjunction with a column header or without (see
43\helpref{HasDefaultCompare}{wxdataviewmodelhasdefaultcompare}.
1ab4aff2 44
b6b9d556 45This class maintains a list of
1ab4aff2 46\helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier}
b6b9d556 47which link this class to the specific implementations on the
b19add95 48supported platforms so that e.g. calling
1ab4aff2 49\helpref{ValueChanged}{wxdataviewmodelvaluechanged}
b6b9d556 50on this model will just call
1ab4aff2
RR
51\helpref{wxDataViewModelNotifier::ValueChanged}{wxdataviewmodelnotifiervaluechanged}
52for each notifier that has been added. You can also add
53your own notifier in order to get informed about any changes
54to the data in the list model.
55
56Currently wxWidgets provides the following models apart
57from the base model:
58\helpref{wxDataViewIndexListModel}{wxdataviewindexlistmodel}.
59It is planned to add helper classes for simple tree
60and list stores in the future.
b6b9d556
RR
61
62\wxheading{Derived from}
63
7376079d 64\helpref{wxObjectRefData}{wxobjectrefdata}
b6b9d556
RR
65
66\wxheading{Include files}
67
68<wx/dataview.h>
69
1ab4aff2 70\wxheading{Library}
b6b9d556 71
1ab4aff2 72\helpref{wxAdv}{librarieslist}
1be9182d 73
809e21b5
FM
74
75
76\latexignore{\rtfignore{\wxheading{Members}}}
77
1ab4aff2 78\membersection{wxDataViewModel::wxDataViewModel}\label{wxdataviewmodelwxdataviewmodel}
1be9182d 79
1ab4aff2 80\func{}{wxDataViewModel}{\void}
b6b9d556 81
1ab4aff2 82Constructor.
b6b9d556 83
1ab4aff2 84\membersection{wxDataViewModel::\destruct{wxDataViewModel}}\label{wxdataviewmodeldtor}
b6b9d556 85
1ab4aff2 86\func{}{\destruct{wxDataViewModel}}{\void}
b6b9d556 87
1ab4aff2 88Destructor. This should not be called directly. Use DecRef() instead.
b6b9d556 89
b6b9d556 90
1ab4aff2 91\membersection{wxDataViewModel::AddNotifier}\label{wxdataviewmodeladdnotifier}
b6b9d556 92
1ab4aff2 93\func{void}{AddNotifier}{\param{wxDataViewModelNotifier* }{notifier}}
b6b9d556 94
61cec318 95Adds a \helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier}
1ab4aff2 96to the model.
b6b9d556 97
1ab4aff2 98\membersection{wxDataViewModel::Cleared}\label{wxdataviewmodelcleared}
b6b9d556 99
1ab4aff2 100\func{bool}{Cleared}{\void}
b6b9d556 101
1ab4aff2 102Called to inform the model that all data has been deleted.
b6b9d556 103
1ab4aff2 104\membersection{wxDataViewModel::Compare}\label{wxdataviewmodelcompare}
b6b9d556 105
1ab4aff2 106\func{int}{Compare}{\param{const wxDataViewItem\& }{item1}, \param{const wxDataViewItem\& }{item2}, \param{unsigned int }{column}, \param{bool }{ascending}}
b6b9d556 107
1ab4aff2
RR
108The compare function to be used by control. The default compare function
109sorts by container and other items separately and in ascending order.
110Override this for a different sorting behaviour.
b6b9d556 111
0bd26819
RR
112See also \helpref{HasDefaultCompare}{wxdataviewmodelhasdefaultcompare}.
113
1ab4aff2 114\membersection{wxDataViewModel::GetColumnCount}\label{wxdataviewmodelgetcolumncount}
b6b9d556 115
1ab4aff2 116\constfunc{unsigned int}{GetColumnCount}{\void}
b6b9d556 117
1ab4aff2 118Override this to indicate the number of columns in the model.
b6b9d556 119
1ab4aff2 120\membersection{wxDataViewModel::GetColumnType}\label{wxdataviewmodelgetcolumntype}
b6b9d556 121
1ab4aff2 122\constfunc{wxString}{GetColumnType}{\param{unsigned int }{col}}
b6b9d556 123
1ab4aff2
RR
124Override this to indicate what type of data is stored in the
125column specified by {\it col}. This should return a string
126indicating the type of data as reported by \helpref{wxVariant}{wxvariant}.
b6b9d556 127
1ab4aff2 128\membersection{wxDataViewModel::GetFirstChild}\label{wxdataviewmodelgetfirstchild}
b6b9d556 129
1ab4aff2 130\constfunc{wxDataViewItem}{GetFirstChild}{\param{const wxDataViewItem\& }{parent}}
b6b9d556 131
1ab4aff2 132To be removed.
b6b9d556 133
1ab4aff2 134\membersection{wxDataViewModel::GetNextSibling}\label{wxdataviewmodelgetnextsibling}
b6b9d556 135
1ab4aff2 136\constfunc{wxDataViewItem}{GetNextSibling}{\param{const wxDataViewItem\& }{item}}
b6b9d556 137
1ab4aff2 138To be removed.
b6b9d556 139
1ab4aff2 140\membersection{wxDataViewModel::GetParent}\label{wxdataviewmodelgetparent}
b6b9d556 141
1ab4aff2 142\constfunc{wxDataViewItem}{GetParent}{\param{const wxDataViewItem\& }{item}}
b6b9d556 143
1ab4aff2
RR
144Override this to indicate which wxDataViewItem representing the parent
145of {\it item} or an invalid wxDataViewItem if {\it item} is the root item.
b6b9d556 146
1ab4aff2 147\membersection{wxDataViewModel::GetValue}\label{wxdataviewmodelgetvalue}
b6b9d556 148
1ab4aff2 149\constfunc{void}{GetValue}{\param{wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
b6b9d556 150
1ab4aff2
RR
151Override this to indicate the value of {\it item}
152A \helpref{wxVariant}{wxvariant} is used to store the data.
b6b9d556 153
0bd26819
RR
154\membersection{wxDataViewModel::HasDefaultCompare}\label{wxdataviewmodelhasdefaultcompare}
155
156\func{bool}{HasDefaultCompare}{\void}
157
158Override this to indicate that the model provides a default compare
159function that the control should use if no wxDataViewColumn has been
160chosen for sorting. Usually, the user clicks on a column header for
161sorting, the data will be sorted alphanumerically. If any other
162order (e.g. by index or order of appearance) is required, then this
163should be used. See also \helpref{wxDataViewIndexListModel}{wxdataviewindexlistmodel}
164for a model which makes use of this.
165
1ab4aff2 166\membersection{wxDataViewModel::IsContainer}\label{wxdataviewmodeliscontainer}
b6b9d556 167
1ab4aff2 168\constfunc{bool}{IsContainer}{\param{const wxDataViewItem\& }{item}}
b6b9d556 169
1ab4aff2
RR
170Override this to indicate of {\it item} is a container, i.e. if
171it can have child items.
b6b9d556 172
1ab4aff2 173\membersection{wxDataViewModel::ItemAdded}\label{wxdataviewmodelitemadded}
b6b9d556 174
1ab4aff2 175\func{bool}{ItemAdded}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}}
b6b9d556 176
1ab4aff2
RR
177Call this to inform the model that an item has been added
178to the data.
b6b9d556 179
1ab4aff2 180\membersection{wxDataViewModel::ItemChanged}\label{wxdataviewmodelitemchanged}
b6b9d556 181
1ab4aff2 182\func{bool}{ItemChanged}{\param{const wxDataViewItem\& }{item}}
b6b9d556 183
1ab4aff2 184Call this to inform the model that an item has changed.
b6b9d556 185
1ab4aff2 186\membersection{wxDataViewModel::ItemDeleted}\label{wxdataviewmodelitemdeleted}
b6b9d556 187
1ab4aff2 188\func{bool}{ItemDeleted}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}}
b6b9d556 189
1ab4aff2 190Call this to inform the model that an item has been deleted.
b6b9d556 191
1ab4aff2 192\membersection{wxDataViewModel::RemoveNotifier}\label{wxdataviewmodelremovenotifier}
b6b9d556 193
1ab4aff2 194\func{void}{RemoveNotifier}{\param{wxDataViewModelNotifier* }{notifier}}
b6b9d556 195
1ab4aff2 196Remove the {\it notifier} from the list of notifiers.
b6b9d556 197
1ab4aff2 198\membersection{wxDataViewModel::Resort}\label{wxdataviewmodelresort}
b6b9d556 199
1ab4aff2 200\func{void}{Resort}{\void}
b6b9d556 201
1ab4aff2
RR
202Call this to initiate a resort after the sort function has
203been changed.
b6b9d556 204
1ab4aff2 205\membersection{wxDataViewModel::SetValue}\label{wxdataviewmodelsetvalue}
b6b9d556 206
1ab4aff2 207\func{bool}{SetValue}{\param{const wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
b6b9d556 208
1ab4aff2
RR
209This gets called in order to set a value in the data model.
210The most common scenario is that the wxDataViewCtrl calls
211this method after the user changed some data in the view.
212Afterwards \helpref{ValueChanged}{wxdataviewmodelvaluechanged}
213has to be called!
b6b9d556 214
1ab4aff2 215\membersection{wxDataViewModel::ValueChanged}\label{wxdataviewmodelvaluechanged}
b6b9d556 216
1ab4aff2 217\func{bool}{ValueChanged}{\param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
b6b9d556 218
1ab4aff2
RR
219Call this to inform this model that a value in
220the model has been changed.
b6b9d556 221