##// END OF EJS Templates
QML model mapper documentation for pie and xy
Tero Ahola -
r1516:267764825d23
parent child
Show More
@@ -1,248 +1,249
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qhbarmodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QHBarModelMapper
27 27 \brief Horizontal model mapper for bar series
28 28 \mainclass
29 29
30 30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
31 31 Horizontal model mapper is used to create a connection between QBarSeries and QAbstractItemModel derived model object.
32 32 Model mapper maintains equal size of all the BarSets.
33 33 Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series.
34 34 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
35 35 */
36 36 /*!
37 37 \qmlclass HBarModelMapper QHBarModelMapper
38 \mainclass
39 38
40 39 HBarModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source
41 for any bar series. Adding/removing value from the BarSet causes the the same change in the rest of the BarSets
42 added to the same series. The following QML example would create a bar series with three bar sets (assuming the
43 model has at least four rows). Each bar set would contain data starting from column 1. The name of a set would be
44 defined by the vertical header (of the row).
40 for any bar series. It is possible to use both QAbstractItemModel and bar series data API to manipulate data.
41 HBarModelMapper keeps the series and the model in sync.
42
43 The following QML example would create a bar series with three bar sets (assuming the model has
44 at least four rows). Each bar set would contain data starting from column 1. The name of a set would be defined by
45 the vertical header (of the row).
45 46 \code
46 47 BarSeries {
47 48 HBarModelMapper {
48 49 model: myCustomModel // QAbstractItemModel derived implementation
49 50 firstBarSetRow: 1
50 51 lastBarSetRow: 3
51 52 firstColumn: 1
52 53 }
53 54 }
54 55 \endcode
55 56 */
56 57
57 58 /*!
58 59 \property QHBarModelMapper::series
59 60 \brief Defines the QPieSeries object that is used by the mapper.
60 61
61 62 All the data in the series is discarded when it is set to the mapper.
62 63 When new series is specified the old series is disconnected (it preserves its data)
63 64 */
64 65 /*!
65 66 \qmlproperty BarSeries HBarModelMapper::series
66 67 Defines the BarSeries based object that is used by the mapper. All the data in the series is discarded when it is
67 68 set to the mapper. When new series is specified the old series is disconnected (it preserves its data).
68 69 */
69 70
70 71 /*!
71 72 \property QHBarModelMapper::model
72 73 \brief Defines the model that is used by the mapper.
73 74 */
74 75 /*!
75 \qmlproperty Model HBarModelMapper::model
76 \qmlproperty SomeModel HBarModelMapper::model
76 77 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
77 78 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
78 79 and modifying the data of the cells.
79 80 */
80 81
81 82 /*!
82 83 \property QHBarModelMapper::firstBarSetRow
83 84 \brief Defines which column of the model is used as the data source for the first bar set
84 85 Default value is: -1 (invalid mapping)
85 86 */
86 87 /*!
87 88 \qmlproperty int HBarModelMapper::firstBarSetRow
88 89 Defines which column of the model is used as the data source for the first bar set. The default value is -1
89 90 (invalid mapping).
90 91 */
91 92
92 93 /*!
93 94 \property QHBarModelMapper::lastBarSetRow
94 95 \brief Defines which column of the model is used as the data source for the last bar set
95 96 Default value is: -1 (invalid mapping)
96 97 */
97 98 /*!
98 99 \qmlproperty int HBarModelMapper::lastBarSetRow
99 100 Defines which column of the model is used as the data source for the last bar set. The default value is -1
100 101 (invalid mapping).
101 102 */
102 103
103 104 /*!
104 105 \property QHBarModelMapper::firstColumn
105 106 \brief Defines which column of the model contains the first values of the QBarSets in the series.
106 107 Minimal and default value is: 0
107 108 */
108 109 /*!
109 110 \qmlproperty int HBarModelMapper::firstColumn
110 111 Defines which column of the model contains the first values of the QBarSets in the series.
111 112 The default value is 0.
112 113 */
113 114
114 115 /*!
115 116 \property QHBarModelMapper::columnCount
116 117 \brief Defines the number of columns of the model that are mapped as the data for QBarSeries
117 118 Minimal and default value is: -1 (count limited by the number of columns in the model)
118 119 */
119 120 /*!
120 121 \qmlproperty int HBarModelMapper::columnCount
121 122 Defines the number of columns of the model that are mapped as the data for QBarSeries. The default value is
122 123 -1 (count limited by the number of columns in the model)
123 124 */
124 125
125 126 /*!
126 127 \fn void QHBarModelMapper::seriesReplaced()
127 128
128 129 Emitted when the series to which mapper is connected to has changed.
129 130 */
130 131
131 132 /*!
132 133 \fn void QHBarModelMapper::modelReplaced()
133 134
134 135 Emitted when the model to which mapper is connected to has changed.
135 136 */
136 137
137 138 /*!
138 139 \fn void QHBarModelMapper::firstBarSetRowChanged()
139 140
140 141 Emitted when the firstBarSetRow has changed.
141 142 */
142 143
143 144 /*!
144 145 \fn void QHBarModelMapper::lastBarSetRowChanged()
145 146
146 147 Emitted when the lastBarSetRow has changed.
147 148 */
148 149
149 150 /*!
150 151 \fn void QHBarModelMapper::firstColumnChanged()
151 152 Emitted when the firstColumn has changed.
152 153 */
153 154
154 155 /*!
155 156 \fn void QHBarModelMapper::columnCountChanged()
156 157 Emitted when the columnCount has changed.
157 158 */
158 159
159 160 /*!
160 161 Constructs a mapper object which is a child of \a parent.
161 162 */
162 163 QHBarModelMapper::QHBarModelMapper(QObject *parent) :
163 164 QBarModelMapper(parent)
164 165 {
165 166 QBarModelMapper::setOrientation(Qt::Horizontal);
166 167 }
167 168
168 169 QAbstractItemModel* QHBarModelMapper::model() const
169 170 {
170 171 return QBarModelMapper::model();
171 172 }
172 173
173 174 void QHBarModelMapper::setModel(QAbstractItemModel *model)
174 175 {
175 176 if (model != QBarModelMapper::model()) {
176 177 QBarModelMapper::setModel(model);
177 178 emit modelReplaced();
178 179 }
179 180 }
180 181
181 182 QBarSeries* QHBarModelMapper::series() const
182 183 {
183 184 return QBarModelMapper::series();
184 185 }
185 186
186 187 void QHBarModelMapper::setSeries(QBarSeries *series)
187 188 {
188 189 if (series != QBarModelMapper::series()) {
189 190 QBarModelMapper::setSeries(series);
190 191 emit seriesReplaced();
191 192 }
192 193 }
193 194
194 195 int QHBarModelMapper::firstBarSetRow() const
195 196 {
196 197 return QBarModelMapper::firstBarSetSection();
197 198 }
198 199
199 200 void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow)
200 201 {
201 202 if (firstBarSetRow != firstBarSetSection()) {
202 203 QBarModelMapper::setFirstBarSetSection(firstBarSetRow);
203 204 emit firstBarSetRowChanged();
204 205 }
205 206 }
206 207
207 208 int QHBarModelMapper::lastBarSetRow() const
208 209 {
209 210 return QBarModelMapper::lastBarSetSection();
210 211 }
211 212
212 213 void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow)
213 214 {
214 215 if (lastBarSetRow != lastBarSetSection()) {
215 216 QBarModelMapper::setLastBarSetSection(lastBarSetRow);
216 217 emit lastBarSetRowChanged();
217 218 }
218 219 }
219 220
220 221 int QHBarModelMapper::firstColumn() const
221 222 {
222 223 return QBarModelMapper::first();
223 224 }
224 225
225 226 void QHBarModelMapper::setFirstColumn(int firstColumn)
226 227 {
227 228 if (firstColumn != first()) {
228 229 QBarModelMapper::setFirst(firstColumn);
229 230 emit firstColumnChanged();
230 231 }
231 232 }
232 233
233 234 int QHBarModelMapper::columnCount() const
234 235 {
235 236 return QBarModelMapper::count();
236 237 }
237 238
238 239 void QHBarModelMapper::setColumnCount(int columnCount)
239 240 {
240 241 if (columnCount != count()) {
241 242 QBarModelMapper::setCount(columnCount);
242 243 emit firstColumnChanged();
243 244 }
244 245 }
245 246
246 247 #include "moc_qhbarmodelmapper.cpp"
247 248
248 249 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,246 +1,248
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qvbarmodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QVBarModelMapper
27 27 \brief Vertical model mapper for bar series
28 28 \mainclass
29 29
30 30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
31 31 Vertical model mapper is used to create a connection between QBarSeries and QAbstractItemModel derived model object.
32 32 Model mapper maintains equal size of all the BarSets.
33 33 Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series.
34 34 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
35 35 */
36 36 /*!
37 37 \qmlclass VBarModelMapper
38 38 \mainclass
39 39
40 40 VBarModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source
41 for any bar series. Adding/removing value from the BarSet causes the the same change in the rest of the BarSets
42 added to the same series. The following QML example would create a bar series with three bar sets (assuming the
41 for any bar series. It is possible to use both QAbstractItemModel and bar series data API to manipulate data.
42 VBarModelMapper keeps the series and the model in sync.
43
44 The following QML example would create a bar series with three bar sets (assuming the
43 45 model has at least four columns). Each bar set would contain data starting from row 1. The name of a set would be
44 46 defined by the horizontal header (of the column).
45 47 \code
46 48 GroupedBarSeries {
47 49 VBarModelMapper {
48 50 model: myCustomModel // QAbstractItemModel derived implementation
49 51 firstBarSetColumn: 1
50 52 lastBarSetColumn: 3
51 53 firstRow: 1
52 54 }
53 55 }
54 56 \endcode
55 57 */
56 58
57 59 /*!
58 60 \property QVBarModelMapper::series
59 61 \brief Defines the QPieSeries object that is used by the mapper.
60 62
61 63 All the data in the series is discarded when it is set to the mapper.
62 64 When new series is specified the old series is disconnected (it preserves its data)
63 65 */
64 66 /*!
65 67 \qmlproperty BarSeries VBarModelMapper::series
66 68 Defines the BarSeries based object that is used by the mapper. All the data in the series is discarded when it is
67 69 set to the mapper. When new series is specified the old series is disconnected (it preserves its data).
68 70 */
69 71
70 72 /*!
71 73 \property QVBarModelMapper::model
72 74 \brief Defines the model that is used by the mapper.
73 75 */
74 76 /*!
75 \qmlproperty Model VBarModelMapper::model
77 \qmlproperty SomeModel VBarModelMapper::model
76 78 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
77 79 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
78 80 and modifying the data of the cells.
79 81 */
80 82
81 83 /*!
82 84 \property QVBarModelMapper::firstBarSetColumn
83 85 \brief Defines which column of the model is used as the data source for the first bar set
84 86 Default value is: -1 (invalid mapping)
85 87 */
86 88 /*!
87 89 \qmlproperty int VBarModelMapper::firstBarSetColumn
88 90 Defines which column of the model is used as the data source for the first bar set. Default value
89 91 is: -1 (invalid mapping).
90 92 */
91 93
92 94 /*!
93 95 \property QVBarModelMapper::lastBarSetColumn
94 96 \brief Defines which column of the model is used as the data source for the last bar set
95 97 Default value is: -1 (invalid mapping)
96 98 */
97 99 /*!
98 100 \qmlproperty int VBarModelMapper::lastBarSetColumn
99 101 Defines which column of the model is used as the data source for the last bar set. Default
100 102 value is: -1 (invalid mapping).
101 103 */
102 104
103 105 /*!
104 106 \property QVBarModelMapper::firstRow
105 107 \brief Defines which row of the model contains the first values of the QBarSets in the series.
106 108 Minimal and default value is: 0
107 109 */
108 110 /*!
109 111 \qmlproperty int VBarModelMapper::firstRow
110 112 Defines which row of the model contains the first values of the QBarSets in the series.
111 113 The default value is 0.
112 114 */
113 115
114 116 /*!
115 117 \property QVBarModelMapper::rowCount
116 118 \brief Defines the number of rows of the model that are mapped as the data for QBarSeries
117 119 Minimal and default value is: -1 (count limited by the number of rows in the model)
118 120 */
119 121 /*!
120 122 \qmlproperty int VBarModelMapper::rowCount
121 123 Defines the number of rows of the model that are mapped as the data for QBarSeries. The default value is
122 124 -1 (count limited by the number of rows in the model)
123 125 */
124 126
125 127 /*!
126 128 \fn void QVBarModelMapper::seriesReplaced()
127 129
128 130 Emitted when the series to which mapper is connected to has changed.
129 131 */
130 132
131 133 /*!
132 134 \fn void QVBarModelMapper::modelReplaced()
133 135
134 136 Emitted when the model to which mapper is connected to has changed.
135 137 */
136 138
137 139 /*!
138 140 \fn void QVBarModelMapper::firstBarSetColumnChanged()
139 141 Emitted when the firstBarSetColumn has changed.
140 142 */
141 143
142 144 /*!
143 145 \fn void QVBarModelMapper::lastBarSetColumnChanged()
144 146 Emitted when the lastBarSetColumn has changed.
145 147 */
146 148
147 149 /*!
148 150 \fn void QVBarModelMapper::firstRowChanged()
149 151 Emitted when the firstRow has changed.
150 152 */
151 153
152 154 /*!
153 155 \fn void QVBarModelMapper::rowCountChanged()
154 156 Emitted when the rowCount has changed.
155 157 */
156 158
157 159 /*!
158 160 Constructs a mapper object which is a child of \a parent.
159 161 */
160 162 QVBarModelMapper::QVBarModelMapper(QObject *parent) :
161 163 QBarModelMapper(parent)
162 164 {
163 165 QBarModelMapper::setOrientation(Qt::Vertical);
164 166 }
165 167
166 168 QAbstractItemModel* QVBarModelMapper::model() const
167 169 {
168 170 return QBarModelMapper::model();
169 171 }
170 172
171 173 void QVBarModelMapper::setModel(QAbstractItemModel *model)
172 174 {
173 175 if (model != QBarModelMapper::model()) {
174 176 QBarModelMapper::setModel(model);
175 177 emit modelReplaced();
176 178 }
177 179 }
178 180
179 181 QBarSeries* QVBarModelMapper::series() const
180 182 {
181 183 return QBarModelMapper::series();
182 184 }
183 185
184 186 void QVBarModelMapper::setSeries(QBarSeries *series)
185 187 {
186 188 if (series != QBarModelMapper::series()) {
187 189 QBarModelMapper::setSeries(series);
188 190 emit seriesReplaced();
189 191 }
190 192 }
191 193
192 194 int QVBarModelMapper::firstBarSetColumn() const
193 195 {
194 196 return QBarModelMapper::firstBarSetSection();
195 197 }
196 198
197 199 void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn)
198 200 {
199 201 if (firstBarSetColumn != firstBarSetSection()) {
200 202 QBarModelMapper::setFirstBarSetSection(firstBarSetColumn);
201 203 emit firstBarSetColumnChanged();
202 204 }
203 205 }
204 206
205 207 int QVBarModelMapper::lastBarSetColumn() const
206 208 {
207 209 return QBarModelMapper::lastBarSetSection();
208 210 }
209 211
210 212 void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn)
211 213 {
212 214 if (lastBarSetColumn != lastBarSetSection()) {
213 215 QBarModelMapper::setLastBarSetSection(lastBarSetColumn);
214 216 emit lastBarSetColumnChanged();
215 217 }
216 218 }
217 219
218 220 int QVBarModelMapper::firstRow() const
219 221 {
220 222 return QBarModelMapper::first();
221 223 }
222 224
223 225 void QVBarModelMapper::setFirstRow(int firstRow)
224 226 {
225 227 if (firstRow != first()) {
226 228 QBarModelMapper::setFirst(firstRow);
227 229 emit firstRowChanged();
228 230 }
229 231 }
230 232
231 233 int QVBarModelMapper::rowCount() const
232 234 {
233 235 return QBarModelMapper::count();
234 236 }
235 237
236 238 void QVBarModelMapper::setRowCount(int rowCount)
237 239 {
238 240 if (rowCount != count()) {
239 241 QBarModelMapper::setCount(rowCount);
240 242 emit firstRowChanged();
241 243 }
242 244 }
243 245
244 246 #include "moc_qvbarmodelmapper.cpp"
245 247
246 248 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,221 +1,257
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qhpiemodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QHPieModelMapper
27 27 \mainclass
28 28
29 29 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
30 30 Horizontal model mapper is used to create a connection between QPieSeries and QAbstractItemModel derived model object that keeps the consecutive pie slices data in rows.
31 31 It is possible to use both QAbstractItemModel and QPieSeries model API. QHPieModelMapper makes sure that Pie and the model are kept in sync.
32 32 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
33 33 */
34 /*!
35 \qmlclass HPieModelMapper QHPieModelMapper
36
37 HPieModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source
38 for a pie series. It is possible to use both QAbstractItemModel and PieSeries data API to manipulate data.
39 HPieModelMapper keeps the Pie and the model in sync.
40
41 The following QML example would create a pie series with four slices (assuming the model has
42 at least five columns). Each slice would contain a label from row 1 and a value from row 2.
43 \code
44 HPieModelMapper {
45 series: pieSeries
46 model: customModel
47 labelsRow: 1
48 valuesRow: 2
49 firstColumn: 1
50 columnCount: 4
51 }
52 \endcode
53 */
34 54
35 55 /*!
36 56 \property QHPieModelMapper::series
37 57 \brief Defines the QPieSeries object that is used by the mapper.
38 58
39 59 All the data in the series is discarded when it is set to the mapper.
40 60 When new series is specified the old series is disconnected (it preserves its data)
41 61 */
62 /*!
63 \qmlproperty PieSeries HPieModelMapper::series
64 Defines the PieSeries object that is used by the mapper. If you define the mapper element as a child for a
65 PieSeries, leave this property undefined. All the data in the series is discarded when it is set to the mapper.
66 When new series is specified the old series is disconnected (it preserves its data).
67 */
42 68
43 69 /*!
44 70 \property QHPieModelMapper::model
45 71 \brief Defines the model that is used by the mapper.
46 72 */
73 /*!
74 \qmlproperty SomeModel HPieModelMapper::model
75 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
76 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
77 and modifying the data of the cells.
78 */
47 79
48 80 /*!
49 81 \property QHPieModelMapper::valuesRow
50 82 \brief Defines which row of the model is kept in sync with the values of the pie's slices
51
52 83 Default value is: -1 (invalid mapping)
53 84 */
85 /*!
86 \qmlproperty int HPieModelMapper::valuesRow
87 Defines which row of the model is kept in sync with the values of the pie's slices. Default value is: -1 (invalid
88 mapping).
89 */
54 90
55 91 /*!
56 92 \property QHPieModelMapper::labelsRow
57 93 \brief Defines which row of the model is kept in sync with the labels of the pie's slices
58
94 Default value is: -1 (invalid mapping)
95 */
96 /*!
97 \qmlproperty int HPieModelMapper::labelsRow
98 Defines which row of the model is kept in sync with the labels of the pie's slices
59 99 Default value is: -1 (invalid mapping)
60 100 */
61 101
62 102 /*!
63 103 \property QHPieModelMapper::firstColumn
64 104 \brief Defines which column of the model contains the first slice value.
65 105 Minimal and default value is: 0
66 106 */
67 107 /*!
68 \qmlproperty int QHPieModelMapper::firstColumn
108 \qmlproperty int HPieModelMapper::firstColumn
69 109 Defines which column of the model contains the first slice value.
70 110 The default value is 0.
71 111 */
72 112
73 113 /*!
74 114 \property QHPieModelMapper::columnCount
75 115 \brief Defines the number of columns of the model that are mapped as the data for QPieSeries
76 116 Minimal and default value is: -1 (count limited by the number of columns in the model)
77 117 */
78 118 /*!
79 \qmlproperty int QHPieModelMapper::columnCount
119 \qmlproperty int HPieModelMapper::columnCount
80 120 Defines the number of columns of the model that are mapped as the data for QPieSeries. The default value is
81 121 -1 (count limited by the number of columns in the model)
82 122 */
83 123
84 124 /*!
85 125 \fn void QHPieModelMapper::seriesReplaced()
86
87 126 Emitted when the series to which mapper is connected to has changed.
88 127 */
89 128
90 129 /*!
91 130 \fn void QHPieModelMapper::modelReplaced()
92
93 131 Emitted when the model to which mapper is connected to has changed.
94 132 */
95 133
96 134 /*!
97 135 \fn void QHPieModelMapper::valuesRowChanged()
98
99 136 Emitted when the valuesRow has changed.
100 137 */
101 138
102 139 /*!
103 140 \fn void QHPieModelMapper::labelsRowChanged()
104
105 141 Emitted when the labelsRow has changed.
106 142 */
107 143
108 144 /*!
109 145 \fn void QHPieModelMapper::firstColumnChanged()
110 146 Emitted when the firstColumn has changed.
111 147 */
112 148
113 149 /*!
114 150 \fn void QHPieModelMapper::columnCountChanged()
115 151 Emitted when the columnCount has changed.
116 152 */
117 153
118 154 /*!
119 155 Constructs a mapper object which is a child of \a parent.
120 156 */
121 157 QHPieModelMapper::QHPieModelMapper(QObject *parent) :
122 158 QPieModelMapper(parent)
123 159 {
124 160 setOrientation(Qt::Horizontal);
125 161 }
126 162
127 163 QAbstractItemModel* QHPieModelMapper::model() const
128 164 {
129 165 return QPieModelMapper::model();
130 166 }
131 167
132 168 void QHPieModelMapper::setModel(QAbstractItemModel *model)
133 169 {
134 170 if (model != QPieModelMapper::model()) {
135 171 QPieModelMapper::setModel(model);
136 172 emit modelReplaced();
137 173 }
138 174 }
139 175
140 176 QPieSeries* QHPieModelMapper::series() const
141 177 {
142 178 return QPieModelMapper::series();
143 179 }
144 180
145 181 void QHPieModelMapper::setSeries(QPieSeries *series)
146 182 {
147 183 if (series != QPieModelMapper::series()) {
148 184 QPieModelMapper::setSeries(series);
149 185 emit seriesReplaced();
150 186 }
151 187 }
152 188
153 189 /*!
154 190 Returns which row of the model is kept in sync with the values of the pie's slices
155 191 */
156 192 int QHPieModelMapper::valuesRow() const
157 193 {
158 194 return valuesSection();
159 195 }
160 196
161 197 /*!
162 198 Sets the model row that is kept in sync with the pie slices values.
163 199 Parameter \a valuesRow specifies the row of the model.
164 200 */
165 201 void QHPieModelMapper::setValuesRow(int valuesRow)
166 202 {
167 203 if (valuesRow != valuesSection()) {
168 204 setValuesSection(valuesRow);
169 205 emit valuesRowChanged();
170 206 }
171 207 }
172 208
173 209 /*!
174 210 Returns which row of the model is kept in sync with the labels of the pie's slices
175 211 */
176 212 int QHPieModelMapper::labelsRow() const
177 213 {
178 214 return labelsSection();
179 215 }
180 216
181 217 /*!
182 218 Sets the model row that is kept in sync with the pie's slices labels.
183 219 Parameter \a labelsRow specifies the row of the model.
184 220 */
185 221 void QHPieModelMapper::setLabelsRow(int labelsRow)
186 222 {
187 223 if (labelsRow != labelsSection()) {
188 224 setLabelsSection(labelsRow);
189 225 emit labelsRowChanged();
190 226 }
191 227 }
192 228
193 229 int QHPieModelMapper::firstColumn() const
194 230 {
195 231 return first();
196 232 }
197 233
198 234 void QHPieModelMapper::setFirstColumn(int firstColumn)
199 235 {
200 236 if (firstColumn != first()) {
201 237 setFirst(firstColumn);
202 238 emit firstColumnChanged();
203 239 }
204 240 }
205 241
206 242 int QHPieModelMapper::columnCount() const
207 243 {
208 244 return count();
209 245 }
210 246
211 247 void QHPieModelMapper::setColumnCount(int columnCount)
212 248 {
213 249 if (columnCount != count()) {
214 250 setCount(columnCount);
215 251 emit firstColumnChanged();
216 252 }
217 253 }
218 254
219 255 #include "moc_qhpiemodelmapper.cpp"
220 256
221 257 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,221 +1,260
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qvpiemodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QVPieModelMapper
27 27 \mainclass
28 28
29 29 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
30 30 Vertical model mapper is used to create a connection between QPieSeries and QAbstractItemModel derived model object that keeps the consecutive pie slices data in columns.
31 31 It is possible to use both QAbstractItemModel and QPieSeries model API. QVPieModelMapper makes sure that Pie and the model are kept in sync.
32 32 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
33 33 */
34 /*!
35 \qmlclass VPieModelMapper QVPieModelMapper
36
37 VPieModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source
38 for a pie series. It is possible to use both QAbstractItemModel and PieSeries data API to manipulate data.
39 VPieModelMapper keeps the Pie and the model in sync.
40
41 The following QML example would create a pie series with four slices (assuming the model has at least five rows).
42 Each slice would contain a label from column 1 and a value from column 2.
43 \code
44 VPieModelMapper {
45 series: pieSeries
46 model: customModel
47 labelsColumn: 1
48 valuesColumn: 2
49 firstRow: 1
50 rowCount: 4
51 }
52 \endcode
53 */
34 54
35 55 /*!
36 56 \property QVPieModelMapper::series
37 57 \brief Defines the QPieSeries object that is used by the mapper.
38
39 58 All the data in the series is discarded when it is set to the mapper.
40 59 When new series is specified the old series is disconnected (it preserves its data)
41 60 */
61 /*!
62 \qmlproperty PieSeries VPieModelMapper::series
63 Defines the PieSeries object that is used by the mapper. If you define the mapper element as a child for a
64 PieSeries, leave this property undefined. All the data in the series is discarded when it is set to the mapper.
65 When new series is specified the old series is disconnected (it preserves its data).
66 */
42 67
43 68 /*!
44 69 \property QVPieModelMapper::model
45 70 \brief Defines the model that is used by the mapper.
46 71 */
72 /*!
73 \qmlproperty SomeModel VPieModelMapper::model
74 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
75 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
76 and modifying the data of the cells.
77 */
47 78
48 79 /*!
49 80 \property QVPieModelMapper::valuesColumn
50 81 \brief Defines which column of the model is kept in sync with the values of the pie's slices
51
52 82 Default value is: -1 (invalid mapping)
53 83 */
84 /*!
85 \qmlproperty int VPieModelMapper::valuesColumn
86 Defines which column of the model is kept in sync with the values of the pie's slices. Default value is -1 (invalid
87 mapping).
88 */
54 89
55 90 /*!
56 91 \property QVPieModelMapper::labelsColumn
57 92 \brief Defines which column of the model is kept in sync with the labels of the pie's slices
58
59 93 Default value is: -1 (invalid mapping)
60 94 */
95 /*!
96 \qmlproperty int VPieModelMapper::labelsColumn
97 Defines which column of the model is kept in sync with the labels of the pie's slices. Default value is -1 (invalid
98 mapping).
99 */
61 100
62 101 /*!
63 102 \property QVPieModelMapper::firstRow
64 103 \brief Defines which row of the model contains the first slice value.
65 104 Minimal and default value is: 0
66 105 */
67 106 /*!
68 \qmlproperty int QVPieModelMapper::firstRow
107 \qmlproperty int VPieModelMapper::firstRow
69 108 Defines which row of the model contains the first slice value.
70 109 The default value is 0.
71 110 */
72 111
73 112 /*!
74 113 \property QVPieModelMapper::rowCount
75 114 \brief Defines the number of rows of the model that are mapped as the data for QPieSeries
76 115 Minimal and default value is: -1 (count limited by the number of rows in the model)
77 116 */
78 117 /*!
79 \qmlproperty int QVPieModelMapper::columnCount
118 \qmlproperty int VPieModelMapper::columnCount
80 119 Defines the number of rows of the model that are mapped as the data for QPieSeries. The default value is
81 120 -1 (count limited by the number of rows in the model)
82 121 */
83 122
84 123 /*!
85 124 \fn void QVPieModelMapper::seriesReplaced()
86 125
87 126 Emitted when the series to which mapper is connected to has changed.
88 127 */
89 128
90 129 /*!
91 130 \fn void QVPieModelMapper::modelReplaced()
92 131
93 132 Emitted when the model to which mapper is connected to has changed.
94 133 */
95 134
96 135 /*!
97 136 \fn void QVPieModelMapper::valuesColumnChanged()
98 137
99 138 Emitted when the valuesColumn has changed.
100 139 */
101 140
102 141 /*!
103 142 \fn void QVPieModelMapper::labelsColumnChanged()
104 143
105 144 Emitted when the labelsColumn has changed.
106 145 */
107 146
108 147 /*!
109 148 \fn void QVPieModelMapper::firstRowChanged()
110 149 Emitted when the firstRow has changed.
111 150 */
112 151
113 152 /*!
114 153 \fn void QVPieModelMapper::rowCountChanged()
115 154 Emitted when the rowCount has changed.
116 155 */
117 156
118 157 /*!
119 158 Constructs a mapper object which is a child of \a parent.
120 159 */
121 160 QVPieModelMapper::QVPieModelMapper(QObject *parent) :
122 161 QPieModelMapper(parent)
123 162 {
124 163 QPieModelMapper::setOrientation(Qt::Vertical);
125 164 }
126 165
127 166 QAbstractItemModel* QVPieModelMapper::model() const
128 167 {
129 168 return QPieModelMapper::model();
130 169 }
131 170
132 171 void QVPieModelMapper::setModel(QAbstractItemModel *model)
133 172 {
134 173 if (model != QPieModelMapper::model()) {
135 174 QPieModelMapper::setModel(model);
136 175 emit modelReplaced();
137 176 }
138 177 }
139 178
140 179 QPieSeries* QVPieModelMapper::series() const
141 180 {
142 181 return QPieModelMapper::series();
143 182 }
144 183
145 184 void QVPieModelMapper::setSeries(QPieSeries *series)
146 185 {
147 186 if (series != QPieModelMapper::series()) {
148 187 QPieModelMapper::setSeries(series);
149 188 emit seriesReplaced();
150 189 }
151 190 }
152 191
153 192 /*!
154 193 Returns which column of the model is kept in sync with the values of the pie's slices
155 194 */
156 195 int QVPieModelMapper::valuesColumn() const
157 196 {
158 197 return QPieModelMapper::valuesSection();
159 198 }
160 199
161 200 /*!
162 201 Sets the model column that is kept in sync with the pie slices values.
163 202 Parameter \a valuesColumn specifies the row of the model.
164 203 */
165 204 void QVPieModelMapper::setValuesColumn(int valuesColumn)
166 205 {
167 206 if (valuesColumn != valuesSection()) {
168 207 QPieModelMapper::setValuesSection(valuesColumn);
169 208 emit valuesColumnChanged();
170 209 }
171 210 }
172 211
173 212 /*!
174 213 Returns which column of the model is kept in sync with the labels of the pie's slices
175 214 */
176 215 int QVPieModelMapper::labelsColumn() const
177 216 {
178 217 return QPieModelMapper::labelsSection();
179 218 }
180 219
181 220 /*!
182 221 Sets the model column that is kept in sync with the pie's slices labels.
183 222 Parameter \a labelsColumn specifies the row of the model.
184 223 */
185 224 void QVPieModelMapper::setLabelsColumn(int labelsColumn)
186 225 {
187 226 if (labelsColumn != labelsSection()) {
188 227 QPieModelMapper::setLabelsSection(labelsColumn);
189 228 emit labelsColumnChanged();
190 229 }
191 230 }
192 231
193 232 int QVPieModelMapper::firstRow() const
194 233 {
195 234 return first();
196 235 }
197 236
198 237 void QVPieModelMapper::setFirstRow(int firstRow)
199 238 {
200 239 if (firstRow != first()) {
201 240 setFirst(firstRow);
202 241 emit firstRowChanged();
203 242 }
204 243 }
205 244
206 245 int QVPieModelMapper::rowCount() const
207 246 {
208 247 return count();
209 248 }
210 249
211 250 void QVPieModelMapper::setRowCount(int rowCount)
212 251 {
213 252 if (rowCount != count()) {
214 253 setCount(rowCount);
215 254 emit firstRowChanged();
216 255 }
217 256 }
218 257
219 258 #include "moc_qvpiemodelmapper.cpp"
220 259
221 260 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,206 +1,232
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qhxymodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QHXYModelMapper
27 27 \mainclass
28 28
29 29 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
30 30 Horizontal model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object.
31 31 It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync.
32 32 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
33 33 */
34 /*!
35 \qmlclass HXYModelMapper QHXYModelMapper
36
37 HXYModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source
38 for XYSeries based series. It is possible to use both QAbstractItemModel and XYSeries data API to manipulate data.
39 HXYModelMapper keeps the series and the model in sync.
40 */
34 41
35 42 /*!
36 43 \property QHXYModelMapper::series
37 44 \brief Defines the QXYSeries object that is used by the mapper.
38
39 45 All the data in the series is discarded when it is set to the mapper.
40 46 When new series is specified the old series is disconnected (it preserves its data)
41 47 */
48 /*!
49 \qmlproperty XYSeries HXYModelMapper::series
50 Defines the QXYSeries object that is used by the mapper. All the data in the series is discarded when it is set to
51 the mapper. When new series is specified the old series is disconnected (it preserves its data).
52 */
42 53
43 54 /*!
44 55 \property QHXYModelMapper::model
45 56 \brief Defines the model that is used by the mapper.
46 57 */
58 /*!
59 \qmlproperty SomeModel HXYModelMapper::model
60 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
61 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
62 and modifying the data of the cells.
63 */
47 64
48 65 /*!
49 66 \property QHXYModelMapper::xRow
50 67 \brief Defines which row of the model is kept in sync with the x values of the QXYSeries
51 68 Default value is: -1 (invalid mapping)
52 69 */
70 /*!
71 \qmlproperty int HXYModelMapper::xRow
72 Defines which row of the model is kept in sync with the x values of the QXYSeries. Default value is -1 (invalid
73 mapping).
74 */
53 75
54 76 /*!
55 77 \property QHXYModelMapper::yRow
56 78 \brief Defines which row of the model is kept in sync with the y values of the QXYSeries
57
58 79 Default value is: -1 (invalid mapping)
59 80 */
81 /*!
82 \qmlproperty int HXYModelMapper::yRow
83 Defines which row of the model is kept in sync with the y values of the QXYSeries. Default value is -1
84 (invalid mapping).
85 */
60 86
61 87 /*!
62 88 \property QHXYModelMapper::firstColumn
63 89 \brief Defines which column of the model contains the data for the first point of the series.
64 90 Minimal and default value is: 0
65 91 */
66 92 /*!
67 \qmlproperty int QHXYModelMapper::firstColumn
93 \qmlproperty int HXYModelMapper::firstColumn
68 94 Defines which column of the model contains the data for the first point of the series.
69 95 The default value is 0.
70 96 */
71 97
72 98 /*!
73 99 \property QHXYModelMapper::columnCount
74 100 \brief Defines the number of columns of the model that are mapped as the data for series
75 101 Minimal and default value is: -1 (count limited by the number of columns in the model)
76 102 */
77 103 /*!
78 \qmlproperty int QHXYModelMapper::columnCount
104 \qmlproperty int HXYModelMapper::columnCount
79 105 Defines the number of columns of the model that are mapped as the data for series. The default value is
80 106 -1 (count limited by the number of columns in the model)
81 107 */
82 108
83 109 /*!
84 110 \fn void QHXYModelMapper::seriesReplaced()
85 111
86 112 Emitted when the series to which mapper is connected to has changed.
87 113 */
88 114
89 115 /*!
90 116 \fn void QHXYModelMapper::modelReplaced()
91 117
92 118 Emitted when the model to which mapper is connected to has changed.
93 119 */
94 120
95 121 /*!
96 122 \fn void QHXYModelMapper::xRowChanged()
97 123
98 124 Emitted when the xRow has changed.
99 125 */
100 126
101 127 /*!
102 128 \fn void QHXYModelMapper::yRowChanged()
103 129
104 130 Emitted when the yRow has changed.
105 131 */
106 132
107 133 /*!
108 134 \fn void QHXYModelMapper::firstColumnChanged()
109 135 Emitted when the firstColumn has changed.
110 136 */
111 137
112 138 /*!
113 139 \fn void QHXYModelMapper::columnCountChanged()
114 140 Emitted when the columnCount has changed.
115 141 */
116 142
117 143 /*!
118 144 Constructs a mapper object which is a child of \a parent.
119 145 */
120 146 QHXYModelMapper::QHXYModelMapper(QObject *parent) :
121 147 QXYModelMapper(parent)
122 148 {
123 149 QXYModelMapper::setOrientation(Qt::Horizontal);
124 150 }
125 151
126 152 QAbstractItemModel* QHXYModelMapper::model() const
127 153 {
128 154 return QXYModelMapper::model();
129 155 }
130 156
131 157 void QHXYModelMapper::setModel(QAbstractItemModel *model)
132 158 {
133 159 if (model != QXYModelMapper::model()) {
134 160 QXYModelMapper::setModel(model);
135 161 emit modelReplaced();
136 162 }
137 163 }
138 164
139 165 QXYSeries* QHXYModelMapper::series() const
140 166 {
141 167 return QXYModelMapper::series();
142 168 }
143 169
144 170 void QHXYModelMapper::setSeries(QXYSeries *series)
145 171 {
146 172 if (series != QXYModelMapper::series()) {
147 173 QXYModelMapper::setSeries(series);
148 174 emit seriesReplaced();
149 175 }
150 176 }
151 177
152 178 int QHXYModelMapper::xRow() const
153 179 {
154 180 return QXYModelMapper::xSection();
155 181 }
156 182
157 183 void QHXYModelMapper::setXRow(int xRow)
158 184 {
159 185 if (xRow != xSection()) {
160 186 return QXYModelMapper::setXSection(xRow);
161 187 emit xRowChanged();
162 188 }
163 189 }
164 190
165 191 int QHXYModelMapper::yRow() const
166 192 {
167 193 return QXYModelMapper::ySection();
168 194 }
169 195
170 196 void QHXYModelMapper::setYRow(int yRow)
171 197 {
172 198 if (yRow != ySection()) {
173 199 return QXYModelMapper::setYSection(yRow);
174 200 emit yRowChanged();
175 201 }
176 202 }
177 203
178 204 int QHXYModelMapper::firstColumn() const
179 205 {
180 206 return first();
181 207 }
182 208
183 209 void QHXYModelMapper::setFirstColumn(int firstColumn)
184 210 {
185 211 if (firstColumn != first()) {
186 212 setFirst(firstColumn);
187 213 emit firstColumnChanged();
188 214 }
189 215 }
190 216
191 217 int QHXYModelMapper::columnCount() const
192 218 {
193 219 return count();
194 220 }
195 221
196 222 void QHXYModelMapper::setColumnCount(int columnCount)
197 223 {
198 224 if (columnCount != count()) {
199 225 setCount(columnCount);
200 226 emit firstColumnChanged();
201 227 }
202 228 }
203 229
204 230 #include "moc_qhxymodelmapper.cpp"
205 231
206 232 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,207 +1,232
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qvxymodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QVXYModelMapper
27 27 \mainclass
28 28
29 29 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
30 30 Vertical model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object.
31 31 It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync.
32 32 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
33 33 */
34 /*!
35 \qmlclass VXYModelMapper QHXYModelMapper
36
37 VXYModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source
38 for XYSeries based series. It is possible to use both QAbstractItemModel and XYSeries data API to manipulate data.
39 VYModelMapper keeps the series and the model in sync.
40 */
34 41
35 42 /*!
36 43 \property QVXYModelMapper::series
37 44 \brief Defines the QXYSeries object that is used by the mapper.
38
39 45 All the data in the series is discarded when it is set to the mapper.
40 46 When new series is specified the old series is disconnected (it preserves its data)
41 47 */
48 /*!
49 \qmlproperty XYSeries VXYModelMapper::series
50 Defines the QXYSeries object that is used by the mapper. All the data in the series is discarded when it is set to
51 the mapper. When new series is specified the old series is disconnected (it preserves its data).
52 */
42 53
43 54 /*!
44 55 \property QVXYModelMapper::model
45 56 \brief Defines the model that is used by the mapper.
46 57 */
58 /*!
59 \qmlproperty SomeModel VXYModelMapper::model
60 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
61 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
62 and modifying the data of the cells.
63 */
47 64
48 65 /*!
49 66 \property QVXYModelMapper::xColumn
50 67 \brief Defines which column of the model is kept in sync with the x values of QXYSeries
51
52 68 Default value is: -1 (invalid mapping)
53 69 */
70 /*!
71 \qmlproperty int VXYModelMapper::xColumn
72 Defines which column of the model is kept in sync with the x values of XYSeries. Default value is -1 (invalid
73 mapping).
74 */
54 75
55 76 /*!
56 77 \property QVXYModelMapper::yColumn
57 78 \brief Defines which column of the model is kept in sync with the y values of QXYSeries
58
59 79 Default value is: -1 (invalid mapping)
60 80 */
81 /*!
82 \qmlproperty int VXYModelMapper::yColumn
83 Defines which column of the model is kept in sync with the y values of QXYSeries. Default value is -1 (invalid
84 mapping).
85 */
61 86
62 87 /*!
63 88 \property QVXYModelMapper::firstRow
64 89 \brief Defines which row of the model contains the data for the first point of the series.
65 90 Minimal and default value is: 0
66 91 */
67 92 /*!
68 \qmlproperty int QVXYModelMapper::firstRow
93 \qmlproperty int VXYModelMapper::firstRow
69 94 Defines which row of the model contains the data for the first point of the series.
70 95 The default value is 0.
71 96 */
72 97
73 98 /*!
74 99 \property QVXYModelMapper::rowCount
75 100 \brief Defines the number of rows of the model that are mapped as the data for series
76 101 Minimal and default value is: -1 (count limited by the number of rows in the model)
77 102 */
78 103 /*!
79 \qmlproperty int QVXYModelMapper::columnCount
104 \qmlproperty int VXYModelMapper::columnCount
80 105 Defines the number of rows of the model that are mapped as the data for series. The default value is
81 -1 (count limited by the number of rows in the model)
106 -1 (count limited by the number of rows in the model).
82 107 */
83 108
84 109 /*!
85 110 \fn void QVXYModelMapper::seriesReplaced()
86 111
87 112 Emitted when the series to which mapper is connected to has changed.
88 113 */
89 114
90 115 /*!
91 116 \fn void QVXYModelMapper::modelReplaced()
92 117
93 118 Emitted when the model to which mapper is connected to has changed.
94 119 */
95 120
96 121 /*!
97 122 \fn void QVXYModelMapper::xColumnChanged()
98 123
99 124 Emitted when the xColumn has changed.
100 125 */
101 126
102 127 /*!
103 128 \fn void QVXYModelMapper::yColumnChanged()
104 129
105 130 Emitted when the yColumn has changed.
106 131 */
107 132
108 133 /*!
109 134 \fn void QVXYModelMapper::firstRowChanged()
110 135 Emitted when the firstRow has changed.
111 136 */
112 137
113 138 /*!
114 139 \fn void QVXYModelMapper::rowCountChanged()
115 140 Emitted when the rowCount has changed.
116 141 */
117 142
118 143 /*!
119 144 Constructs a mapper object which is a child of \a parent.
120 145 */
121 146 QVXYModelMapper::QVXYModelMapper(QObject *parent) :
122 147 QXYModelMapper(parent)
123 148 {
124 149 QXYModelMapper::setOrientation(Qt::Vertical);
125 150 }
126 151
127 152 QAbstractItemModel* QVXYModelMapper::model() const
128 153 {
129 154 return QXYModelMapper::model();
130 155 }
131 156
132 157 void QVXYModelMapper::setModel(QAbstractItemModel *model)
133 158 {
134 159 if (model != QXYModelMapper::model()) {
135 160 QXYModelMapper::setModel(model);
136 161 emit modelReplaced();
137 162 }
138 163 }
139 164
140 165 QXYSeries* QVXYModelMapper::series() const
141 166 {
142 167 return QXYModelMapper::series();
143 168 }
144 169
145 170 void QVXYModelMapper::setSeries(QXYSeries *series)
146 171 {
147 172 if (series != QXYModelMapper::series()) {
148 173 QXYModelMapper::setSeries(series);
149 174 emit seriesReplaced();
150 175 }
151 176 }
152 177
153 178 int QVXYModelMapper::xColumn() const
154 179 {
155 180 return QXYModelMapper::xSection();
156 181 }
157 182
158 183 void QVXYModelMapper::setXColumn(int xColumn)
159 184 {
160 185 if (xColumn != xSection()) {
161 186 return QXYModelMapper::setXSection(xColumn);
162 187 emit xColumnChanged();
163 188 }
164 189 }
165 190
166 191 int QVXYModelMapper::yColumn() const
167 192 {
168 193 return QXYModelMapper::ySection();
169 194 }
170 195
171 196 void QVXYModelMapper::setYColumn(int yColumn)
172 197 {
173 198 if (yColumn != ySection()) {
174 199 return QXYModelMapper::setYSection(yColumn);
175 200 emit yColumnChanged();
176 201 }
177 202 }
178 203
179 204 int QVXYModelMapper::firstRow() const
180 205 {
181 206 return first();
182 207 }
183 208
184 209 void QVXYModelMapper::setFirstRow(int firstRow)
185 210 {
186 211 if (firstRow != first()) {
187 212 setFirst(firstRow);
188 213 emit firstRowChanged();
189 214 }
190 215 }
191 216
192 217 int QVXYModelMapper::rowCount() const
193 218 {
194 219 return count();
195 220 }
196 221
197 222 void QVXYModelMapper::setRowCount(int rowCount)
198 223 {
199 224 if (rowCount != count()) {
200 225 setCount(rowCount);
201 226 emit firstRowChanged();
202 227 }
203 228 }
204 229
205 230 #include "moc_qvxymodelmapper.cpp"
206 231
207 232 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now