##// END OF EJS Templates
Updated QML bar model mapper property names
Tero Ahola -
r1496:46e4d06d4e0f
parent child
Show More
@@ -1,155 +1,155
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 import QtQuick 1.0
22 22 import QtCommercial.Chart 1.0
23 23 import QmlCustomModel 1.0
24 24
25 25 Rectangle {
26 26 anchors.fill: parent
27 27
28 28 //![1]
29 29 ChartView {
30 30 id: chartView
31 31 title: "Top-5 car brand shares in Finland"
32 32 anchors.fill: parent
33 33 axisX.max: 10
34 34 axisX.min: 0
35 35 axisY.max: 20
36 36 axisY.min: 0
37 37 animationOptions: ChartView.SeriesAnimations
38 38 axisXLabels: [0, "2007", 1, "2008", 2, "2009", 3, "2010", 4, "2011", 5, "2012"]
39 39 // ...
40 40 //![1]
41 41
42 42 //![2]
43 43 CustomModel {
44 44 id: customModel
45 45 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
46 46 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
47 47 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
48 48 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
49 49 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
50 50 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
51 51 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
52 52 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
53 53 }
54 54 //![2]
55 55
56 56 //![5]
57 57 BarSeries {
58 58 name: "Others"
59 59 barWidth: 0.9
60 60 visible: false
61 61 HBarModelMapper {
62 62 model: customModel
63 63 firstBarSetRow: 6
64 64 lastBarSetRow: 6
65 first: 2
65 firstColumn: 2
66 66 }
67 67 }
68 68 //![5]
69 69
70 70 //![4]
71 71 LineSeries {
72 72 name: "Volkswagen"
73 73 visible: false
74 74 HXYModelMapper {
75 75 model: customModel
76 76 xRow: 0
77 77 yRow: 1
78 78 first: 2
79 79 }
80 80 }
81 81 //![4]
82 82
83 83 LineSeries {
84 84 name: "Toyota"
85 85 visible: false
86 86 HXYModelMapper {
87 87 model: customModel
88 88 xRow: 0
89 89 yRow: 2
90 90 first: 2
91 91 }
92 92 }
93 93
94 94 LineSeries {
95 95 name: "Ford"
96 96 visible: false
97 97 HXYModelMapper {
98 98 model: customModel
99 99 xRow: 0
100 100 yRow: 3
101 101 first: 2
102 102 }
103 103 }
104 104
105 105 LineSeries {
106 106 name: "Skoda"
107 107 visible: false
108 108 HXYModelMapper {
109 109 model: customModel
110 110 xRow: 0
111 111 yRow: 4
112 112 first: 2
113 113 }
114 114 }
115 115
116 116 LineSeries {
117 117 name: "Volvo"
118 118 visible: false
119 119 HXYModelMapper {
120 120 model: customModel
121 121 xRow: 0
122 122 yRow: 5
123 123 first: 2
124 124 }
125 125 }
126 126
127 127 //![3]
128 128 PieSeries {
129 129 id: pieSeries
130 130 size: 0.4
131 131 horizontalPosition: 0.7
132 132 verticalPosition: 0.4
133 133 onClicked: {
134 134 // Show the selection by exploding the slice
135 135 slice.exploded = !slice.exploded;
136 136
137 137 // Update the line series to show the yearly data for this slice
138 138 for (var i = 0; i < chartView.count; i++) {
139 139 if (chartView.series(i).name == slice.label) {
140 140 chartView.series(i).visible = slice.exploded;
141 141 }
142 142 }
143 143 }
144 144 }
145 145 //![3]
146 146
147 147 VPieModelMapper {
148 148 series: pieSeries
149 149 model: customModel
150 150 labelsColumn: 1
151 151 valuesColumn: 2
152 152 first: 1
153 153 }
154 154 }
155 155 }
@@ -1,178 +1,178
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qhbarmodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QHBarModelMapper
27 27 \brief part of QtCommercial chart API.
28 28 \mainclass
29 29
30 30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
31 31 Horizontal model mapper is used to create a connection between QBarSeries and QAbstractItemModel derived model object.
32 32 Model mapper maintains equal size of all the BarSets.
33 33 Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series.
34 34 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
35 35 */
36 36 /*!
37 37 \qmlclass HBarModelMapper
38 38 \inherits BarModelMapper
39 39 \mainclass
40 40
41 41 HBarModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source
42 42 for any bar series. The following QML example would create a bar series with three bar sets (assuming the model has
43 43 at least four rows). Each bar set would contain data starting from column 1. The name of a set would be defined
44 44 by the vertical header (of the row).
45 45 \code
46 46 BarSeries {
47 47 HBarModelMapper {
48 48 model: myCustomModel
49 49 firstBarSetRow: 1
50 50 lastBarSetRow: 3
51 first: 1
51 firstColumn: 1
52 52 }
53 53 }
54 54 \endcode
55 55 */
56 56
57 57 /*!
58 58 \property QHBarModelMapper::firstBarSetRow
59 59 \brief Defines which column of the model is used as the data source for the first bar set
60 60
61 61 Default value is: -1 (invalid mapping)
62 62 */
63 63
64 64 /*!
65 65 \property QHBarModelMapper::lastBarSetRow
66 66 \brief Defines which column of the model is used as the data source for the last bar set
67 67
68 68 Default value is: -1 (invalid mapping)
69 69 */
70 70
71 71 /*!
72 72 \property QHBarModelMapper::firstColumn
73 73 \brief Defines which column of the model contains the first values of the QBarSets in the series.
74 74 Minimal and default value is: 0
75 75 */
76 76 /*!
77 \qmlproperty int BarModelMapper::first
77 \qmlproperty int BarModelMapper::firstColumn
78 78 Defines which column of the model contains the first values of the QBarSets in the series.
79 79 The default value is 0.
80 80 */
81 81
82 82 /*!
83 83 \property QHBarModelMapper::columnCount
84 84 \brief Defines the number of rows of the model that are mapped as the data for QBarSeries
85 85 Minimal and default value is: -1 (count limited by the number of rows in the model)
86 86 */
87 87 /*!
88 \qmlproperty int BarModelMapper::count
88 \qmlproperty int BarModelMapper::columnCount
89 89 Defines the number of rows of the model that are mapped as the data for QBarSeries. The default value is
90 90 -1 (count limited by the number of rows in the model)
91 91 */
92 92
93 93 /*!
94 94 \fn void QHBarModelMapper::firstBarSetRowChanged()
95 95
96 96 Emitted when the firstBarSetRow has changed.
97 97 */
98 98
99 99 /*!
100 100 \fn void QHBarModelMapper::lastBarSetRowChanged()
101 101
102 102 Emitted when the lastBarSetRow has changed.
103 103 */
104 104
105 105 /*!
106 106 \fn void QHBarModelMapper::firstColumnChanged()
107 107 Emitted when the firstColumn has changed.
108 108 */
109 109
110 110 /*!
111 111 \fn void QHBarModelMapper::columnCountChanged()
112 112 Emitted when the columnCount has changed.
113 113 */
114 114
115 115 /*!
116 116 Constructs a mapper object which is a child of \a parent.
117 117 */
118 118 QHBarModelMapper::QHBarModelMapper(QObject *parent) :
119 119 QBarModelMapper(parent)
120 120 {
121 121 QBarModelMapper::setOrientation(Qt::Horizontal);
122 122 }
123 123
124 124 int QHBarModelMapper::firstBarSetRow() const
125 125 {
126 126 return QBarModelMapper::firstBarSetSection();
127 127 }
128 128
129 129 void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow)
130 130 {
131 131 if (firstBarSetRow != firstBarSetSection()) {
132 132 QBarModelMapper::setFirstBarSetSection(firstBarSetRow);
133 133 emit firstBarSetRowChanged();
134 134 }
135 135 }
136 136
137 137 int QHBarModelMapper::lastBarSetRow() const
138 138 {
139 139 return QBarModelMapper::lastBarSetSection();
140 140 }
141 141
142 142 void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow)
143 143 {
144 144 if (lastBarSetRow != lastBarSetSection()) {
145 145 QBarModelMapper::setLastBarSetSection(lastBarSetRow);
146 146 emit lastBarSetRowChanged();
147 147 }
148 148 }
149 149
150 150 int QHBarModelMapper::firstColumn() const
151 151 {
152 152 return QBarModelMapper::first();
153 153 }
154 154
155 155 void QHBarModelMapper::setFirstColumn(int firstColumn)
156 156 {
157 157 if (firstColumn != first()) {
158 158 QBarModelMapper::setFirst(firstColumn);
159 159 emit firstColumnChanged();
160 160 }
161 161 }
162 162
163 163 int QHBarModelMapper::columnCount() const
164 164 {
165 165 return QBarModelMapper::count();
166 166 }
167 167
168 168 void QHBarModelMapper::setColumnCount(int columnCount)
169 169 {
170 170 if (columnCount != count()) {
171 171 QBarModelMapper::setCount(columnCount);
172 172 emit firstColumnChanged();
173 173 }
174 174 }
175 175
176 176 #include "moc_qhbarmodelmapper.cpp"
177 177
178 178 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,184 +1,184
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qvbarmodelmapper.h"
22 22
23 23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 24
25 25 /*!
26 26 \class QVBarModelMapper
27 27 \brief part of QtCommercial chart API.
28 28 \mainclass
29 29
30 30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
31 31 Vertical model mapper is used to create a connection between QBarSeries and QAbstractItemModel derived model object.
32 32 Model mapper maintains equal size of all the BarSets.
33 33 Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series.
34 34 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
35 35 */
36 36 /*!
37 37 \qmlclass VBarModelMapper
38 38 \inherits BarModelMapper
39 39 \mainclass
40 40
41 41 VBarModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source
42 42 for any bar series. The following QML example would create a bar series with three bar sets (assuming the model has
43 43 at least four columns). Each bar set would contain data starting from row 1. The name of a set would be defined
44 44 by the horizontal header (of the column).
45 45 \code
46 46 GroupedBarSeries {
47 47 VBarModelMapper {
48 48 model: myCustomModel
49 49 firstBarSetColumn: 1
50 50 lastBarSetColumn: 3
51 first: 1
51 firstRow: 1
52 52 }
53 53 }
54 54 \endcode
55 55 */
56 56
57 57 /*!
58 58 \property QVBarModelMapper::firstBarSetColumn
59 59 \brief Defines which column of the model is used as the data source for the first bar set
60 60 Default value is: -1 (invalid mapping)
61 61 */
62 62 /*!
63 63 \qmlproperty int VBarModelMapper::firstBarSetColumn
64 64 Defines which column of the model is used as the data source for the first bar set. Default value
65 65 is: -1 (invalid mapping).
66 66 */
67 67
68 68 /*!
69 69 \property QVBarModelMapper::lastBarSetColumn
70 70 \brief Defines which column of the model is used as the data source for the last bar set
71 71 Default value is: -1 (invalid mapping)
72 72 */
73 73 /*!
74 74 \qmlproperty int VBarModelMapper::lastBarSetColumn
75 75 Defines which column of the model is used as the data source for the last bar set. Default
76 76 value is: -1 (invalid mapping).
77 77 */
78 78
79 79 /*!
80 80 \property QVBarModelMapper::firstRow
81 81 \brief Defines which row of the model contains the first values of the QBarSets in the series.
82 82 Minimal and default value is: 0
83 83 */
84 84 /*!
85 \qmlproperty int BarModelMapper::first
85 \qmlproperty int BarModelMapper::firstRow
86 86 Defines which row of the model contains the first values of the QBarSets in the series.
87 87 The default value is 0.
88 88 */
89 89
90 90 /*!
91 91 \property QVBarModelMapper::rowCount
92 92 \brief Defines the number of rows of the model that are mapped as the data for QBarSeries
93 93 Minimal and default value is: -1 (count limited by the number of rows in the model)
94 94 */
95 95 /*!
96 \qmlproperty int BarModelMapper::count
96 \qmlproperty int BarModelMapper::rowCount
97 97 Defines the number of rows of the model that are mapped as the data for QBarSeries. The default value is
98 98 -1 (count limited by the number of rows in the model)
99 99 */
100 100
101 101 /*!
102 102 \fn void QVBarModelMapper::firstBarSetColumnChanged()
103 103 Emitted when the firstBarSetColumn has changed.
104 104 */
105 105
106 106 /*!
107 107 \fn void QVBarModelMapper::lastBarSetColumnChanged()
108 108 Emitted when the lastBarSetColumn has changed.
109 109 */
110 110
111 111 /*!
112 112 \fn void QVBarModelMapper::firstRowChanged()
113 113 Emitted when the firstRow has changed.
114 114 */
115 115
116 116 /*!
117 117 \fn void QVBarModelMapper::rowCountChanged()
118 118 Emitted when the rowCount has changed.
119 119 */
120 120
121 121 /*!
122 122 Constructs a mapper object which is a child of \a parent.
123 123 */
124 124 QVBarModelMapper::QVBarModelMapper(QObject *parent) :
125 125 QBarModelMapper(parent)
126 126 {
127 127 QBarModelMapper::setOrientation(Qt::Vertical);
128 128 }
129 129
130 130 int QVBarModelMapper::firstBarSetColumn() const
131 131 {
132 132 return QBarModelMapper::firstBarSetSection();
133 133 }
134 134
135 135 void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn)
136 136 {
137 137 if (firstBarSetColumn != firstBarSetSection()) {
138 138 QBarModelMapper::setFirstBarSetSection(firstBarSetColumn);
139 139 emit firstBarSetColumnChanged();
140 140 }
141 141 }
142 142
143 143 int QVBarModelMapper::lastBarSetColumn() const
144 144 {
145 145 return QBarModelMapper::lastBarSetSection();
146 146 }
147 147
148 148 void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn)
149 149 {
150 150 if (lastBarSetColumn != lastBarSetSection()) {
151 151 QBarModelMapper::setLastBarSetSection(lastBarSetColumn);
152 152 emit lastBarSetColumnChanged();
153 153 }
154 154 }
155 155
156 156 int QVBarModelMapper::firstRow() const
157 157 {
158 158 return QBarModelMapper::first();
159 159 }
160 160
161 161 void QVBarModelMapper::setFirstRow(int firstRow)
162 162 {
163 163 if (firstRow != first()) {
164 164 QBarModelMapper::setFirst(firstRow);
165 165 emit firstRowChanged();
166 166 }
167 167 }
168 168
169 169 int QVBarModelMapper::rowCount() const
170 170 {
171 171 return QBarModelMapper::count();
172 172 }
173 173
174 174 void QVBarModelMapper::setRowCount(int rowCount)
175 175 {
176 176 if (rowCount != count()) {
177 177 QBarModelMapper::setCount(rowCount);
178 178 emit firstRowChanged();
179 179 }
180 180 }
181 181
182 182 #include "moc_qvbarmodelmapper.cpp"
183 183
184 184 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now