##// END OF EJS Templates
Remove QML Custom Model from documentation...
Titta Heikkala -
r2633:f1cc99933181
parent child
Show More
@@ -1,253 +1,253
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qvboxplotmodelmapper.h"
21 #include "qvboxplotmodelmapper.h"
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 /*!
25 /*!
26 \class QVBoxPlotModelMapper
26 \class QVBoxPlotModelMapper
27 \brief Vertical model mapper for bar series
27 \brief Vertical model mapper for bar series
28 \mainclass
28 \mainclass
29
29
30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
31 Vertical model mapper is used to create a connection between QBoxPlotSeries and QAbstractItemModel derived model object.
31 Vertical model mapper is used to create a connection between QBoxPlotSeries and QAbstractItemModel derived model object.
32 Model mapper maintains equal size of all the QBoxSets.
32 Model mapper maintains equal size of all the QBoxSets.
33 Note: used model has to support adding/removing rows/columns and modifying the data of the cells.
33 Note: used model has to support adding/removing rows/columns and modifying the data of the cells.
34 */
34 */
35 /*!
35 /*!
36 \qmlclass VBoxPlotModelMapper
36 \qmlclass VBoxPlotModelMapper
37 \mainclass
37 \mainclass
38
38
39 VBoxPlotModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source
39 VBoxPlotModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source
40 for any box-and-whiskers series. It is possible to use both QAbstractItemModel and box-and-whiskers series data API to
40 for any box-and-whiskers series. It is possible to use both QAbstractItemModel and box-and-whiskers series data API to
41 manipulate data.
41 manipulate data.
42 VBoxPlotModelMapper keeps the series and the model in sync.
42 VBoxPlotModelMapper keeps the series and the model in sync.
43
43
44 The following QML example would create a box-and-whiskers series with three box sets (assuming the
44 The following QML example would create a box-and-whiskers series with three box sets (assuming the
45 model has at least four columns). Each box set would contain data starting from row 1. The name of a set would be
45 model has at least four columns). Each box set would contain data starting from row 1. The name of a set would be
46 defined by the horizontal header (of the column).
46 defined by the horizontal header (of the column).
47 \code
47 \code
48 BarSeries {
48 BarSeries {
49 VBarModelMapper {
49 VBarModelMapper {
50 model: myCustomModel // QAbstractItemModel derived implementation
50 model: myCustomModel // QAbstractItemModel derived implementation
51 firstBoxSetColumn: 1
51 firstBoxSetColumn: 1
52 lastBoxSetColumn: 3
52 lastBoxSetColumn: 3
53 firstRow: 1
53 firstRow: 1
54 }
54 }
55 }
55 }
56 \endcode
56 \endcode
57 */
57 */
58
58
59 /*!
59 /*!
60 \property QVBoxPlotModelMapper::series
60 \property QVBoxPlotModelMapper::series
61 \brief Defines the QBoxPlotSeries object that is used by the mapper.
61 \brief Defines the QBoxPlotSeries object that is used by the mapper.
62
62
63 All the data in the series is discarded when it is set to the mapper.
63 All the data in the series is discarded when it is set to the mapper.
64 When new series is specified the old series is disconnected (it preserves its data)
64 When new series is specified the old series is disconnected (it preserves its data)
65 */
65 */
66 /*!
66 /*!
67 \qmlproperty AbstractBarSeries VBarModelMapper::series
67 \qmlproperty AbstractBarSeries VBarModelMapper::series
68 Defines the AbstractBarSeries based object that is used by the mapper. All the data in the series is discarded when it is
68 Defines the AbstractBarSeries based object that is used by the mapper. All the data in the series is discarded when it is
69 set to the mapper. When new series is specified the old series is disconnected (it preserves its data).
69 set to the mapper. When new series is specified the old series is disconnected (it preserves its data).
70 */
70 */
71
71
72 /*!
72 /*!
73 \property QVBoxPlotModelMapper::model
73 \property QVBoxPlotModelMapper::model
74 \brief Defines the model that is used by the mapper.
74 \brief Defines the model that is used by the mapper.
75 */
75 */
76 /*!
76 /*!
77 \qmlproperty SomeModel VBarModelMapper::model
77 \qmlproperty SomeModel VBarModelMapper::model
78 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
78 The QAbstractItemModel based model that is used by the mapper. You need to implement the model
79 QML as shown in \l {QML Custom Model} demo application. Note: the model has to support adding/removing rows/columns
79 and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying
80 and modifying the data of the cells.
80 the data of the cells.
81 */
81 */
82
82
83 /*!
83 /*!
84 \property QVBoxPlotModelMapper::firstBoxSetColumn
84 \property QVBoxPlotModelMapper::firstBoxSetColumn
85 \brief Defines which column of the model is used as the data source for the first box-and-whiskers set.
85 \brief Defines which column of the model is used as the data source for the first box-and-whiskers set.
86
86
87 Default value is: -1 (invalid mapping)
87 Default value is: -1 (invalid mapping)
88 */
88 */
89 /*!
89 /*!
90 \qmlproperty int VBarModelMapper::firstBoxSetColumn
90 \qmlproperty int VBarModelMapper::firstBoxSetColumn
91 Defines which column of the model is used as the data source for the first box-and-whiskers set. Default value
91 Defines which column of the model is used as the data source for the first box-and-whiskers set. Default value
92 is: -1 (invalid mapping).
92 is: -1 (invalid mapping).
93 */
93 */
94
94
95 /*!
95 /*!
96 \property QVBoxPlotModelMapper::lastBoxSetColumn
96 \property QVBoxPlotModelMapper::lastBoxSetColumn
97 \brief Defines which column of the model is used as the data source for the last box-and-whiskers set.
97 \brief Defines which column of the model is used as the data source for the last box-and-whiskers set.
98
98
99 Default value is: -1 (invalid mapping)
99 Default value is: -1 (invalid mapping)
100 */
100 */
101 /*!
101 /*!
102 \qmlproperty int VBarModelMapper::lastBoxSetColumn
102 \qmlproperty int VBarModelMapper::lastBoxSetColumn
103 Defines which column of the model is used as the data source for the last box-and-whiskers set. Default
103 Defines which column of the model is used as the data source for the last box-and-whiskers set. Default
104 value is: -1 (invalid mapping).
104 value is: -1 (invalid mapping).
105 */
105 */
106
106
107 /*!
107 /*!
108 \property QVBoxPlotModelMapper::firstRow
108 \property QVBoxPlotModelMapper::firstRow
109 \brief Defines which row of the model contains the first values of the QBoxSets in the series.
109 \brief Defines which row of the model contains the first values of the QBoxSets in the series.
110
110
111 Minimal and default value is: 0
111 Minimal and default value is: 0
112 */
112 */
113 /*!
113 /*!
114 \qmlproperty int VBoxPlotModelMapper::firstRow
114 \qmlproperty int VBoxPlotModelMapper::firstRow
115 Defines which row of the model contains the first values of the QBoxSets in the series.
115 Defines which row of the model contains the first values of the QBoxSets in the series.
116 The default value is 0.
116 The default value is 0.
117 */
117 */
118
118
119 /*!
119 /*!
120 \property QVBoxPlotModelMapper::rowCount
120 \property QVBoxPlotModelMapper::rowCount
121 \brief Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries
121 \brief Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries
122
122
123 Minimal and default value is: -1 (count limited by the number of rows in the model)
123 Minimal and default value is: -1 (count limited by the number of rows in the model)
124 */
124 */
125 /*!
125 /*!
126 \qmlproperty int VBoxModelMapper::rowCount
126 \qmlproperty int VBoxModelMapper::rowCount
127 Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries. The default value is
127 Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries. The default value is
128 -1 (count limited by the number of rows in the model)
128 -1 (count limited by the number of rows in the model)
129 */
129 */
130
130
131 /*!
131 /*!
132 \fn void QVBoxPlotModelMapper::seriesReplaced()
132 \fn void QVBoxPlotModelMapper::seriesReplaced()
133
133
134 Emitted when the series to which mapper is connected to has changed.
134 Emitted when the series to which mapper is connected to has changed.
135 */
135 */
136
136
137 /*!
137 /*!
138 \fn void QVBoxPlotModelMapper::modelReplaced()
138 \fn void QVBoxPlotModelMapper::modelReplaced()
139
139
140 Emitted when the model to which mapper is connected to has changed.
140 Emitted when the model to which mapper is connected to has changed.
141 */
141 */
142
142
143 /*!
143 /*!
144 \fn void QVBoxPlotModelMapper::firstBoxSetColumnChanged()
144 \fn void QVBoxPlotModelMapper::firstBoxSetColumnChanged()
145 Emitted when the firstBoxSetColumn has changed.
145 Emitted when the firstBoxSetColumn has changed.
146 */
146 */
147
147
148 /*!
148 /*!
149 \fn void QVBoxPlotModelMapper::lastBoxSetColumnChanged()
149 \fn void QVBoxPlotModelMapper::lastBoxSetColumnChanged()
150 Emitted when the lastBoxSetColumn has changed.
150 Emitted when the lastBoxSetColumn has changed.
151 */
151 */
152
152
153 /*!
153 /*!
154 \fn void QVBoxPlotModelMapper::firstRowChanged()
154 \fn void QVBoxPlotModelMapper::firstRowChanged()
155 Emitted when the firstRow has changed.
155 Emitted when the firstRow has changed.
156 */
156 */
157
157
158 /*!
158 /*!
159 \fn void QVBoxPlotModelMapper::rowCountChanged()
159 \fn void QVBoxPlotModelMapper::rowCountChanged()
160 Emitted when the rowCount has changed.
160 Emitted when the rowCount has changed.
161 */
161 */
162
162
163 /*!
163 /*!
164 Constructs a mapper object which is a child of \a parent.
164 Constructs a mapper object which is a child of \a parent.
165 */
165 */
166 QVBoxPlotModelMapper::QVBoxPlotModelMapper(QObject *parent) :
166 QVBoxPlotModelMapper::QVBoxPlotModelMapper(QObject *parent) :
167 QBoxPlotModelMapper(parent)
167 QBoxPlotModelMapper(parent)
168 {
168 {
169 QBoxPlotModelMapper::setOrientation(Qt::Vertical);
169 QBoxPlotModelMapper::setOrientation(Qt::Vertical);
170 }
170 }
171
171
172 QAbstractItemModel *QVBoxPlotModelMapper::model() const
172 QAbstractItemModel *QVBoxPlotModelMapper::model() const
173 {
173 {
174 return QBoxPlotModelMapper::model();
174 return QBoxPlotModelMapper::model();
175 }
175 }
176
176
177 void QVBoxPlotModelMapper::setModel(QAbstractItemModel *model)
177 void QVBoxPlotModelMapper::setModel(QAbstractItemModel *model)
178 {
178 {
179 if (model != QBoxPlotModelMapper::model()) {
179 if (model != QBoxPlotModelMapper::model()) {
180 QBoxPlotModelMapper::setModel(model);
180 QBoxPlotModelMapper::setModel(model);
181 emit modelReplaced();
181 emit modelReplaced();
182 }
182 }
183 }
183 }
184
184
185 QBoxPlotSeries *QVBoxPlotModelMapper::series() const
185 QBoxPlotSeries *QVBoxPlotModelMapper::series() const
186 {
186 {
187 return QBoxPlotModelMapper::series();
187 return QBoxPlotModelMapper::series();
188 }
188 }
189
189
190 void QVBoxPlotModelMapper::setSeries(QBoxPlotSeries *series)
190 void QVBoxPlotModelMapper::setSeries(QBoxPlotSeries *series)
191 {
191 {
192 if (series != QBoxPlotModelMapper::series()) {
192 if (series != QBoxPlotModelMapper::series()) {
193 QBoxPlotModelMapper::setSeries(series);
193 QBoxPlotModelMapper::setSeries(series);
194 emit seriesReplaced();
194 emit seriesReplaced();
195 }
195 }
196 }
196 }
197
197
198 int QVBoxPlotModelMapper::firstBoxSetColumn() const
198 int QVBoxPlotModelMapper::firstBoxSetColumn() const
199 {
199 {
200 return QBoxPlotModelMapper::firstBoxSetSection();
200 return QBoxPlotModelMapper::firstBoxSetSection();
201 }
201 }
202
202
203 void QVBoxPlotModelMapper::setFirstBoxSetColumn(int firstBoxSetColumn)
203 void QVBoxPlotModelMapper::setFirstBoxSetColumn(int firstBoxSetColumn)
204 {
204 {
205 if (firstBoxSetColumn != firstBoxSetSection()) {
205 if (firstBoxSetColumn != firstBoxSetSection()) {
206 QBoxPlotModelMapper::setFirstBoxSetSection(firstBoxSetColumn);
206 QBoxPlotModelMapper::setFirstBoxSetSection(firstBoxSetColumn);
207 emit firstBoxSetColumnChanged();
207 emit firstBoxSetColumnChanged();
208 }
208 }
209 }
209 }
210
210
211 int QVBoxPlotModelMapper::lastBoxSetColumn() const
211 int QVBoxPlotModelMapper::lastBoxSetColumn() const
212 {
212 {
213 return QBoxPlotModelMapper::lastBoxSetSection();
213 return QBoxPlotModelMapper::lastBoxSetSection();
214 }
214 }
215
215
216 void QVBoxPlotModelMapper::setLastBoxSetColumn(int lastBoxSetColumn)
216 void QVBoxPlotModelMapper::setLastBoxSetColumn(int lastBoxSetColumn)
217 {
217 {
218 if (lastBoxSetColumn != lastBoxSetSection()) {
218 if (lastBoxSetColumn != lastBoxSetSection()) {
219 QBoxPlotModelMapper::setLastBoxSetSection(lastBoxSetColumn);
219 QBoxPlotModelMapper::setLastBoxSetSection(lastBoxSetColumn);
220 emit lastBoxSetColumnChanged();
220 emit lastBoxSetColumnChanged();
221 }
221 }
222 }
222 }
223
223
224 int QVBoxPlotModelMapper::firstRow() const
224 int QVBoxPlotModelMapper::firstRow() const
225 {
225 {
226 return QBoxPlotModelMapper::first();
226 return QBoxPlotModelMapper::first();
227 }
227 }
228
228
229 void QVBoxPlotModelMapper::setFirstRow(int firstRow)
229 void QVBoxPlotModelMapper::setFirstRow(int firstRow)
230 {
230 {
231 if (firstRow != first()) {
231 if (firstRow != first()) {
232 QBoxPlotModelMapper::setFirst(firstRow);
232 QBoxPlotModelMapper::setFirst(firstRow);
233 emit firstRowChanged();
233 emit firstRowChanged();
234 }
234 }
235 }
235 }
236
236
237 int QVBoxPlotModelMapper::rowCount() const
237 int QVBoxPlotModelMapper::rowCount() const
238 {
238 {
239 return QBoxPlotModelMapper::count();
239 return QBoxPlotModelMapper::count();
240 }
240 }
241
241
242 void QVBoxPlotModelMapper::setRowCount(int rowCount)
242 void QVBoxPlotModelMapper::setRowCount(int rowCount)
243 {
243 {
244 if (rowCount != count()) {
244 if (rowCount != count()) {
245 QBoxPlotModelMapper::setCount(rowCount);
245 QBoxPlotModelMapper::setCount(rowCount);
246 emit rowCountChanged();
246 emit rowCountChanged();
247 }
247 }
248 }
248 }
249
249
250 #include "moc_qvboxplotmodelmapper.cpp"
250 #include "moc_qvboxplotmodelmapper.cpp"
251
251
252 QTCOMMERCIALCHART_END_NAMESPACE
252 QTCOMMERCIALCHART_END_NAMESPACE
253
253
General Comments 0
You need to be logged in to leave comments. Login now