2 \section{\class{wxDataViewModel
}}\label{wxdataviewmodel
}
4 wxDataViewModel is the base class for all data model to be
5 displayed by a
\helpref{wxDataViewCtrl
}{wxdataviewctrl
}.
6 All other models derive from it and must implement its
7 pure virtual functions in order to define a complete
8 data 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
14 define the data model which acts as an interface between
15 your actual data and the wxDataViewCtrl. Since you will
16 usually also allow the wxDataViewCtrl to change your data
17 through its graphical interface, you will also have to override
18 \helpref{SetValue
}{wxdataviewmodelsetvalue
} which the
19 wxDataViewCtrl will call when a change to some data has been
22 wxDataViewModel (as indeed the entire wxDataViewCtrl
23 code) is using
\helpref{wxVariant
}{wxvariant
} to store data and
24 its type in a generic way. wxVariant can be extended to contain
25 almost any data without changes to the original class.
27 The data that is presented through this data model is expected
28 to change at run-time. You need to inform the data model when
29 a change happened. Depending on what happened you need to call
30 one of the following methods:
31 \helpref{ValueChanged
}{wxdataviewmodelvaluechanged
},
32 \helpref{ItemAdded
}{wxdataviewmodelitemadded
},
33 \helpref{ItemDeleted
}{wxdataviewmodelitemdeleted
},
34 \helpref{ItemChanged
}{wxdataviewmodelitemchanged
},
35 \helpref{Cleared
}{wxdataviewmodelcleared
}.
37 Note that wxDataViewModel does not define the position or
38 index of any item in the control since several control might
39 display the data differently, but wxDataViewModel does
40 provide a
\helpref{Compare
}{wxdataviewmodelcompare
} method
41 which the wxDataViewCtrl may use to sort the data either
42 in conjunction with a column header or without (see
43 \helpref{HasDefaultCompare
}{wxdataviewmodelhasdefaultcompare
}.
45 This class maintains a list of
46 \helpref{wxDataViewModelNotifier
}{wxdataviewmodelnotifier
}
47 which link this class to the specific implementations on the
48 supported platforms so that e.g. calling
49 \helpref{ValueChanged
}{wxdataviewmodelvaluechanged
}
50 on this model will just call
51 \helpref{wxDataViewModelNotifier::ValueChanged
}{wxdataviewmodelnotifiervaluechanged
}
52 for each notifier that has been added. You can also add
53 your own notifier in order to get informed about any changes
54 to the data in the list model.
56 Currently wxWidgets provides the following models apart
58 \helpref{wxDataViewIndexListModel
}{wxdataviewindexlistmodel
}.
59 It is planned to add helper classes for simple tree
60 and list stores in the future.
62 \wxheading{Derived from
}
64 \helpref{wxObjectRefData
}{wxobjectrefdata
}
66 \wxheading{Include files
}
72 \helpref{wxAdv
}{librarieslist
}
76 \latexignore{\rtfignore{\wxheading{Members
}}}
78 \membersection{wxDataViewModel::wxDataViewModel
}\label{wxdataviewmodelwxdataviewmodel
}
80 \func{}{wxDataViewModel
}{\void}
84 \membersection{wxDataViewModel::
\destruct{wxDataViewModel
}}\label{wxdataviewmodeldtor
}
86 \func{}{\destruct{wxDataViewModel
}}{\void}
88 Destructor. This should not be called directly. Use DecRef() instead.
91 \membersection{wxDataViewModel::AddNotifier
}\label{wxdataviewmodeladdnotifier
}
93 \func{void
}{AddNotifier
}{\param{wxDataViewModelNotifier*
}{notifier
}}
95 Adds a
\helpref{wxDataViewModelNotifier
}{wxdataviewmodelnotifier
}
98 \membersection{wxDataViewModel::Cleared
}\label{wxdataviewmodelcleared
}
100 \func{bool
}{Cleared
}{\void}
102 Called to inform the model that all data has been deleted.
104 \membersection{wxDataViewModel::Compare
}\label{wxdataviewmodelcompare
}
106 \func{int
}{Compare
}{\param{const wxDataViewItem\&
}{item1
},
\param{const wxDataViewItem\&
}{item2
},
\param{unsigned int
}{column
},
\param{bool
}{ascending
}}
108 The compare function to be used by control. The default compare function
109 sorts by container and other items separately and in ascending order.
110 Override this for a different sorting behaviour.
112 See also
\helpref{HasDefaultCompare
}{wxdataviewmodelhasdefaultcompare
}.
114 \membersection{wxDataViewModel::GetColumnCount
}\label{wxdataviewmodelgetcolumncount
}
116 \constfunc{unsigned int
}{GetColumnCount
}{\void}
118 Override this to indicate the number of columns in the model.
120 \membersection{wxDataViewModel::GetColumnType
}\label{wxdataviewmodelgetcolumntype
}
122 \constfunc{wxString
}{GetColumnType
}{\param{unsigned int
}{col
}}
124 Override this to indicate what type of data is stored in the
125 column specified by
{\it col
}. This should return a string
126 indicating the type of data as reported by
\helpref{wxVariant
}{wxvariant
}.
128 \membersection{wxDataViewModel::GetFirstChild
}\label{wxdataviewmodelgetfirstchild
}
130 \constfunc{wxDataViewItem
}{GetFirstChild
}{\param{const wxDataViewItem\&
}{parent
}}
134 \membersection{wxDataViewModel::GetNextSibling
}\label{wxdataviewmodelgetnextsibling
}
136 \constfunc{wxDataViewItem
}{GetNextSibling
}{\param{const wxDataViewItem\&
}{item
}}
140 \membersection{wxDataViewModel::GetParent
}\label{wxdataviewmodelgetparent
}
142 \constfunc{wxDataViewItem
}{GetParent
}{\param{const wxDataViewItem\&
}{item
}}
144 Override this to indicate which wxDataViewItem representing the parent
145 of
{\it item
} or an invalid wxDataViewItem if
{\it item
} is the root item.
147 \membersection{wxDataViewModel::GetValue
}\label{wxdataviewmodelgetvalue
}
149 \constfunc{void
}{GetValue
}{\param{wxVariant\&
}{variant
},
\param{const wxDataViewItem\&
}{item
},
\param{unsigned int
}{col
}}
151 Override this to indicate the value of
{\it item
}
152 A
\helpref{wxVariant
}{wxvariant
} is used to store the data.
154 \membersection{wxDataViewModel::HasDefaultCompare
}\label{wxdataviewmodelhasdefaultcompare
}
156 \func{bool
}{HasDefaultCompare
}{\void}
158 Override this to indicate that the model provides a default compare
159 function that the control should use if no wxDataViewColumn has been
160 chosen for sorting. Usually, the user clicks on a column header for
161 sorting, the data will be sorted alphanumerically. If any other
162 order (e.g. by index or order of appearance) is required, then this
163 should be used. See also
\helpref{wxDataViewIndexListModel
}{wxdataviewindexlistmodel
}
164 for a model which makes use of this.
166 \membersection{wxDataViewModel::IsContainer
}\label{wxdataviewmodeliscontainer
}
168 \constfunc{bool
}{IsContainer
}{\param{const wxDataViewItem\&
}{item
}}
170 Override this to indicate of
{\it item
} is a container, i.e. if
171 it can have child items.
173 \membersection{wxDataViewModel::ItemAdded
}\label{wxdataviewmodelitemadded
}
175 \func{bool
}{ItemAdded
}{\param{const wxDataViewItem\&
}{parent
},
\param{const wxDataViewItem\&
}{item
}}
177 Call this to inform the model that an item has been added
180 \membersection{wxDataViewModel::ItemChanged
}\label{wxdataviewmodelitemchanged
}
182 \func{bool
}{ItemChanged
}{\param{const wxDataViewItem\&
}{item
}}
184 Call this to inform the model that an item has changed.
186 \membersection{wxDataViewModel::ItemDeleted
}\label{wxdataviewmodelitemdeleted
}
188 \func{bool
}{ItemDeleted
}{\param{const wxDataViewItem\&
}{parent
},
\param{const wxDataViewItem\&
}{item
}}
190 Call this to inform the model that an item has been deleted.
192 \membersection{wxDataViewModel::RemoveNotifier
}\label{wxdataviewmodelremovenotifier
}
194 \func{void
}{RemoveNotifier
}{\param{wxDataViewModelNotifier*
}{notifier
}}
196 Remove the
{\it notifier
} from the list of notifiers.
198 \membersection{wxDataViewModel::Resort
}\label{wxdataviewmodelresort
}
200 \func{void
}{Resort
}{\void}
202 Call this to initiate a resort after the sort function has
205 \membersection{wxDataViewModel::SetValue
}\label{wxdataviewmodelsetvalue
}
207 \func{bool
}{SetValue
}{\param{const wxVariant\&
}{variant
},
\param{const wxDataViewItem\&
}{item
},
\param{unsigned int
}{col
}}
209 This gets called in order to set a value in the data model.
210 The most common scenario is that the wxDataViewCtrl calls
211 this method after the user changed some data in the view.
212 Afterwards
\helpref{ValueChanged
}{wxdataviewmodelvaluechanged
}
215 \membersection{wxDataViewModel::ValueChanged
}\label{wxdataviewmodelvaluechanged
}
217 \func{bool
}{ValueChanged
}{\param{const wxDataViewItem\&
}{item
},
\param{unsigned int
}{col
}}
219 Call this to inform this model that a value in
220 the model has been changed.