@@ -1,84 +1,78 | |||||
1 | /*! |
|
1 | /*! | |
2 | \page demos.html |
|
2 | \page demos.html | |
3 | \title Qt Charts Demos |
|
3 | \title Qt Charts Demos | |
4 | \keyword Demos |
|
4 | \keyword Demos | |
5 |
|
5 | |||
6 | \raw HTML |
|
6 | \raw HTML | |
7 | <div class="qchart"> |
|
7 | <div class="qchart"> | |
8 |
|
8 | |||
9 | <table> |
|
9 | <table> | |
10 | <tr> |
|
10 | <tr> | |
11 | <td><a href="demos-audio.html">Audio</a></td> |
|
11 | <td><a href="demos-audio.html">Audio</a></td> | |
12 | <td><a href="demos-callout.html">Callout</a></td> |
|
12 | <td><a href="demos-callout.html">Callout</a></td> | |
13 | </tr> |
|
13 | </tr> | |
14 | <tr> |
|
14 | <tr> | |
15 | <td><a href="demos-audio.html"><img src="images/demos_audio.png" width="300" alt="Audio" /></a></td> |
|
15 | <td><a href="demos-audio.html"><img src="images/demos_audio.png" width="300" alt="Audio" /></a></td> | |
16 | <td><a href="demos-callout.html"><img src="images/demos_callout.png" width="300" alt="Callout" /></a></td> |
|
16 | <td><a href="demos-callout.html"><img src="images/demos_callout.png" width="300" alt="Callout" /></a></td> | |
17 | </tr> |
|
17 | </tr> | |
18 | <tr> |
|
18 | <tr> | |
19 | <td><a href="demos-chartthemes.html">Chart Themes</a></td> |
|
19 | <td><a href="demos-chartthemes.html">Chart Themes</a></td> | |
20 | <td><a href="demos-dynamicspline.html">Dynamic Spline Chart</a></td> |
|
20 | <td><a href="demos-dynamicspline.html">Dynamic Spline Chart</a></td> | |
21 | </tr> |
|
21 | </tr> | |
22 | <tr> |
|
22 | <tr> | |
23 | <td><a href="demos-chartthemes.html"><img src="images/demo_chartthemes_blue_cerulean.png" width="300" alt="Chart Themes" /></a></td> |
|
23 | <td><a href="demos-chartthemes.html"><img src="images/demo_chartthemes_blue_cerulean.png" width="300" alt="Chart Themes" /></a></td> | |
24 | <td><a href="demos-dynamicspline.html"><img src="images/demos_dynamicspline2.png" width="300" alt="Dynamic Spline" /></a></td> |
|
24 | <td><a href="demos-dynamicspline.html"><img src="images/demos_dynamicspline2.png" width="300" alt="Dynamic Spline" /></a></td> | |
25 | </tr> |
|
25 | </tr> | |
26 | <tr> |
|
26 | <tr> | |
27 | <td><a href="demos-nesteddonuts.html">Nested Donuts Chart</a></td> |
|
27 | <td><a href="demos-nesteddonuts.html">Nested Donuts Chart</a></td> | |
28 | <td><a href="demos-piechartcustomization.html">Pie Chart Customization</a></td> |
|
28 | <td><a href="demos-piechartcustomization.html">Pie Chart Customization</a></td> | |
29 | </tr> |
|
29 | </tr> | |
30 | <tr> |
|
30 | <tr> | |
31 | <td><a href="demos-nesteddonuts.html"><img src="images/demos_nesteddonuts.png" width="300" alt="Nested Donuts Chart" /></a></td> |
|
31 | <td><a href="demos-nesteddonuts.html"><img src="images/demos_nesteddonuts.png" width="300" alt="Nested Donuts Chart" /></a></td> | |
32 | <td><a href="demos-piechartcustomization.html"><img src="images/piechart_customization.png" width="300" alt="Pie Chart Customization" /></a></td> |
|
32 | <td><a href="demos-piechartcustomization.html"><img src="images/piechart_customization.png" width="300" alt="Pie Chart Customization" /></a></td> | |
33 | </tr> |
|
33 | </tr> | |
34 | <tr> |
|
34 | <tr> | |
35 | <td><a href="demos-qmlchart.html">Qml Basic Charts</a></td> |
|
35 | <td><a href="demos-qmlchart.html">Qml Basic Charts</a></td> | |
36 | <td><a href="demos-qmlaxes.html">Qml Axes</a></td> |
|
36 | <td><a href="demos-qmlaxes.html">Qml Axes</a></td> | |
37 | </tr> |
|
37 | </tr> | |
38 | <tr> |
|
38 | <tr> | |
39 | <td><a href="demos-qmlchart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qml Basic Charts" /></a></td> |
|
39 | <td><a href="demos-qmlchart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qml Basic Charts" /></a></td> | |
40 | <td><a href="demos-qmlaxes.html"><img src="images/demos_qmlaxes1.png" width="300" alt="Qml Axes" /></a></td> |
|
40 | <td><a href="demos-qmlaxes.html"><img src="images/demos_qmlaxes1.png" width="300" alt="Qml Axes" /></a></td> | |
41 | </tr> |
|
41 | </tr> | |
42 | <tr> |
|
42 | <tr> | |
43 | <td><a href="demos-qmlcustomizations.html">Qml Customizations</a></td> |
|
43 | <td><a href="demos-qmlcustomizations.html">Qml Customizations</a></td> | |
44 |
<td><a href="demos-qmlcustom |
|
44 | <td><a href="demos-qmlcustomlegend.html">Qml Custom Legend</a></td> | |
45 | </tr> |
|
45 | </tr> | |
46 | <tr> |
|
46 | <tr> | |
47 | <td><a href="demos-qmlcustomizations.html"><img src="images/demos_qmlcustomizations.png" width="300" alt="Qml Customizations" /></a></td> |
|
47 | <td><a href="demos-qmlcustomizations.html"><img src="images/demos_qmlcustomizations.png" width="300" alt="Qml Customizations" /></a></td> | |
48 |
<td><a href="demos-qmlcustom |
|
48 | <td><a href="demos-qmlcustomlegend.html"><img src="images/demos-qmlcustomlegend1.png" width="300" alt="Qml Custom Legend" /></a></td> | |
49 | </tr> |
|
49 | </tr> | |
50 | <tr> |
|
50 | <tr> | |
51 | <td><a href="demos-qmlf1legends.html">Qml F1 Legends</a></td> |
|
51 | <td><a href="demos-qmlf1legends.html">Qml F1 Legends</a></td> | |
52 | <td><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></td> |
|
52 | <td><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></td> | |
53 | </tr> |
|
53 | </tr> | |
54 | <tr> |
|
54 | <tr> | |
55 | <td><a href="demos-qmlf1legends.html"><img src="images/demos_qmlf1legends.png" width="300" alt="Qml F1 Legends" /></a></td> |
|
55 | <td><a href="demos-qmlf1legends.html"><img src="images/demos_qmlf1legends.png" width="300" alt="Qml F1 Legends" /></a></td> | |
56 | <td><a href="demos-qmloscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qml Oscilloscope" /></a></td> |
|
56 | <td><a href="demos-qmloscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qml Oscilloscope" /></a></td> | |
57 | </tr> |
|
57 | </tr> | |
58 | <tr> |
|
58 | <tr> | |
59 | <td><a href="demos-qmlweather.html">Qml Weather</a></td> |
|
59 | <td><a href="demos-qmlweather.html">Qml Weather</a></td> | |
60 | <td><a href="demos-qmlcustomlegend.html">Qml Custom Legend</a></td> |
|
|||
61 | </tr> |
|
|||
62 | <tr> |
|
|||
63 | <td><a href="demos-qmlweather.html"><img src="images/demos_qmlweather.png" width="300" alt="Qml Weather" /></a></td> |
|
|||
64 | <td><a href="demos-qmlcustomlegend.html"><img src="images/demos-qmlcustomlegend1.png" width="300" alt="Qml Custom Legend" /></a></td> |
|
|||
65 | </tr> |
|
|||
66 | <tr> |
|
|||
67 | <td><a href="demos-qmlpolarchart.html">Qml Polar Chart</a></td> |
|
60 | <td><a href="demos-qmlpolarchart.html">Qml Polar Chart</a></td> | |
68 | <td><a href="demos-quick2chart.html">Qt Quick 2 Basic Charts</a></td> |
|
|||
69 | </tr> |
|
61 | </tr> | |
70 | <tr> |
|
62 | <tr> | |
|
63 | <td><a href="demos-qmlweather.html"><img src="images/demos_qmlweather.png" width="300" alt="Qml Weather" /></a></td> | |||
71 | <td><a href="demos-qmlpolarchart.html"><img src="images/demos_qmlpolarchart1.png" width="300" alt="Qml Polar Chart" /></a></td> |
|
64 | <td><a href="demos-qmlpolarchart.html"><img src="images/demos_qmlpolarchart1.png" width="300" alt="Qml Polar Chart" /></a></td> | |
72 | <td><a href="demos-quick2chart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qt Quick 2 Basic Charts" /></a></td> |
|
|||
73 | </tr> |
|
65 | </tr> | |
74 | <tr> |
|
66 | <tr> | |
|
67 | <td><a href="demos-quick2chart.html">Qt Quick 2 Basic Charts</a></td> | |||
75 | <td><a href="demos-quick2oscilloscope.html">Qt Quick 2 Oscilloscope</a></td> |
|
68 | <td><a href="demos-quick2oscilloscope.html">Qt Quick 2 Oscilloscope</a></td> | |
76 | </tr> |
|
69 | </tr> | |
77 | <tr> |
|
70 | <tr> | |
|
71 | <td><a href="demos-quick2chart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qt Quick 2 Basic Charts" /></a></td> | |||
78 | <td><a href="demos-quick2oscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qt Quick 2 Oscilloscope" /></a></td> |
|
72 | <td><a href="demos-quick2oscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qt Quick 2 Oscilloscope" /></a></td> | |
79 | </tr> |
|
73 | </tr> | |
80 | </table> |
|
74 | </table> | |
81 | </div> |
|
75 | </div> | |
82 | \endraw |
|
76 | \endraw | |
83 |
|
77 | |||
84 | */ |
|
78 | */ |
@@ -1,253 +1,253 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "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 |
|
77 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
78 |
|
|
78 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
79 |
|
|
79 | 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 |
|
85 | |||
86 | Default value is: -1 (invalid mapping) |
|
86 | Default value is: -1 (invalid mapping) | |
87 | */ |
|
87 | */ | |
88 | /*! |
|
88 | /*! | |
89 | \qmlproperty int HBarModelMapper::firstBarSetRow |
|
89 | \qmlproperty int HBarModelMapper::firstBarSetRow | |
90 | Defines which column of the model is used as the data source for the first bar set. The default value is -1 |
|
90 | Defines which column of the model is used as the data source for the first bar set. The default value is -1 | |
91 | (invalid mapping). |
|
91 | (invalid mapping). | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QHBarModelMapper::lastBarSetRow |
|
95 | \property QHBarModelMapper::lastBarSetRow | |
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 |
|
97 | |||
98 | Default value is: -1 (invalid mapping) |
|
98 | Default value is: -1 (invalid mapping) | |
99 | */ |
|
99 | */ | |
100 | /*! |
|
100 | /*! | |
101 | \qmlproperty int HBarModelMapper::lastBarSetRow |
|
101 | \qmlproperty int HBarModelMapper::lastBarSetRow | |
102 | Defines which column of the model is used as the data source for the last bar set. The default value is -1 |
|
102 | Defines which column of the model is used as the data source for the last bar set. The default value is -1 | |
103 | (invalid mapping). |
|
103 | (invalid mapping). | |
104 | */ |
|
104 | */ | |
105 |
|
105 | |||
106 | /*! |
|
106 | /*! | |
107 | \property QHBarModelMapper::firstColumn |
|
107 | \property QHBarModelMapper::firstColumn | |
108 | \brief Defines which column of the model contains the first values of the QBarSets in the series. |
|
108 | \brief Defines which column of the model contains the first values of the QBarSets in the series. | |
109 |
|
109 | |||
110 | Minimal and default value is: 0 |
|
110 | Minimal and default value is: 0 | |
111 | */ |
|
111 | */ | |
112 | /*! |
|
112 | /*! | |
113 | \qmlproperty int HBarModelMapper::firstColumn |
|
113 | \qmlproperty int HBarModelMapper::firstColumn | |
114 | Defines which column of the model contains the first values of the QBarSets in the series. |
|
114 | Defines which column of the model contains the first values of the QBarSets in the series. | |
115 | The default value is 0. |
|
115 | The default value is 0. | |
116 | */ |
|
116 | */ | |
117 |
|
117 | |||
118 | /*! |
|
118 | /*! | |
119 | \property QHBarModelMapper::columnCount |
|
119 | \property QHBarModelMapper::columnCount | |
120 | \brief Defines the number of columns of the model that are mapped as the data for QAbstractBarSeries. |
|
120 | \brief Defines the number of columns of the model that are mapped as the data for QAbstractBarSeries. | |
121 |
|
121 | |||
122 | Minimal and default value is: -1 (count limited by the number of columns in the model) |
|
122 | Minimal and default value is: -1 (count limited by the number of columns in the model) | |
123 | */ |
|
123 | */ | |
124 | /*! |
|
124 | /*! | |
125 | \qmlproperty int HBarModelMapper::columnCount |
|
125 | \qmlproperty int HBarModelMapper::columnCount | |
126 | Defines the number of columns of the model that are mapped as the data for QAbstractBarSeries. The default value is |
|
126 | Defines the number of columns of the model that are mapped as the data for QAbstractBarSeries. The default value is | |
127 | -1 (count limited by the number of columns in the model) |
|
127 | -1 (count limited by the number of columns in the model) | |
128 | */ |
|
128 | */ | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | \fn void QHBarModelMapper::seriesReplaced() |
|
131 | \fn void QHBarModelMapper::seriesReplaced() | |
132 |
|
132 | |||
133 | Emitted when the series to which mapper is connected to has changed. |
|
133 | Emitted when the series to which mapper is connected to has changed. | |
134 | */ |
|
134 | */ | |
135 |
|
135 | |||
136 | /*! |
|
136 | /*! | |
137 | \fn void QHBarModelMapper::modelReplaced() |
|
137 | \fn void QHBarModelMapper::modelReplaced() | |
138 |
|
138 | |||
139 | Emitted when the model to which mapper is connected to has changed. |
|
139 | Emitted when the model to which mapper is connected to has changed. | |
140 | */ |
|
140 | */ | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | \fn void QHBarModelMapper::firstBarSetRowChanged() |
|
143 | \fn void QHBarModelMapper::firstBarSetRowChanged() | |
144 |
|
144 | |||
145 | Emitted when the firstBarSetRow has changed. |
|
145 | Emitted when the firstBarSetRow has changed. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QHBarModelMapper::lastBarSetRowChanged() |
|
149 | \fn void QHBarModelMapper::lastBarSetRowChanged() | |
150 |
|
150 | |||
151 | Emitted when the lastBarSetRow has changed. |
|
151 | Emitted when the lastBarSetRow has changed. | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \fn void QHBarModelMapper::firstColumnChanged() |
|
155 | \fn void QHBarModelMapper::firstColumnChanged() | |
156 | Emitted when the firstColumn has changed. |
|
156 | Emitted when the firstColumn has changed. | |
157 | */ |
|
157 | */ | |
158 |
|
158 | |||
159 | /*! |
|
159 | /*! | |
160 | \fn void QHBarModelMapper::columnCountChanged() |
|
160 | \fn void QHBarModelMapper::columnCountChanged() | |
161 | Emitted when the columnCount has changed. |
|
161 | Emitted when the columnCount has changed. | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | Constructs a mapper object which is a child of \a parent. |
|
165 | Constructs a mapper object which is a child of \a parent. | |
166 | */ |
|
166 | */ | |
167 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : |
|
167 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : | |
168 | QBarModelMapper(parent) |
|
168 | QBarModelMapper(parent) | |
169 | { |
|
169 | { | |
170 | QBarModelMapper::setOrientation(Qt::Horizontal); |
|
170 | QBarModelMapper::setOrientation(Qt::Horizontal); | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | QAbstractItemModel *QHBarModelMapper::model() const |
|
173 | QAbstractItemModel *QHBarModelMapper::model() const | |
174 | { |
|
174 | { | |
175 | return QBarModelMapper::model(); |
|
175 | return QBarModelMapper::model(); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | void QHBarModelMapper::setModel(QAbstractItemModel *model) |
|
178 | void QHBarModelMapper::setModel(QAbstractItemModel *model) | |
179 | { |
|
179 | { | |
180 | if (model != QBarModelMapper::model()) { |
|
180 | if (model != QBarModelMapper::model()) { | |
181 | QBarModelMapper::setModel(model); |
|
181 | QBarModelMapper::setModel(model); | |
182 | emit modelReplaced(); |
|
182 | emit modelReplaced(); | |
183 | } |
|
183 | } | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 | QAbstractBarSeries *QHBarModelMapper::series() const |
|
186 | QAbstractBarSeries *QHBarModelMapper::series() const | |
187 | { |
|
187 | { | |
188 | return QBarModelMapper::series(); |
|
188 | return QBarModelMapper::series(); | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | void QHBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
191 | void QHBarModelMapper::setSeries(QAbstractBarSeries *series) | |
192 | { |
|
192 | { | |
193 | if (series != QBarModelMapper::series()) { |
|
193 | if (series != QBarModelMapper::series()) { | |
194 | QBarModelMapper::setSeries(series); |
|
194 | QBarModelMapper::setSeries(series); | |
195 | emit seriesReplaced(); |
|
195 | emit seriesReplaced(); | |
196 | } |
|
196 | } | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | int QHBarModelMapper::firstBarSetRow() const |
|
199 | int QHBarModelMapper::firstBarSetRow() const | |
200 | { |
|
200 | { | |
201 | return QBarModelMapper::firstBarSetSection(); |
|
201 | return QBarModelMapper::firstBarSetSection(); | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow) |
|
204 | void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow) | |
205 | { |
|
205 | { | |
206 | if (firstBarSetRow != firstBarSetSection()) { |
|
206 | if (firstBarSetRow != firstBarSetSection()) { | |
207 | QBarModelMapper::setFirstBarSetSection(firstBarSetRow); |
|
207 | QBarModelMapper::setFirstBarSetSection(firstBarSetRow); | |
208 | emit firstBarSetRowChanged(); |
|
208 | emit firstBarSetRowChanged(); | |
209 | } |
|
209 | } | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | int QHBarModelMapper::lastBarSetRow() const |
|
212 | int QHBarModelMapper::lastBarSetRow() const | |
213 | { |
|
213 | { | |
214 | return QBarModelMapper::lastBarSetSection(); |
|
214 | return QBarModelMapper::lastBarSetSection(); | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow) |
|
217 | void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow) | |
218 | { |
|
218 | { | |
219 | if (lastBarSetRow != lastBarSetSection()) { |
|
219 | if (lastBarSetRow != lastBarSetSection()) { | |
220 | QBarModelMapper::setLastBarSetSection(lastBarSetRow); |
|
220 | QBarModelMapper::setLastBarSetSection(lastBarSetRow); | |
221 | emit lastBarSetRowChanged(); |
|
221 | emit lastBarSetRowChanged(); | |
222 | } |
|
222 | } | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | int QHBarModelMapper::firstColumn() const |
|
225 | int QHBarModelMapper::firstColumn() const | |
226 | { |
|
226 | { | |
227 | return QBarModelMapper::first(); |
|
227 | return QBarModelMapper::first(); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | void QHBarModelMapper::setFirstColumn(int firstColumn) |
|
230 | void QHBarModelMapper::setFirstColumn(int firstColumn) | |
231 | { |
|
231 | { | |
232 | if (firstColumn != first()) { |
|
232 | if (firstColumn != first()) { | |
233 | QBarModelMapper::setFirst(firstColumn); |
|
233 | QBarModelMapper::setFirst(firstColumn); | |
234 | emit firstColumnChanged(); |
|
234 | emit firstColumnChanged(); | |
235 | } |
|
235 | } | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | int QHBarModelMapper::columnCount() const |
|
238 | int QHBarModelMapper::columnCount() const | |
239 | { |
|
239 | { | |
240 | return QBarModelMapper::count(); |
|
240 | return QBarModelMapper::count(); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | void QHBarModelMapper::setColumnCount(int columnCount) |
|
243 | void QHBarModelMapper::setColumnCount(int columnCount) | |
244 | { |
|
244 | { | |
245 | if (columnCount != count()) { |
|
245 | if (columnCount != count()) { | |
246 | QBarModelMapper::setCount(columnCount); |
|
246 | QBarModelMapper::setCount(columnCount); | |
247 | emit columnCountChanged(); |
|
247 | emit columnCountChanged(); | |
248 | } |
|
248 | } | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | #include "moc_qhbarmodelmapper.cpp" |
|
251 | #include "moc_qhbarmodelmapper.cpp" | |
252 |
|
252 | |||
253 | QTCOMMERCIALCHART_END_NAMESPACE |
|
253 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,252 +1,252 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "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 QBarSeries object that is used by the mapper. |
|
61 | \brief Defines the QBarSeries 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 |
|
78 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
79 |
|
|
79 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
80 |
|
|
80 | 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 |
|
86 | |||
87 | Default value is: -1 (invalid mapping) |
|
87 | Default value is: -1 (invalid mapping) | |
88 | */ |
|
88 | */ | |
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty int VBarModelMapper::firstBarSetColumn |
|
90 | \qmlproperty int VBarModelMapper::firstBarSetColumn | |
91 | Defines which column of the model is used as the data source for the first bar set. Default value |
|
91 | Defines which column of the model is used as the data source for the first bar set. Default value | |
92 | is: -1 (invalid mapping). |
|
92 | is: -1 (invalid mapping). | |
93 | */ |
|
93 | */ | |
94 |
|
94 | |||
95 | /*! |
|
95 | /*! | |
96 | \property QVBarModelMapper::lastBarSetColumn |
|
96 | \property QVBarModelMapper::lastBarSetColumn | |
97 | \brief Defines which column of the model is used as the data source for the last bar set. |
|
97 | \brief Defines which column of the model is used as the data source for the last bar set. | |
98 |
|
98 | |||
99 | Default value is: -1 (invalid mapping) |
|
99 | Default value is: -1 (invalid mapping) | |
100 | */ |
|
100 | */ | |
101 | /*! |
|
101 | /*! | |
102 | \qmlproperty int VBarModelMapper::lastBarSetColumn |
|
102 | \qmlproperty int VBarModelMapper::lastBarSetColumn | |
103 | Defines which column of the model is used as the data source for the last bar set. Default |
|
103 | Defines which column of the model is used as the data source for the last bar set. Default | |
104 | value is: -1 (invalid mapping). |
|
104 | value is: -1 (invalid mapping). | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | \property QVBarModelMapper::firstRow |
|
108 | \property QVBarModelMapper::firstRow | |
109 | \brief Defines which row of the model contains the first values of the QBarSets in the series. |
|
109 | \brief Defines which row of the model contains the first values of the QBarSets in the series. | |
110 |
|
110 | |||
111 | Minimal and default value is: 0 |
|
111 | Minimal and default value is: 0 | |
112 | */ |
|
112 | */ | |
113 | /*! |
|
113 | /*! | |
114 | \qmlproperty int VBarModelMapper::firstRow |
|
114 | \qmlproperty int VBarModelMapper::firstRow | |
115 | Defines which row of the model contains the first values of the QBarSets in the series. |
|
115 | Defines which row of the model contains the first values of the QBarSets in the series. | |
116 | The default value is 0. |
|
116 | The default value is 0. | |
117 | */ |
|
117 | */ | |
118 |
|
118 | |||
119 | /*! |
|
119 | /*! | |
120 | \property QVBarModelMapper::rowCount |
|
120 | \property QVBarModelMapper::rowCount | |
121 | \brief Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. |
|
121 | \brief Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. | |
122 |
|
122 | |||
123 | Minimal and default value is: -1 (count limited by the number of rows in the model) |
|
123 | Minimal and default value is: -1 (count limited by the number of rows in the model) | |
124 | */ |
|
124 | */ | |
125 | /*! |
|
125 | /*! | |
126 | \qmlproperty int VBarModelMapper::rowCount |
|
126 | \qmlproperty int VBarModelMapper::rowCount | |
127 | Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. The default value is |
|
127 | Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. The default value is | |
128 | -1 (count limited by the number of rows in the model) |
|
128 | -1 (count limited by the number of rows in the model) | |
129 | */ |
|
129 | */ | |
130 |
|
130 | |||
131 | /*! |
|
131 | /*! | |
132 | \fn void QVBarModelMapper::seriesReplaced() |
|
132 | \fn void QVBarModelMapper::seriesReplaced() | |
133 |
|
133 | |||
134 | Emitted when the series to which mapper is connected to has changed. |
|
134 | Emitted when the series to which mapper is connected to has changed. | |
135 | */ |
|
135 | */ | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | \fn void QVBarModelMapper::modelReplaced() |
|
138 | \fn void QVBarModelMapper::modelReplaced() | |
139 |
|
139 | |||
140 | Emitted when the model to which mapper is connected to has changed. |
|
140 | Emitted when the model to which mapper is connected to has changed. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn void QVBarModelMapper::firstBarSetColumnChanged() |
|
144 | \fn void QVBarModelMapper::firstBarSetColumnChanged() | |
145 | Emitted when the firstBarSetColumn has changed. |
|
145 | Emitted when the firstBarSetColumn has changed. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QVBarModelMapper::lastBarSetColumnChanged() |
|
149 | \fn void QVBarModelMapper::lastBarSetColumnChanged() | |
150 | Emitted when the lastBarSetColumn has changed. |
|
150 | Emitted when the lastBarSetColumn has changed. | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \fn void QVBarModelMapper::firstRowChanged() |
|
154 | \fn void QVBarModelMapper::firstRowChanged() | |
155 | Emitted when the firstRow has changed. |
|
155 | Emitted when the firstRow has changed. | |
156 | */ |
|
156 | */ | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | \fn void QVBarModelMapper::rowCountChanged() |
|
159 | \fn void QVBarModelMapper::rowCountChanged() | |
160 | Emitted when the rowCount has changed. |
|
160 | Emitted when the rowCount has changed. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | Constructs a mapper object which is a child of \a parent. |
|
164 | Constructs a mapper object which is a child of \a parent. | |
165 | */ |
|
165 | */ | |
166 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : |
|
166 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : | |
167 | QBarModelMapper(parent) |
|
167 | QBarModelMapper(parent) | |
168 | { |
|
168 | { | |
169 | QBarModelMapper::setOrientation(Qt::Vertical); |
|
169 | QBarModelMapper::setOrientation(Qt::Vertical); | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | QAbstractItemModel *QVBarModelMapper::model() const |
|
172 | QAbstractItemModel *QVBarModelMapper::model() const | |
173 | { |
|
173 | { | |
174 | return QBarModelMapper::model(); |
|
174 | return QBarModelMapper::model(); | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | void QVBarModelMapper::setModel(QAbstractItemModel *model) |
|
177 | void QVBarModelMapper::setModel(QAbstractItemModel *model) | |
178 | { |
|
178 | { | |
179 | if (model != QBarModelMapper::model()) { |
|
179 | if (model != QBarModelMapper::model()) { | |
180 | QBarModelMapper::setModel(model); |
|
180 | QBarModelMapper::setModel(model); | |
181 | emit modelReplaced(); |
|
181 | emit modelReplaced(); | |
182 | } |
|
182 | } | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | QAbstractBarSeries *QVBarModelMapper::series() const |
|
185 | QAbstractBarSeries *QVBarModelMapper::series() const | |
186 | { |
|
186 | { | |
187 | return QBarModelMapper::series(); |
|
187 | return QBarModelMapper::series(); | |
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 | void QVBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
190 | void QVBarModelMapper::setSeries(QAbstractBarSeries *series) | |
191 | { |
|
191 | { | |
192 | if (series != QBarModelMapper::series()) { |
|
192 | if (series != QBarModelMapper::series()) { | |
193 | QBarModelMapper::setSeries(series); |
|
193 | QBarModelMapper::setSeries(series); | |
194 | emit seriesReplaced(); |
|
194 | emit seriesReplaced(); | |
195 | } |
|
195 | } | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | int QVBarModelMapper::firstBarSetColumn() const |
|
198 | int QVBarModelMapper::firstBarSetColumn() const | |
199 | { |
|
199 | { | |
200 | return QBarModelMapper::firstBarSetSection(); |
|
200 | return QBarModelMapper::firstBarSetSection(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn) |
|
203 | void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn) | |
204 | { |
|
204 | { | |
205 | if (firstBarSetColumn != firstBarSetSection()) { |
|
205 | if (firstBarSetColumn != firstBarSetSection()) { | |
206 | QBarModelMapper::setFirstBarSetSection(firstBarSetColumn); |
|
206 | QBarModelMapper::setFirstBarSetSection(firstBarSetColumn); | |
207 | emit firstBarSetColumnChanged(); |
|
207 | emit firstBarSetColumnChanged(); | |
208 | } |
|
208 | } | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | int QVBarModelMapper::lastBarSetColumn() const |
|
211 | int QVBarModelMapper::lastBarSetColumn() const | |
212 | { |
|
212 | { | |
213 | return QBarModelMapper::lastBarSetSection(); |
|
213 | return QBarModelMapper::lastBarSetSection(); | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn) |
|
216 | void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn) | |
217 | { |
|
217 | { | |
218 | if (lastBarSetColumn != lastBarSetSection()) { |
|
218 | if (lastBarSetColumn != lastBarSetSection()) { | |
219 | QBarModelMapper::setLastBarSetSection(lastBarSetColumn); |
|
219 | QBarModelMapper::setLastBarSetSection(lastBarSetColumn); | |
220 | emit lastBarSetColumnChanged(); |
|
220 | emit lastBarSetColumnChanged(); | |
221 | } |
|
221 | } | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | int QVBarModelMapper::firstRow() const |
|
224 | int QVBarModelMapper::firstRow() const | |
225 | { |
|
225 | { | |
226 | return QBarModelMapper::first(); |
|
226 | return QBarModelMapper::first(); | |
227 | } |
|
227 | } | |
228 |
|
228 | |||
229 | void QVBarModelMapper::setFirstRow(int firstRow) |
|
229 | void QVBarModelMapper::setFirstRow(int firstRow) | |
230 | { |
|
230 | { | |
231 | if (firstRow != first()) { |
|
231 | if (firstRow != first()) { | |
232 | QBarModelMapper::setFirst(firstRow); |
|
232 | QBarModelMapper::setFirst(firstRow); | |
233 | emit firstRowChanged(); |
|
233 | emit firstRowChanged(); | |
234 | } |
|
234 | } | |
235 | } |
|
235 | } | |
236 |
|
236 | |||
237 | int QVBarModelMapper::rowCount() const |
|
237 | int QVBarModelMapper::rowCount() const | |
238 | { |
|
238 | { | |
239 | return QBarModelMapper::count(); |
|
239 | return QBarModelMapper::count(); | |
240 | } |
|
240 | } | |
241 |
|
241 | |||
242 | void QVBarModelMapper::setRowCount(int rowCount) |
|
242 | void QVBarModelMapper::setRowCount(int rowCount) | |
243 | { |
|
243 | { | |
244 | if (rowCount != count()) { |
|
244 | if (rowCount != count()) { | |
245 | QBarModelMapper::setCount(rowCount); |
|
245 | QBarModelMapper::setCount(rowCount); | |
246 | emit rowCountChanged(); |
|
246 | emit rowCountChanged(); | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | #include "moc_qvbarmodelmapper.cpp" |
|
250 | #include "moc_qvbarmodelmapper.cpp" | |
251 |
|
251 | |||
252 | QTCOMMERCIALCHART_END_NAMESPACE |
|
252 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,261 +1,261 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "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 |
|
75 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
76 |
|
|
76 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
77 |
|
|
77 | 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 |
|
83 | |||
84 | Default value is: -1 (invalid mapping) |
|
84 | Default value is: -1 (invalid mapping) | |
85 | */ |
|
85 | */ | |
86 | /*! |
|
86 | /*! | |
87 | \qmlproperty int HPieModelMapper::valuesRow |
|
87 | \qmlproperty int HPieModelMapper::valuesRow | |
88 | Defines which row of the model is kept in sync with the values of the pie's slices. Default value is: -1 (invalid |
|
88 | Defines which row of the model is kept in sync with the values of the pie's slices. Default value is: -1 (invalid | |
89 | mapping). |
|
89 | mapping). | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | /*! |
|
92 | /*! | |
93 | \property QHPieModelMapper::labelsRow |
|
93 | \property QHPieModelMapper::labelsRow | |
94 | \brief Defines which row of the model is kept in sync with the labels of the pie's slices. |
|
94 | \brief Defines which row of the model is kept in sync with the labels of the pie's slices. | |
95 |
|
95 | |||
96 | Default value is: -1 (invalid mapping) |
|
96 | Default value is: -1 (invalid mapping) | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty int HPieModelMapper::labelsRow |
|
99 | \qmlproperty int HPieModelMapper::labelsRow | |
100 | Defines which row of the model is kept in sync with the labels of the pie's slices |
|
100 | Defines which row of the model is kept in sync with the labels of the pie's slices | |
101 | Default value is: -1 (invalid mapping) |
|
101 | Default value is: -1 (invalid mapping) | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \property QHPieModelMapper::firstColumn |
|
105 | \property QHPieModelMapper::firstColumn | |
106 | \brief Defines which column of the model contains the first slice value. |
|
106 | \brief Defines which column of the model contains the first slice value. | |
107 |
|
107 | |||
108 | Minimal and default value is: 0 |
|
108 | Minimal and default value is: 0 | |
109 | */ |
|
109 | */ | |
110 | /*! |
|
110 | /*! | |
111 | \qmlproperty int HPieModelMapper::firstColumn |
|
111 | \qmlproperty int HPieModelMapper::firstColumn | |
112 | Defines which column of the model contains the first slice value. |
|
112 | Defines which column of the model contains the first slice value. | |
113 | The default value is 0. |
|
113 | The default value is 0. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \property QHPieModelMapper::columnCount |
|
117 | \property QHPieModelMapper::columnCount | |
118 | \brief Defines the number of columns of the model that are mapped as the data for QPieSeries. |
|
118 | \brief Defines the number of columns of the model that are mapped as the data for QPieSeries. | |
119 |
|
119 | |||
120 | Minimal and default value is: -1 (count limited by the number of columns in the model) |
|
120 | Minimal and default value is: -1 (count limited by the number of columns in the model) | |
121 | */ |
|
121 | */ | |
122 | /*! |
|
122 | /*! | |
123 | \qmlproperty int HPieModelMapper::columnCount |
|
123 | \qmlproperty int HPieModelMapper::columnCount | |
124 | Defines the number of columns of the model that are mapped as the data for QPieSeries. The default value is |
|
124 | Defines the number of columns of the model that are mapped as the data for QPieSeries. The default value is | |
125 | -1 (count limited by the number of columns in the model) |
|
125 | -1 (count limited by the number of columns in the model) | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \fn void QHPieModelMapper::seriesReplaced() |
|
129 | \fn void QHPieModelMapper::seriesReplaced() | |
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 QHPieModelMapper::modelReplaced() |
|
134 | \fn void QHPieModelMapper::modelReplaced() | |
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 QHPieModelMapper::valuesRowChanged() |
|
139 | \fn void QHPieModelMapper::valuesRowChanged() | |
140 | Emitted when the valuesRow has changed. |
|
140 | Emitted when the valuesRow has changed. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn void QHPieModelMapper::labelsRowChanged() |
|
144 | \fn void QHPieModelMapper::labelsRowChanged() | |
145 | Emitted when the labelsRow has changed. |
|
145 | Emitted when the labelsRow has changed. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QHPieModelMapper::firstColumnChanged() |
|
149 | \fn void QHPieModelMapper::firstColumnChanged() | |
150 | Emitted when the firstColumn has changed. |
|
150 | Emitted when the firstColumn has changed. | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \fn void QHPieModelMapper::columnCountChanged() |
|
154 | \fn void QHPieModelMapper::columnCountChanged() | |
155 | Emitted when the columnCount has changed. |
|
155 | Emitted when the columnCount has changed. | |
156 | */ |
|
156 | */ | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | Constructs a mapper object which is a child of \a parent. |
|
159 | Constructs a mapper object which is a child of \a parent. | |
160 | */ |
|
160 | */ | |
161 | QHPieModelMapper::QHPieModelMapper(QObject *parent) : |
|
161 | QHPieModelMapper::QHPieModelMapper(QObject *parent) : | |
162 | QPieModelMapper(parent) |
|
162 | QPieModelMapper(parent) | |
163 | { |
|
163 | { | |
164 | setOrientation(Qt::Horizontal); |
|
164 | setOrientation(Qt::Horizontal); | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | QAbstractItemModel *QHPieModelMapper::model() const |
|
167 | QAbstractItemModel *QHPieModelMapper::model() const | |
168 | { |
|
168 | { | |
169 | return QPieModelMapper::model(); |
|
169 | return QPieModelMapper::model(); | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | void QHPieModelMapper::setModel(QAbstractItemModel *model) |
|
172 | void QHPieModelMapper::setModel(QAbstractItemModel *model) | |
173 | { |
|
173 | { | |
174 | if (model != QPieModelMapper::model()) { |
|
174 | if (model != QPieModelMapper::model()) { | |
175 | QPieModelMapper::setModel(model); |
|
175 | QPieModelMapper::setModel(model); | |
176 | emit modelReplaced(); |
|
176 | emit modelReplaced(); | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | QPieSeries *QHPieModelMapper::series() const |
|
180 | QPieSeries *QHPieModelMapper::series() const | |
181 | { |
|
181 | { | |
182 | return QPieModelMapper::series(); |
|
182 | return QPieModelMapper::series(); | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | void QHPieModelMapper::setSeries(QPieSeries *series) |
|
185 | void QHPieModelMapper::setSeries(QPieSeries *series) | |
186 | { |
|
186 | { | |
187 | if (series != QPieModelMapper::series()) { |
|
187 | if (series != QPieModelMapper::series()) { | |
188 | QPieModelMapper::setSeries(series); |
|
188 | QPieModelMapper::setSeries(series); | |
189 | emit seriesReplaced(); |
|
189 | emit seriesReplaced(); | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | /*! |
|
193 | /*! | |
194 | Returns which row of the model is kept in sync with the values of the pie's slices |
|
194 | Returns which row of the model is kept in sync with the values of the pie's slices | |
195 | */ |
|
195 | */ | |
196 | int QHPieModelMapper::valuesRow() const |
|
196 | int QHPieModelMapper::valuesRow() const | |
197 | { |
|
197 | { | |
198 | return valuesSection(); |
|
198 | return valuesSection(); | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
202 | Sets the model row that is kept in sync with the pie slices values. |
|
202 | Sets the model row that is kept in sync with the pie slices values. | |
203 | Parameter \a valuesRow specifies the row of the model. |
|
203 | Parameter \a valuesRow specifies the row of the model. | |
204 | */ |
|
204 | */ | |
205 | void QHPieModelMapper::setValuesRow(int valuesRow) |
|
205 | void QHPieModelMapper::setValuesRow(int valuesRow) | |
206 | { |
|
206 | { | |
207 | if (valuesRow != valuesSection()) { |
|
207 | if (valuesRow != valuesSection()) { | |
208 | setValuesSection(valuesRow); |
|
208 | setValuesSection(valuesRow); | |
209 | emit valuesRowChanged(); |
|
209 | emit valuesRowChanged(); | |
210 | } |
|
210 | } | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | /*! |
|
213 | /*! | |
214 | Returns which row of the model is kept in sync with the labels of the pie's slices |
|
214 | Returns which row of the model is kept in sync with the labels of the pie's slices | |
215 | */ |
|
215 | */ | |
216 | int QHPieModelMapper::labelsRow() const |
|
216 | int QHPieModelMapper::labelsRow() const | |
217 | { |
|
217 | { | |
218 | return labelsSection(); |
|
218 | return labelsSection(); | |
219 | } |
|
219 | } | |
220 |
|
220 | |||
221 | /*! |
|
221 | /*! | |
222 | Sets the model row that is kept in sync with the pie's slices labels. |
|
222 | Sets the model row that is kept in sync with the pie's slices labels. | |
223 | Parameter \a labelsRow specifies the row of the model. |
|
223 | Parameter \a labelsRow specifies the row of the model. | |
224 | */ |
|
224 | */ | |
225 | void QHPieModelMapper::setLabelsRow(int labelsRow) |
|
225 | void QHPieModelMapper::setLabelsRow(int labelsRow) | |
226 | { |
|
226 | { | |
227 | if (labelsRow != labelsSection()) { |
|
227 | if (labelsRow != labelsSection()) { | |
228 | setLabelsSection(labelsRow); |
|
228 | setLabelsSection(labelsRow); | |
229 | emit labelsRowChanged(); |
|
229 | emit labelsRowChanged(); | |
230 | } |
|
230 | } | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | int QHPieModelMapper::firstColumn() const |
|
233 | int QHPieModelMapper::firstColumn() const | |
234 | { |
|
234 | { | |
235 | return first(); |
|
235 | return first(); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | void QHPieModelMapper::setFirstColumn(int firstColumn) |
|
238 | void QHPieModelMapper::setFirstColumn(int firstColumn) | |
239 | { |
|
239 | { | |
240 | if (firstColumn != first()) { |
|
240 | if (firstColumn != first()) { | |
241 | setFirst(firstColumn); |
|
241 | setFirst(firstColumn); | |
242 | emit firstColumnChanged(); |
|
242 | emit firstColumnChanged(); | |
243 | } |
|
243 | } | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 | int QHPieModelMapper::columnCount() const |
|
246 | int QHPieModelMapper::columnCount() const | |
247 | { |
|
247 | { | |
248 | return count(); |
|
248 | return count(); | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void QHPieModelMapper::setColumnCount(int columnCount) |
|
251 | void QHPieModelMapper::setColumnCount(int columnCount) | |
252 | { |
|
252 | { | |
253 | if (columnCount != count()) { |
|
253 | if (columnCount != count()) { | |
254 | setCount(columnCount); |
|
254 | setCount(columnCount); | |
255 | emit columnCountChanged(); |
|
255 | emit columnCountChanged(); | |
256 | } |
|
256 | } | |
257 | } |
|
257 | } | |
258 |
|
258 | |||
259 | #include "moc_qhpiemodelmapper.cpp" |
|
259 | #include "moc_qhpiemodelmapper.cpp" | |
260 |
|
260 | |||
261 | QTCOMMERCIALCHART_END_NAMESPACE |
|
261 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,264 +1,264 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "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 |
|
74 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
75 |
|
|
75 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
76 |
|
|
76 | 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 |
|
82 | |||
83 | Default value is: -1 (invalid mapping) |
|
83 | Default value is: -1 (invalid mapping) | |
84 | */ |
|
84 | */ | |
85 | /*! |
|
85 | /*! | |
86 | \qmlproperty int VPieModelMapper::valuesColumn |
|
86 | \qmlproperty int VPieModelMapper::valuesColumn | |
87 | Defines which column of the model is kept in sync with the values of the pie's slices. Default value is -1 (invalid |
|
87 | Defines which column 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 QVPieModelMapper::labelsColumn |
|
92 | \property QVPieModelMapper::labelsColumn | |
93 | \brief Defines which column of the model is kept in sync with the labels of the pie's slices. |
|
93 | \brief Defines which column of the model is kept in sync with the labels of the pie's slices. | |
94 |
|
94 | |||
95 | Default value is: -1 (invalid mapping) |
|
95 | Default value is: -1 (invalid mapping) | |
96 | */ |
|
96 | */ | |
97 | /*! |
|
97 | /*! | |
98 | \qmlproperty int VPieModelMapper::labelsColumn |
|
98 | \qmlproperty int VPieModelMapper::labelsColumn | |
99 | Defines which column of the model is kept in sync with the labels of the pie's slices. Default value is -1 (invalid |
|
99 | Defines which column of the model is kept in sync with the labels of the pie's slices. Default value is -1 (invalid | |
100 | mapping). |
|
100 | mapping). | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \property QVPieModelMapper::firstRow |
|
104 | \property QVPieModelMapper::firstRow | |
105 | \brief Defines which row of the model contains the first slice value. |
|
105 | \brief Defines which row of the model contains the first slice value. | |
106 |
|
106 | |||
107 | Minimal and default value is: 0 |
|
107 | Minimal and default value is: 0 | |
108 | */ |
|
108 | */ | |
109 | /*! |
|
109 | /*! | |
110 | \qmlproperty int VPieModelMapper::firstRow |
|
110 | \qmlproperty int VPieModelMapper::firstRow | |
111 | Defines which row of the model contains the first slice value. |
|
111 | Defines which row of the model contains the first slice value. | |
112 | The default value is 0. |
|
112 | The default value is 0. | |
113 | */ |
|
113 | */ | |
114 |
|
114 | |||
115 | /*! |
|
115 | /*! | |
116 | \property QVPieModelMapper::rowCount |
|
116 | \property QVPieModelMapper::rowCount | |
117 | \brief Defines the number of rows of the model that are mapped as the data for QPieSeries. |
|
117 | \brief Defines the number of rows of the model that are mapped as the data for QPieSeries. | |
118 |
|
118 | |||
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 VPieModelMapper::columnCount |
|
122 | \qmlproperty int VPieModelMapper::columnCount | |
123 | Defines the number of rows of the model that are mapped as the data for QPieSeries. The default value is |
|
123 | Defines the number of rows of the model that are mapped as the data for QPieSeries. 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 QVPieModelMapper::seriesReplaced() |
|
128 | \fn void QVPieModelMapper::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 QVPieModelMapper::modelReplaced() |
|
134 | \fn void QVPieModelMapper::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 QVPieModelMapper::valuesColumnChanged() |
|
140 | \fn void QVPieModelMapper::valuesColumnChanged() | |
141 |
|
141 | |||
142 | Emitted when the valuesColumn has changed. |
|
142 | Emitted when the valuesColumn has changed. | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \fn void QVPieModelMapper::labelsColumnChanged() |
|
146 | \fn void QVPieModelMapper::labelsColumnChanged() | |
147 |
|
147 | |||
148 | Emitted when the labelsColumn has changed. |
|
148 | Emitted when the labelsColumn has changed. | |
149 | */ |
|
149 | */ | |
150 |
|
150 | |||
151 | /*! |
|
151 | /*! | |
152 | \fn void QVPieModelMapper::firstRowChanged() |
|
152 | \fn void QVPieModelMapper::firstRowChanged() | |
153 | Emitted when the firstRow has changed. |
|
153 | Emitted when the firstRow has changed. | |
154 | */ |
|
154 | */ | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | \fn void QVPieModelMapper::rowCountChanged() |
|
157 | \fn void QVPieModelMapper::rowCountChanged() | |
158 | Emitted when the rowCount has changed. |
|
158 | Emitted when the rowCount has changed. | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | Constructs a mapper object which is a child of \a parent. |
|
162 | Constructs a mapper object which is a child of \a parent. | |
163 | */ |
|
163 | */ | |
164 | QVPieModelMapper::QVPieModelMapper(QObject *parent) : |
|
164 | QVPieModelMapper::QVPieModelMapper(QObject *parent) : | |
165 | QPieModelMapper(parent) |
|
165 | QPieModelMapper(parent) | |
166 | { |
|
166 | { | |
167 | QPieModelMapper::setOrientation(Qt::Vertical); |
|
167 | QPieModelMapper::setOrientation(Qt::Vertical); | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QAbstractItemModel *QVPieModelMapper::model() const |
|
170 | QAbstractItemModel *QVPieModelMapper::model() const | |
171 | { |
|
171 | { | |
172 | return QPieModelMapper::model(); |
|
172 | return QPieModelMapper::model(); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | void QVPieModelMapper::setModel(QAbstractItemModel *model) |
|
175 | void QVPieModelMapper::setModel(QAbstractItemModel *model) | |
176 | { |
|
176 | { | |
177 | if (model != QPieModelMapper::model()) { |
|
177 | if (model != QPieModelMapper::model()) { | |
178 | QPieModelMapper::setModel(model); |
|
178 | QPieModelMapper::setModel(model); | |
179 | emit modelReplaced(); |
|
179 | emit modelReplaced(); | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | QPieSeries *QVPieModelMapper::series() const |
|
183 | QPieSeries *QVPieModelMapper::series() const | |
184 | { |
|
184 | { | |
185 | return QPieModelMapper::series(); |
|
185 | return QPieModelMapper::series(); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | void QVPieModelMapper::setSeries(QPieSeries *series) |
|
188 | void QVPieModelMapper::setSeries(QPieSeries *series) | |
189 | { |
|
189 | { | |
190 | if (series != QPieModelMapper::series()) { |
|
190 | if (series != QPieModelMapper::series()) { | |
191 | QPieModelMapper::setSeries(series); |
|
191 | QPieModelMapper::setSeries(series); | |
192 | emit seriesReplaced(); |
|
192 | emit seriesReplaced(); | |
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | /*! |
|
196 | /*! | |
197 | Returns which column of the model is kept in sync with the values of the pie's slices |
|
197 | Returns which column of the model is kept in sync with the values of the pie's slices | |
198 | */ |
|
198 | */ | |
199 | int QVPieModelMapper::valuesColumn() const |
|
199 | int QVPieModelMapper::valuesColumn() const | |
200 | { |
|
200 | { | |
201 | return QPieModelMapper::valuesSection(); |
|
201 | return QPieModelMapper::valuesSection(); | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | Sets the model column that is kept in sync with the pie slices values. |
|
205 | Sets the model column that is kept in sync with the pie slices values. | |
206 | Parameter \a valuesColumn specifies the row of the model. |
|
206 | Parameter \a valuesColumn specifies the row of the model. | |
207 | */ |
|
207 | */ | |
208 | void QVPieModelMapper::setValuesColumn(int valuesColumn) |
|
208 | void QVPieModelMapper::setValuesColumn(int valuesColumn) | |
209 | { |
|
209 | { | |
210 | if (valuesColumn != valuesSection()) { |
|
210 | if (valuesColumn != valuesSection()) { | |
211 | QPieModelMapper::setValuesSection(valuesColumn); |
|
211 | QPieModelMapper::setValuesSection(valuesColumn); | |
212 | emit valuesColumnChanged(); |
|
212 | emit valuesColumnChanged(); | |
213 | } |
|
213 | } | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | /*! |
|
216 | /*! | |
217 | Returns which column of the model is kept in sync with the labels of the pie's slices |
|
217 | Returns which column of the model is kept in sync with the labels of the pie's slices | |
218 | */ |
|
218 | */ | |
219 | int QVPieModelMapper::labelsColumn() const |
|
219 | int QVPieModelMapper::labelsColumn() const | |
220 | { |
|
220 | { | |
221 | return QPieModelMapper::labelsSection(); |
|
221 | return QPieModelMapper::labelsSection(); | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | /*! |
|
224 | /*! | |
225 | Sets the model column that is kept in sync with the pie's slices labels. |
|
225 | Sets the model column that is kept in sync with the pie's slices labels. | |
226 | Parameter \a labelsColumn specifies the row of the model. |
|
226 | Parameter \a labelsColumn specifies the row of the model. | |
227 | */ |
|
227 | */ | |
228 | void QVPieModelMapper::setLabelsColumn(int labelsColumn) |
|
228 | void QVPieModelMapper::setLabelsColumn(int labelsColumn) | |
229 | { |
|
229 | { | |
230 | if (labelsColumn != labelsSection()) { |
|
230 | if (labelsColumn != labelsSection()) { | |
231 | QPieModelMapper::setLabelsSection(labelsColumn); |
|
231 | QPieModelMapper::setLabelsSection(labelsColumn); | |
232 | emit labelsColumnChanged(); |
|
232 | emit labelsColumnChanged(); | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | int QVPieModelMapper::firstRow() const |
|
236 | int QVPieModelMapper::firstRow() const | |
237 | { |
|
237 | { | |
238 | return first(); |
|
238 | return first(); | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | void QVPieModelMapper::setFirstRow(int firstRow) |
|
241 | void QVPieModelMapper::setFirstRow(int firstRow) | |
242 | { |
|
242 | { | |
243 | if (firstRow != first()) { |
|
243 | if (firstRow != first()) { | |
244 | setFirst(firstRow); |
|
244 | setFirst(firstRow); | |
245 | emit firstRowChanged(); |
|
245 | emit firstRowChanged(); | |
246 | } |
|
246 | } | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | int QVPieModelMapper::rowCount() const |
|
249 | int QVPieModelMapper::rowCount() const | |
250 | { |
|
250 | { | |
251 | return count(); |
|
251 | return count(); | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | void QVPieModelMapper::setRowCount(int rowCount) |
|
254 | void QVPieModelMapper::setRowCount(int rowCount) | |
255 | { |
|
255 | { | |
256 | if (rowCount != count()) { |
|
256 | if (rowCount != count()) { | |
257 | setCount(rowCount); |
|
257 | setCount(rowCount); | |
258 | emit rowCountChanged(); |
|
258 | emit rowCountChanged(); | |
259 | } |
|
259 | } | |
260 | } |
|
260 | } | |
261 |
|
261 | |||
262 | #include "moc_qvpiemodelmapper.cpp" |
|
262 | #include "moc_qvpiemodelmapper.cpp" | |
263 |
|
263 | |||
264 | QTCOMMERCIALCHART_END_NAMESPACE |
|
264 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,237 +1,237 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qhxymodelmapper.h" |
|
21 | #include "qhxymodelmapper.h" | |
22 |
|
22 | |||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | /*! |
|
25 | /*! | |
26 | \class QHXYModelMapper |
|
26 | \class QHXYModelMapper | |
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 QXYSeries and QAbstractItemModel derived model object. |
|
30 | Horizontal model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object. | |
31 | It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. |
|
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 | 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 HXYModelMapper QHXYModelMapper |
|
35 | \qmlclass HXYModelMapper QHXYModelMapper | |
36 |
|
36 | |||
37 | HXYModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source |
|
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. |
|
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. |
|
39 | HXYModelMapper keeps the series and the model in sync. | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | /*! |
|
42 | /*! | |
43 | \property QHXYModelMapper::series |
|
43 | \property QHXYModelMapper::series | |
44 | \brief Defines the QXYSeries object that is used by the mapper. |
|
44 | \brief Defines the QXYSeries object that is used by the mapper. | |
45 |
|
45 | |||
46 | All the data in the series is discarded when it is set to the mapper. |
|
46 | All the data in the series is discarded when it is set to the mapper. | |
47 | When new series is specified the old series is disconnected (it preserves its data) |
|
47 | When new series is specified the old series is disconnected (it preserves its data) | |
48 | */ |
|
48 | */ | |
49 | /*! |
|
49 | /*! | |
50 | \qmlproperty XYSeries HXYModelMapper::series |
|
50 | \qmlproperty XYSeries HXYModelMapper::series | |
51 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to |
|
51 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to | |
52 | the mapper. When new series is specified the old series is disconnected (it preserves its data). |
|
52 | the mapper. When new series is specified the old series is disconnected (it preserves its data). | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \property QHXYModelMapper::model |
|
56 | \property QHXYModelMapper::model | |
57 | \brief Defines the model that is used by the mapper. |
|
57 | \brief Defines the model that is used by the mapper. | |
58 | */ |
|
58 | */ | |
59 | /*! |
|
59 | /*! | |
60 | \qmlproperty SomeModel HXYModelMapper::model |
|
60 | \qmlproperty SomeModel HXYModelMapper::model | |
61 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
61 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
62 |
|
|
62 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
63 |
|
|
63 | the data of the cells. | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | \property QHXYModelMapper::xRow |
|
67 | \property QHXYModelMapper::xRow | |
68 | \brief Defines which row of the model is kept in sync with the x values of the QXYSeries. |
|
68 | \brief Defines which row of the model is kept in sync with the x values of the QXYSeries. | |
69 |
|
69 | |||
70 | Default value is: -1 (invalid mapping) |
|
70 | Default value is: -1 (invalid mapping) | |
71 | */ |
|
71 | */ | |
72 | /*! |
|
72 | /*! | |
73 | \qmlproperty int HXYModelMapper::xRow |
|
73 | \qmlproperty int HXYModelMapper::xRow | |
74 | Defines which row of the model is kept in sync with the x values of the series. Default value is -1 (invalid |
|
74 | Defines which row of the model is kept in sync with the x values of the series. Default value is -1 (invalid | |
75 | mapping). |
|
75 | mapping). | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \property QHXYModelMapper::yRow |
|
79 | \property QHXYModelMapper::yRow | |
80 | \brief Defines which row of the model is kept in sync with the y values of the QXYSeries. |
|
80 | \brief Defines which row of the model is kept in sync with the y values of the QXYSeries. | |
81 |
|
81 | |||
82 | Default value is: -1 (invalid mapping) |
|
82 | Default value is: -1 (invalid mapping) | |
83 | */ |
|
83 | */ | |
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty int HXYModelMapper::yRow |
|
85 | \qmlproperty int HXYModelMapper::yRow | |
86 | Defines which row of the model is kept in sync with the y values of the series. Default value is -1 |
|
86 | Defines which row of the model is kept in sync with the y values of the series. Default value is -1 | |
87 | (invalid mapping). |
|
87 | (invalid mapping). | |
88 | */ |
|
88 | */ | |
89 |
|
89 | |||
90 | /*! |
|
90 | /*! | |
91 | \property QHXYModelMapper::firstColumn |
|
91 | \property QHXYModelMapper::firstColumn | |
92 | \brief Defines which column of the model contains the data for the first point of the series. |
|
92 | \brief Defines which column of the model contains the data for the first point of the series. | |
93 |
|
93 | |||
94 | Minimal and default value is: 0 |
|
94 | Minimal and default value is: 0 | |
95 | */ |
|
95 | */ | |
96 | /*! |
|
96 | /*! | |
97 | \qmlproperty int HXYModelMapper::firstColumn |
|
97 | \qmlproperty int HXYModelMapper::firstColumn | |
98 | Defines which column of the model contains the data for the first point of the series. |
|
98 | Defines which column of the model contains the data for the first point of the series. | |
99 | The default value is 0. |
|
99 | The default value is 0. | |
100 | */ |
|
100 | */ | |
101 |
|
101 | |||
102 | /*! |
|
102 | /*! | |
103 | \property QHXYModelMapper::columnCount |
|
103 | \property QHXYModelMapper::columnCount | |
104 | \brief Defines the number of columns of the model that are mapped as the data for series. |
|
104 | \brief Defines the number of columns of the model that are mapped as the data for series. | |
105 |
|
105 | |||
106 | Minimal and default value is: -1 (count limited by the number of columns in the model) |
|
106 | Minimal and default value is: -1 (count limited by the number of columns in the model) | |
107 | */ |
|
107 | */ | |
108 | /*! |
|
108 | /*! | |
109 | \qmlproperty int HXYModelMapper::columnCount |
|
109 | \qmlproperty int HXYModelMapper::columnCount | |
110 | Defines the number of columns of the model that are mapped as the data for series. The default value is |
|
110 | Defines the number of columns of the model that are mapped as the data for series. The default value is | |
111 | -1 (count limited by the number of columns in the model) |
|
111 | -1 (count limited by the number of columns in the model) | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | \fn void QHXYModelMapper::seriesReplaced() |
|
115 | \fn void QHXYModelMapper::seriesReplaced() | |
116 |
|
116 | |||
117 | Emitted when the series to which mapper is connected to has changed. |
|
117 | Emitted when the series to which mapper is connected to has changed. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QHXYModelMapper::modelReplaced() |
|
121 | \fn void QHXYModelMapper::modelReplaced() | |
122 |
|
122 | |||
123 | Emitted when the model to which mapper is connected to has changed. |
|
123 | Emitted when the model to which mapper is connected to has changed. | |
124 | */ |
|
124 | */ | |
125 |
|
125 | |||
126 | /*! |
|
126 | /*! | |
127 | \fn void QHXYModelMapper::xRowChanged() |
|
127 | \fn void QHXYModelMapper::xRowChanged() | |
128 |
|
128 | |||
129 | Emitted when the xRow has changed. |
|
129 | Emitted when the xRow has changed. | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QHXYModelMapper::yRowChanged() |
|
133 | \fn void QHXYModelMapper::yRowChanged() | |
134 |
|
134 | |||
135 | Emitted when the yRow has changed. |
|
135 | Emitted when the yRow has changed. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QHXYModelMapper::firstColumnChanged() |
|
139 | \fn void QHXYModelMapper::firstColumnChanged() | |
140 | Emitted when the firstColumn has changed. |
|
140 | Emitted when the firstColumn has changed. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn void QHXYModelMapper::columnCountChanged() |
|
144 | \fn void QHXYModelMapper::columnCountChanged() | |
145 | Emitted when the columnCount has changed. |
|
145 | Emitted when the columnCount has changed. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | Constructs a mapper object which is a child of \a parent. |
|
149 | Constructs a mapper object which is a child of \a parent. | |
150 | */ |
|
150 | */ | |
151 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : |
|
151 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : | |
152 | QXYModelMapper(parent) |
|
152 | QXYModelMapper(parent) | |
153 | { |
|
153 | { | |
154 | QXYModelMapper::setOrientation(Qt::Horizontal); |
|
154 | QXYModelMapper::setOrientation(Qt::Horizontal); | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | QAbstractItemModel *QHXYModelMapper::model() const |
|
157 | QAbstractItemModel *QHXYModelMapper::model() const | |
158 | { |
|
158 | { | |
159 | return QXYModelMapper::model(); |
|
159 | return QXYModelMapper::model(); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void QHXYModelMapper::setModel(QAbstractItemModel *model) |
|
162 | void QHXYModelMapper::setModel(QAbstractItemModel *model) | |
163 | { |
|
163 | { | |
164 | if (model != QXYModelMapper::model()) { |
|
164 | if (model != QXYModelMapper::model()) { | |
165 | QXYModelMapper::setModel(model); |
|
165 | QXYModelMapper::setModel(model); | |
166 | emit modelReplaced(); |
|
166 | emit modelReplaced(); | |
167 | } |
|
167 | } | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QXYSeries *QHXYModelMapper::series() const |
|
170 | QXYSeries *QHXYModelMapper::series() const | |
171 | { |
|
171 | { | |
172 | return QXYModelMapper::series(); |
|
172 | return QXYModelMapper::series(); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | void QHXYModelMapper::setSeries(QXYSeries *series) |
|
175 | void QHXYModelMapper::setSeries(QXYSeries *series) | |
176 | { |
|
176 | { | |
177 | if (series != QXYModelMapper::series()) { |
|
177 | if (series != QXYModelMapper::series()) { | |
178 | QXYModelMapper::setSeries(series); |
|
178 | QXYModelMapper::setSeries(series); | |
179 | emit seriesReplaced(); |
|
179 | emit seriesReplaced(); | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | int QHXYModelMapper::xRow() const |
|
183 | int QHXYModelMapper::xRow() const | |
184 | { |
|
184 | { | |
185 | return QXYModelMapper::xSection(); |
|
185 | return QXYModelMapper::xSection(); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | void QHXYModelMapper::setXRow(int xRow) |
|
188 | void QHXYModelMapper::setXRow(int xRow) | |
189 | { |
|
189 | { | |
190 | if (xRow != xSection()) { |
|
190 | if (xRow != xSection()) { | |
191 | QXYModelMapper::setXSection(xRow); |
|
191 | QXYModelMapper::setXSection(xRow); | |
192 | emit xRowChanged(); |
|
192 | emit xRowChanged(); | |
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | int QHXYModelMapper::yRow() const |
|
196 | int QHXYModelMapper::yRow() const | |
197 | { |
|
197 | { | |
198 | return QXYModelMapper::ySection(); |
|
198 | return QXYModelMapper::ySection(); | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | void QHXYModelMapper::setYRow(int yRow) |
|
201 | void QHXYModelMapper::setYRow(int yRow) | |
202 | { |
|
202 | { | |
203 | if (yRow != ySection()) { |
|
203 | if (yRow != ySection()) { | |
204 | QXYModelMapper::setYSection(yRow); |
|
204 | QXYModelMapper::setYSection(yRow); | |
205 | emit yRowChanged(); |
|
205 | emit yRowChanged(); | |
206 | } |
|
206 | } | |
207 | } |
|
207 | } | |
208 |
|
208 | |||
209 | int QHXYModelMapper::firstColumn() const |
|
209 | int QHXYModelMapper::firstColumn() const | |
210 | { |
|
210 | { | |
211 | return first(); |
|
211 | return first(); | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | void QHXYModelMapper::setFirstColumn(int firstColumn) |
|
214 | void QHXYModelMapper::setFirstColumn(int firstColumn) | |
215 | { |
|
215 | { | |
216 | if (firstColumn != first()) { |
|
216 | if (firstColumn != first()) { | |
217 | setFirst(firstColumn); |
|
217 | setFirst(firstColumn); | |
218 | emit firstColumnChanged(); |
|
218 | emit firstColumnChanged(); | |
219 | } |
|
219 | } | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | int QHXYModelMapper::columnCount() const |
|
222 | int QHXYModelMapper::columnCount() const | |
223 | { |
|
223 | { | |
224 | return count(); |
|
224 | return count(); | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | void QHXYModelMapper::setColumnCount(int columnCount) |
|
227 | void QHXYModelMapper::setColumnCount(int columnCount) | |
228 | { |
|
228 | { | |
229 | if (columnCount != count()) { |
|
229 | if (columnCount != count()) { | |
230 | setCount(columnCount); |
|
230 | setCount(columnCount); | |
231 | emit columnCountChanged(); |
|
231 | emit columnCountChanged(); | |
232 | } |
|
232 | } | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | #include "moc_qhxymodelmapper.cpp" |
|
235 | #include "moc_qhxymodelmapper.cpp" | |
236 |
|
236 | |||
237 | QTCOMMERCIALCHART_END_NAMESPACE |
|
237 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,237 +1,237 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qvxymodelmapper.h" |
|
21 | #include "qvxymodelmapper.h" | |
22 |
|
22 | |||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | /*! |
|
25 | /*! | |
26 | \class QVXYModelMapper |
|
26 | \class QVXYModelMapper | |
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 QXYSeries and QAbstractItemModel derived model object. |
|
30 | Vertical model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object. | |
31 | It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. |
|
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 | 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 VXYModelMapper QHXYModelMapper |
|
35 | \qmlclass VXYModelMapper QHXYModelMapper | |
36 |
|
36 | |||
37 | VXYModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source |
|
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. |
|
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. |
|
39 | VYModelMapper keeps the series and the model in sync. | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | /*! |
|
42 | /*! | |
43 | \property QVXYModelMapper::series |
|
43 | \property QVXYModelMapper::series | |
44 | \brief Defines the QXYSeries object that is used by the mapper. |
|
44 | \brief Defines the QXYSeries object that is used by the mapper. | |
45 |
|
45 | |||
46 | All the data in the series is discarded when it is set to the mapper. |
|
46 | All the data in the series is discarded when it is set to the mapper. | |
47 | When new series is specified the old series is disconnected (it preserves its data) |
|
47 | When new series is specified the old series is disconnected (it preserves its data) | |
48 | */ |
|
48 | */ | |
49 | /*! |
|
49 | /*! | |
50 | \qmlproperty XYSeries VXYModelMapper::series |
|
50 | \qmlproperty XYSeries VXYModelMapper::series | |
51 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to |
|
51 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to | |
52 | the mapper. When new series is specified the old series is disconnected (it preserves its data). |
|
52 | the mapper. When new series is specified the old series is disconnected (it preserves its data). | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \property QVXYModelMapper::model |
|
56 | \property QVXYModelMapper::model | |
57 | \brief Defines the model that is used by the mapper. |
|
57 | \brief Defines the model that is used by the mapper. | |
58 | */ |
|
58 | */ | |
59 | /*! |
|
59 | /*! | |
60 | \qmlproperty SomeModel VXYModelMapper::model |
|
60 | \qmlproperty SomeModel VXYModelMapper::model | |
61 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
61 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
62 |
|
|
62 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
63 |
|
|
63 | the data of the cells. | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | \property QVXYModelMapper::xColumn |
|
67 | \property QVXYModelMapper::xColumn | |
68 | \brief Defines which column of the model is kept in sync with the x values of QXYSeries. |
|
68 | \brief Defines which column of the model is kept in sync with the x values of QXYSeries. | |
69 |
|
69 | |||
70 | Default value is: -1 (invalid mapping) |
|
70 | Default value is: -1 (invalid mapping) | |
71 | */ |
|
71 | */ | |
72 | /*! |
|
72 | /*! | |
73 | \qmlproperty int VXYModelMapper::xColumn |
|
73 | \qmlproperty int VXYModelMapper::xColumn | |
74 | Defines which column of the model is kept in sync with the x values of the series. Default value is -1 (invalid |
|
74 | Defines which column of the model is kept in sync with the x values of the series. Default value is -1 (invalid | |
75 | mapping). |
|
75 | mapping). | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \property QVXYModelMapper::yColumn |
|
79 | \property QVXYModelMapper::yColumn | |
80 | \brief Defines which column of the model is kept in sync with the y values of QXYSeries. |
|
80 | \brief Defines which column of the model is kept in sync with the y values of QXYSeries. | |
81 |
|
81 | |||
82 | Default value is: -1 (invalid mapping) |
|
82 | Default value is: -1 (invalid mapping) | |
83 | */ |
|
83 | */ | |
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty int VXYModelMapper::yColumn |
|
85 | \qmlproperty int VXYModelMapper::yColumn | |
86 | Defines which column of the model is kept in sync with the y values of the series. Default value is -1 (invalid |
|
86 | Defines which column of the model is kept in sync with the y values of the series. Default value is -1 (invalid | |
87 | mapping). |
|
87 | mapping). | |
88 | */ |
|
88 | */ | |
89 |
|
89 | |||
90 | /*! |
|
90 | /*! | |
91 | \property QVXYModelMapper::firstRow |
|
91 | \property QVXYModelMapper::firstRow | |
92 | \brief Defines which row of the model contains the data for the first point of the series. |
|
92 | \brief Defines which row of the model contains the data for the first point of the series. | |
93 |
|
93 | |||
94 | Minimal and default value is: 0 |
|
94 | Minimal and default value is: 0 | |
95 | */ |
|
95 | */ | |
96 | /*! |
|
96 | /*! | |
97 | \qmlproperty int VXYModelMapper::firstRow |
|
97 | \qmlproperty int VXYModelMapper::firstRow | |
98 | Defines which row of the model contains the data for the first point of the series. |
|
98 | Defines which row of the model contains the data for the first point of the series. | |
99 | The default value is 0. |
|
99 | The default value is 0. | |
100 | */ |
|
100 | */ | |
101 |
|
101 | |||
102 | /*! |
|
102 | /*! | |
103 | \property QVXYModelMapper::rowCount |
|
103 | \property QVXYModelMapper::rowCount | |
104 | \brief Defines the number of rows of the model that are mapped as the data for series. |
|
104 | \brief Defines the number of rows of the model that are mapped as the data for series. | |
105 |
|
105 | |||
106 | Minimal and default value is: -1 (count limited by the number of rows in the model) |
|
106 | Minimal and default value is: -1 (count limited by the number of rows in the model) | |
107 | */ |
|
107 | */ | |
108 | /*! |
|
108 | /*! | |
109 | \qmlproperty int VXYModelMapper::columnCount |
|
109 | \qmlproperty int VXYModelMapper::columnCount | |
110 | Defines the number of rows of the model that are mapped as the data for series. The default value is |
|
110 | Defines the number of rows of the model that are mapped as the data for series. The default value is | |
111 | -1 (count limited by the number of rows in the model). |
|
111 | -1 (count limited by the number of rows in the model). | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | \fn void QVXYModelMapper::seriesReplaced() |
|
115 | \fn void QVXYModelMapper::seriesReplaced() | |
116 |
|
116 | |||
117 | Emitted when the series to which mapper is connected to has changed. |
|
117 | Emitted when the series to which mapper is connected to has changed. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QVXYModelMapper::modelReplaced() |
|
121 | \fn void QVXYModelMapper::modelReplaced() | |
122 |
|
122 | |||
123 | Emitted when the model to which mapper is connected to has changed. |
|
123 | Emitted when the model to which mapper is connected to has changed. | |
124 | */ |
|
124 | */ | |
125 |
|
125 | |||
126 | /*! |
|
126 | /*! | |
127 | \fn void QVXYModelMapper::xColumnChanged() |
|
127 | \fn void QVXYModelMapper::xColumnChanged() | |
128 |
|
128 | |||
129 | Emitted when the xColumn has changed. |
|
129 | Emitted when the xColumn has changed. | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QVXYModelMapper::yColumnChanged() |
|
133 | \fn void QVXYModelMapper::yColumnChanged() | |
134 |
|
134 | |||
135 | Emitted when the yColumn has changed. |
|
135 | Emitted when the yColumn has changed. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QVXYModelMapper::firstRowChanged() |
|
139 | \fn void QVXYModelMapper::firstRowChanged() | |
140 | Emitted when the firstRow has changed. |
|
140 | Emitted when the firstRow has changed. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn void QVXYModelMapper::rowCountChanged() |
|
144 | \fn void QVXYModelMapper::rowCountChanged() | |
145 | Emitted when the rowCount has changed. |
|
145 | Emitted when the rowCount has changed. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | Constructs a mapper object which is a child of \a parent. |
|
149 | Constructs a mapper object which is a child of \a parent. | |
150 | */ |
|
150 | */ | |
151 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : |
|
151 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : | |
152 | QXYModelMapper(parent) |
|
152 | QXYModelMapper(parent) | |
153 | { |
|
153 | { | |
154 | QXYModelMapper::setOrientation(Qt::Vertical); |
|
154 | QXYModelMapper::setOrientation(Qt::Vertical); | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | QAbstractItemModel *QVXYModelMapper::model() const |
|
157 | QAbstractItemModel *QVXYModelMapper::model() const | |
158 | { |
|
158 | { | |
159 | return QXYModelMapper::model(); |
|
159 | return QXYModelMapper::model(); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void QVXYModelMapper::setModel(QAbstractItemModel *model) |
|
162 | void QVXYModelMapper::setModel(QAbstractItemModel *model) | |
163 | { |
|
163 | { | |
164 | if (model != QXYModelMapper::model()) { |
|
164 | if (model != QXYModelMapper::model()) { | |
165 | QXYModelMapper::setModel(model); |
|
165 | QXYModelMapper::setModel(model); | |
166 | emit modelReplaced(); |
|
166 | emit modelReplaced(); | |
167 | } |
|
167 | } | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | QXYSeries *QVXYModelMapper::series() const |
|
170 | QXYSeries *QVXYModelMapper::series() const | |
171 | { |
|
171 | { | |
172 | return QXYModelMapper::series(); |
|
172 | return QXYModelMapper::series(); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | void QVXYModelMapper::setSeries(QXYSeries *series) |
|
175 | void QVXYModelMapper::setSeries(QXYSeries *series) | |
176 | { |
|
176 | { | |
177 | if (series != QXYModelMapper::series()) { |
|
177 | if (series != QXYModelMapper::series()) { | |
178 | QXYModelMapper::setSeries(series); |
|
178 | QXYModelMapper::setSeries(series); | |
179 | emit seriesReplaced(); |
|
179 | emit seriesReplaced(); | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | int QVXYModelMapper::xColumn() const |
|
183 | int QVXYModelMapper::xColumn() const | |
184 | { |
|
184 | { | |
185 | return QXYModelMapper::xSection(); |
|
185 | return QXYModelMapper::xSection(); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | void QVXYModelMapper::setXColumn(int xColumn) |
|
188 | void QVXYModelMapper::setXColumn(int xColumn) | |
189 | { |
|
189 | { | |
190 | if (xColumn != xSection()) { |
|
190 | if (xColumn != xSection()) { | |
191 | QXYModelMapper::setXSection(xColumn); |
|
191 | QXYModelMapper::setXSection(xColumn); | |
192 | emit xColumnChanged(); |
|
192 | emit xColumnChanged(); | |
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | int QVXYModelMapper::yColumn() const |
|
196 | int QVXYModelMapper::yColumn() const | |
197 | { |
|
197 | { | |
198 | return QXYModelMapper::ySection(); |
|
198 | return QXYModelMapper::ySection(); | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | void QVXYModelMapper::setYColumn(int yColumn) |
|
201 | void QVXYModelMapper::setYColumn(int yColumn) | |
202 | { |
|
202 | { | |
203 | if (yColumn != ySection()) { |
|
203 | if (yColumn != ySection()) { | |
204 | QXYModelMapper::setYSection(yColumn); |
|
204 | QXYModelMapper::setYSection(yColumn); | |
205 | emit yColumnChanged(); |
|
205 | emit yColumnChanged(); | |
206 | } |
|
206 | } | |
207 | } |
|
207 | } | |
208 |
|
208 | |||
209 | int QVXYModelMapper::firstRow() const |
|
209 | int QVXYModelMapper::firstRow() const | |
210 | { |
|
210 | { | |
211 | return first(); |
|
211 | return first(); | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | void QVXYModelMapper::setFirstRow(int firstRow) |
|
214 | void QVXYModelMapper::setFirstRow(int firstRow) | |
215 | { |
|
215 | { | |
216 | if (firstRow != first()) { |
|
216 | if (firstRow != first()) { | |
217 | setFirst(firstRow); |
|
217 | setFirst(firstRow); | |
218 | emit firstRowChanged(); |
|
218 | emit firstRowChanged(); | |
219 | } |
|
219 | } | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | int QVXYModelMapper::rowCount() const |
|
222 | int QVXYModelMapper::rowCount() const | |
223 | { |
|
223 | { | |
224 | return count(); |
|
224 | return count(); | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | void QVXYModelMapper::setRowCount(int rowCount) |
|
227 | void QVXYModelMapper::setRowCount(int rowCount) | |
228 | { |
|
228 | { | |
229 | if (rowCount != count()) { |
|
229 | if (rowCount != count()) { | |
230 | setCount(rowCount); |
|
230 | setCount(rowCount); | |
231 | emit rowCountChanged(); |
|
231 | emit rowCountChanged(); | |
232 | } |
|
232 | } | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | #include "moc_qvxymodelmapper.cpp" |
|
235 | #include "moc_qvxymodelmapper.cpp" | |
236 |
|
236 | |||
237 | QTCOMMERCIALCHART_END_NAMESPACE |
|
237 | QTCOMMERCIALCHART_END_NAMESPACE |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now