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