@@ -1,423 +1,423 | |||||
1 | #include "qbarmodelmapper.h" |
|
1 | #include "qbarmodelmapper.h" | |
2 | #include "qbarmodelmapper_p.h" |
|
2 | #include "qbarmodelmapper_p.h" | |
3 | #include "qbarseries.h" |
|
3 | #include "qbarseries.h" | |
4 | #include "qbarset.h" |
|
4 | #include "qbarset.h" | |
5 | #include <QAbstractItemModel> |
|
5 | #include <QAbstractItemModel> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
9 | QBarModelMapper::QBarModelMapper(QObject *parent) : |
|
9 | QBarModelMapper::QBarModelMapper(QObject *parent) : | |
10 | QObject(parent), |
|
10 | QObject(parent), | |
11 | d_ptr(new QBarModelMapperPrivate(this)) |
|
11 | d_ptr(new QBarModelMapperPrivate(this)) | |
12 | { |
|
12 | { | |
13 | } |
|
13 | } | |
14 |
|
14 | |||
15 | QAbstractItemModel* QBarModelMapper::model() const |
|
15 | QAbstractItemModel* QBarModelMapper::model() const | |
16 | { |
|
16 | { | |
17 | Q_D(const QBarModelMapper); |
|
17 | Q_D(const QBarModelMapper); | |
18 | return d->m_model; |
|
18 | return d->m_model; | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | void QBarModelMapper::setModel(QAbstractItemModel *model) |
|
21 | void QBarModelMapper::setModel(QAbstractItemModel *model) | |
22 | { |
|
22 | { | |
23 | if (model == 0) |
|
23 | if (model == 0) | |
24 | return; |
|
24 | return; | |
25 |
|
25 | |||
26 | Q_D(QBarModelMapper); |
|
26 | Q_D(QBarModelMapper); | |
27 | if (d->m_model) { |
|
27 | if (d->m_model) { | |
28 | disconnect(d->m_model, 0, d, 0); |
|
28 | disconnect(d->m_model, 0, d, 0); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | d->m_model = model; |
|
31 | d->m_model = model; | |
32 | d->initializeBarFromModel(); |
|
32 | d->initializeBarFromModel(); | |
33 | // connect signals from the model |
|
33 | // connect signals from the model | |
34 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
34 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
35 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
35 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
36 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
36 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
37 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
37 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
38 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
38 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | QBarSeries* QBarModelMapper::series() const |
|
41 | QBarSeries* QBarModelMapper::series() const | |
42 | { |
|
42 | { | |
43 | Q_D(const QBarModelMapper); |
|
43 | Q_D(const QBarModelMapper); | |
44 | return d->m_series; |
|
44 | return d->m_series; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void QBarModelMapper::setSeries(QBarSeries *series) |
|
47 | void QBarModelMapper::setSeries(QBarSeries *series) | |
48 | { |
|
48 | { | |
49 | Q_D(QBarModelMapper); |
|
49 | Q_D(QBarModelMapper); | |
50 | if (d->m_series) { |
|
50 | if (d->m_series) { | |
51 | disconnect(d->m_series, 0, d, 0); |
|
51 | disconnect(d->m_series, 0, d, 0); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | if (series == 0) |
|
54 | if (series == 0) | |
55 | return; |
|
55 | return; | |
56 |
|
56 | |||
57 | d->m_series = series; |
|
57 | d->m_series = series; | |
58 | d->initializeBarFromModel(); |
|
58 | d->initializeBarFromModel(); | |
59 | // connect the signals from the series |
|
59 | // connect the signals from the series | |
60 | // connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); |
|
60 | // connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); | |
61 | // connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); |
|
61 | // connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); | |
62 | // connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); |
|
62 | // connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | int QBarModelMapper::first() const |
|
65 | int QBarModelMapper::first() const | |
66 | { |
|
66 | { | |
67 | Q_D(const QBarModelMapper); |
|
67 | Q_D(const QBarModelMapper); | |
68 | return d->m_first; |
|
68 | return d->m_first; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void QBarModelMapper::setFirst(int first) |
|
71 | void QBarModelMapper::setFirst(int first) | |
72 | { |
|
72 | { | |
73 | Q_D(QBarModelMapper); |
|
73 | Q_D(QBarModelMapper); | |
74 | d->m_first = qMax(first, 0); |
|
74 | d->m_first = qMax(first, 0); | |
75 | d->initializeBarFromModel(); |
|
75 | d->initializeBarFromModel(); | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | int QBarModelMapper::count() const |
|
78 | int QBarModelMapper::count() const | |
79 | { |
|
79 | { | |
80 | Q_D(const QBarModelMapper); |
|
80 | Q_D(const QBarModelMapper); | |
81 | return d->m_count; |
|
81 | return d->m_count; | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void QBarModelMapper::setCount(int count) |
|
84 | void QBarModelMapper::setCount(int count) | |
85 | { |
|
85 | { | |
86 | Q_D(QBarModelMapper); |
|
86 | Q_D(QBarModelMapper); | |
87 | d->m_count = qMax(count, -1); |
|
87 | d->m_count = qMax(count, -1); | |
88 | d->initializeBarFromModel(); |
|
88 | d->initializeBarFromModel(); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | Qt::Orientation QBarModelMapper::orientation() const |
|
91 | Qt::Orientation QBarModelMapper::orientation() const | |
92 | { |
|
92 | { | |
93 | Q_D(const QBarModelMapper); |
|
93 | Q_D(const QBarModelMapper); | |
94 | return d->m_orientation; |
|
94 | return d->m_orientation; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) |
|
97 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) | |
98 | { |
|
98 | { | |
99 | Q_D(QBarModelMapper); |
|
99 | Q_D(QBarModelMapper); | |
100 | d->m_orientation = orientation; |
|
100 | d->m_orientation = orientation; | |
101 | d->initializeBarFromModel(); |
|
101 | d->initializeBarFromModel(); | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | int QBarModelMapper::firstBarSection() const |
|
104 | int QBarModelMapper::firstBarSetSection() const | |
105 | { |
|
105 | { | |
106 | Q_D(const QBarModelMapper); |
|
106 | Q_D(const QBarModelMapper); | |
107 | return d->m_firstBarSection; |
|
107 | return d->m_firstBarSetSection; | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | void QBarModelMapper::setFirstBarSection(int firstBarSection) |
|
110 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) | |
111 | { |
|
111 | { | |
112 | Q_D(QBarModelMapper); |
|
112 | Q_D(QBarModelMapper); | |
113 | d->m_firstBarSection = firstBarSection; |
|
113 | d->m_firstBarSetSection = firstBarSetSection; | |
114 | d->initializeBarFromModel(); |
|
114 | d->initializeBarFromModel(); | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | int QBarModelMapper::lastBarSection() const |
|
117 | int QBarModelMapper::lastBarSetSection() const | |
118 | { |
|
118 | { | |
119 | Q_D(const QBarModelMapper); |
|
119 | Q_D(const QBarModelMapper); | |
120 | return d->m_lastBarSection; |
|
120 | return d->m_lastBarSetSection; | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QBarModelMapper::setLastBarSection(int lastBarSection) |
|
123 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) | |
124 | { |
|
124 | { | |
125 | Q_D(QBarModelMapper); |
|
125 | Q_D(QBarModelMapper); | |
126 | d->m_lastBarSection = lastBarSection; |
|
126 | d->m_lastBarSetSection = lastBarSetSection; | |
127 | d->initializeBarFromModel(); |
|
127 | d->initializeBarFromModel(); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | int QBarModelMapper::categoriesSection() const |
|
130 | int QBarModelMapper::categoriesSection() const | |
131 | { |
|
131 | { | |
132 | Q_D(const QBarModelMapper); |
|
132 | Q_D(const QBarModelMapper); | |
133 | return d->m_categoriesSection; |
|
133 | return d->m_categoriesSection; | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | void QBarModelMapper::setCategoriesSection(int categoriesSection) |
|
136 | void QBarModelMapper::setCategoriesSection(int categoriesSection) | |
137 | { |
|
137 | { | |
138 | Q_D(QBarModelMapper); |
|
138 | Q_D(QBarModelMapper); | |
139 | d->m_categoriesSection = categoriesSection; |
|
139 | d->m_categoriesSection = categoriesSection; | |
140 | d->initializeBarFromModel(); |
|
140 | d->initializeBarFromModel(); | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | void QBarModelMapper::reset() |
|
143 | void QBarModelMapper::reset() | |
144 | { |
|
144 | { | |
145 | Q_D(QBarModelMapper); |
|
145 | Q_D(QBarModelMapper); | |
146 | d->m_first = 0; |
|
146 | d->m_first = 0; | |
147 | d->m_count = -1; |
|
147 | d->m_count = -1; | |
148 | d->m_orientation = Qt::Vertical; |
|
148 | d->m_orientation = Qt::Vertical; | |
149 | d->m_firstBarSection = -1; |
|
149 | d->m_firstBarSetSection = -1; | |
150 | d->m_lastBarSection = -1; |
|
150 | d->m_lastBarSetSection = -1; | |
151 | d->m_categoriesSection = -1; |
|
151 | d->m_categoriesSection = -1; | |
152 | d->initializeBarFromModel(); |
|
152 | d->initializeBarFromModel(); | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
155 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
156 |
|
156 | |||
157 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : |
|
157 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : | |
158 | m_series(0), |
|
158 | m_series(0), | |
159 | m_model(0), |
|
159 | m_model(0), | |
160 | m_first(0), |
|
160 | m_first(0), | |
161 | m_count(-1), |
|
161 | m_count(-1), | |
162 | m_orientation(Qt::Vertical), |
|
162 | m_orientation(Qt::Vertical), | |
163 | m_firstBarSection(-1), |
|
163 | m_firstBarSetSection(-1), | |
164 | m_lastBarSection(-1), |
|
164 | m_lastBarSetSection(-1), | |
165 | m_categoriesSection(-1), |
|
165 | m_categoriesSection(-1), | |
166 | m_seriesSignalsBlock(false), |
|
166 | m_seriesSignalsBlock(false), | |
167 | m_modelSignalsBlock(false), |
|
167 | m_modelSignalsBlock(false), | |
168 | q_ptr(q) |
|
168 | q_ptr(q) | |
169 | { |
|
169 | { | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | void QBarModelMapperPrivate::blockModelSignals(bool block) |
|
172 | void QBarModelMapperPrivate::blockModelSignals(bool block) | |
173 | { |
|
173 | { | |
174 | m_modelSignalsBlock = block; |
|
174 | m_modelSignalsBlock = block; | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) |
|
177 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) | |
178 | { |
|
178 | { | |
179 | m_seriesSignalsBlock = block; |
|
179 | m_seriesSignalsBlock = block; | |
180 | } |
|
180 | } | |
181 |
|
181 | |||
182 | QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) |
|
182 | QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) | |
183 | { |
|
183 | { | |
184 | if (!index.isValid()) |
|
184 | if (!index.isValid()) | |
185 | return 0; |
|
185 | return 0; | |
186 |
|
186 | |||
187 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSection && index.column() <= m_lastBarSection) { |
|
187 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { | |
188 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) |
|
188 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) | |
189 | return m_series->barSets().at(index.column() - m_firstBarSection); |
|
189 | return m_series->barSets().at(index.column() - m_firstBarSetSection); | |
190 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSection && index.row() <= m_lastBarSection) { |
|
190 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { | |
191 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
191 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) | |
192 | return m_series->barSets().at(index.row() - m_firstBarSection); |
|
192 | return m_series->barSets().at(index.row() - m_firstBarSetSection); | |
193 | } |
|
193 | } | |
194 | return 0; // This part of model has not been mapped to any slice |
|
194 | return 0; // This part of model has not been mapped to any slice | |
195 | } |
|
195 | } | |
196 |
|
196 | |||
197 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) |
|
197 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) | |
198 | { |
|
198 | { | |
199 | if (m_count != -1 && posInBar >= m_count) |
|
199 | if (m_count != -1 && posInBar >= m_count) | |
200 | return QModelIndex(); // invalid |
|
200 | return QModelIndex(); // invalid | |
201 |
|
201 | |||
202 | if (barSection < m_firstBarSection || barSection > m_lastBarSection) |
|
202 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) | |
203 | return QModelIndex(); // invalid |
|
203 | return QModelIndex(); // invalid | |
204 |
|
204 | |||
205 | if (m_orientation == Qt::Vertical) |
|
205 | if (m_orientation == Qt::Vertical) | |
206 | return m_model->index(posInBar + m_first, barSection); |
|
206 | return m_model->index(posInBar + m_first, barSection); | |
207 | else |
|
207 | else | |
208 | return m_model->index(barSection, posInBar + m_first); |
|
208 | return m_model->index(barSection, posInBar + m_first); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | QModelIndex QBarModelMapperPrivate::categoriesModelIndex(int posInCategories) |
|
211 | QModelIndex QBarModelMapperPrivate::categoriesModelIndex(int posInCategories) | |
212 | { |
|
212 | { | |
213 | if (m_count != -1 && posInCategories >= m_count) |
|
213 | if (m_count != -1 && posInCategories >= m_count) | |
214 | return QModelIndex(); // invalid |
|
214 | return QModelIndex(); // invalid | |
215 |
|
215 | |||
216 | if (m_orientation == Qt::Vertical) |
|
216 | if (m_orientation == Qt::Vertical) | |
217 | return m_model->index(posInCategories + m_first, m_categoriesSection); |
|
217 | return m_model->index(posInCategories + m_first, m_categoriesSection); | |
218 | else |
|
218 | else | |
219 | return m_model->index(m_categoriesSection, posInCategories + m_first); |
|
219 | return m_model->index(m_categoriesSection, posInCategories + m_first); | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
222 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
223 | { |
|
223 | { | |
224 | Q_UNUSED(topLeft) |
|
224 | Q_UNUSED(topLeft) | |
225 | Q_UNUSED(bottomRight) |
|
225 | Q_UNUSED(bottomRight) | |
226 |
|
226 | |||
227 | if (m_model == 0 || m_series == 0) |
|
227 | if (m_model == 0 || m_series == 0) | |
228 | return; |
|
228 | return; | |
229 |
|
229 | |||
230 | if (m_modelSignalsBlock) |
|
230 | if (m_modelSignalsBlock) | |
231 | return; |
|
231 | return; | |
232 |
|
232 | |||
233 | blockSeriesSignals(); |
|
233 | blockSeriesSignals(); | |
234 | QModelIndex index; |
|
234 | QModelIndex index; | |
235 | // QPointF oldPoint; |
|
235 | // QPointF oldPoint; | |
236 | // QPointF newPoint; |
|
236 | // QPointF newPoint; | |
237 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
237 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
238 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
238 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
239 | index = topLeft.sibling(row, column); |
|
239 | index = topLeft.sibling(row, column); | |
240 | QBarSet* bar = barSet(index); |
|
240 | QBarSet* bar = barSet(index); | |
241 | if (bar) { |
|
241 | if (bar) { | |
242 | if (m_orientation == Qt::Vertical) |
|
242 | if (m_orientation == Qt::Vertical) | |
243 | bar->replace(row - m_first, m_model->data(index).toReal()); |
|
243 | bar->replace(row - m_first, m_model->data(index).toReal()); | |
244 | else |
|
244 | else | |
245 | bar->replace(column - m_first, m_model->data(index).toReal()); |
|
245 | bar->replace(column - m_first, m_model->data(index).toReal()); | |
246 | } |
|
246 | } | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 | blockSeriesSignals(false); |
|
249 | blockSeriesSignals(false); | |
250 | } |
|
250 | } | |
251 |
|
251 | |||
252 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
252 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
253 | { |
|
253 | { | |
254 | Q_UNUSED(parent); |
|
254 | Q_UNUSED(parent); | |
255 | Q_UNUSED(end) |
|
255 | Q_UNUSED(end) | |
256 | if (m_modelSignalsBlock) |
|
256 | if (m_modelSignalsBlock) | |
257 | return; |
|
257 | return; | |
258 |
|
258 | |||
259 | blockSeriesSignals(); |
|
259 | blockSeriesSignals(); | |
260 | if (m_orientation == Qt::Vertical) |
|
260 | if (m_orientation == Qt::Vertical) | |
261 | // insertData(start, end); |
|
261 | // insertData(start, end); | |
262 | initializeBarFromModel(); |
|
262 | initializeBarFromModel(); | |
263 | else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize |
|
263 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize | |
264 | initializeBarFromModel(); |
|
264 | initializeBarFromModel(); | |
265 | blockSeriesSignals(false); |
|
265 | blockSeriesSignals(false); | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
268 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
269 | { |
|
269 | { | |
270 | Q_UNUSED(parent); |
|
270 | Q_UNUSED(parent); | |
271 | Q_UNUSED(end) |
|
271 | Q_UNUSED(end) | |
272 | if (m_modelSignalsBlock) |
|
272 | if (m_modelSignalsBlock) | |
273 | return; |
|
273 | return; | |
274 |
|
274 | |||
275 | blockSeriesSignals(); |
|
275 | blockSeriesSignals(); | |
276 | if (m_orientation == Qt::Vertical) |
|
276 | if (m_orientation == Qt::Vertical) | |
277 | // removeData(start, end); |
|
277 | // removeData(start, end); | |
278 | initializeBarFromModel(); |
|
278 | initializeBarFromModel(); | |
279 | else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize |
|
279 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize | |
280 | initializeBarFromModel(); |
|
280 | initializeBarFromModel(); | |
281 | blockSeriesSignals(false); |
|
281 | blockSeriesSignals(false); | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
284 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
285 | { |
|
285 | { | |
286 | Q_UNUSED(parent); |
|
286 | Q_UNUSED(parent); | |
287 | Q_UNUSED(end) |
|
287 | Q_UNUSED(end) | |
288 | if (m_modelSignalsBlock) |
|
288 | if (m_modelSignalsBlock) | |
289 | return; |
|
289 | return; | |
290 |
|
290 | |||
291 | blockSeriesSignals(); |
|
291 | blockSeriesSignals(); | |
292 | if (m_orientation == Qt::Horizontal) |
|
292 | if (m_orientation == Qt::Horizontal) | |
293 | // insertData(start, end); |
|
293 | // insertData(start, end); | |
294 | initializeBarFromModel(); |
|
294 | initializeBarFromModel(); | |
295 | else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize |
|
295 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize | |
296 | initializeBarFromModel(); |
|
296 | initializeBarFromModel(); | |
297 | blockSeriesSignals(false); |
|
297 | blockSeriesSignals(false); | |
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
300 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
301 | { |
|
301 | { | |
302 | Q_UNUSED(parent); |
|
302 | Q_UNUSED(parent); | |
303 | Q_UNUSED(end) |
|
303 | Q_UNUSED(end) | |
304 | if (m_modelSignalsBlock) |
|
304 | if (m_modelSignalsBlock) | |
305 | return; |
|
305 | return; | |
306 |
|
306 | |||
307 | blockSeriesSignals(); |
|
307 | blockSeriesSignals(); | |
308 | if (m_orientation == Qt::Horizontal) |
|
308 | if (m_orientation == Qt::Horizontal) | |
309 | // removeData(start, end); |
|
309 | // removeData(start, end); | |
310 | initializeBarFromModel(); |
|
310 | initializeBarFromModel(); | |
311 | else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize |
|
311 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize | |
312 | initializeBarFromModel(); |
|
312 | initializeBarFromModel(); | |
313 | blockSeriesSignals(false); |
|
313 | blockSeriesSignals(false); | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | void QBarModelMapperPrivate::insertData(int start, int end) |
|
316 | void QBarModelMapperPrivate::insertData(int start, int end) | |
317 | { |
|
317 | { | |
318 | Q_UNUSED(end) |
|
318 | Q_UNUSED(end) | |
319 | if (m_model == 0 || m_series == 0) |
|
319 | if (m_model == 0 || m_series == 0) | |
320 | return; |
|
320 | return; | |
321 |
|
321 | |||
322 | if (m_count != -1 && start >= m_first + m_count) { |
|
322 | if (m_count != -1 && start >= m_first + m_count) { | |
323 | return; |
|
323 | return; | |
324 | } /*else { |
|
324 | } /*else { | |
325 | int addedCount = end - start + 1; |
|
325 | int addedCount = end - start + 1; | |
326 | if (m_count != -1 && addedCount > m_count) |
|
326 | if (m_count != -1 && addedCount > m_count) | |
327 | addedCount = m_count; |
|
327 | addedCount = m_count; | |
328 | int first = qMax(start, m_first); |
|
328 | int first = qMax(start, m_first); | |
329 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); |
|
329 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
330 | for (int k = 0; k < m_series->barSets().count(); k++) { |
|
330 | for (int k = 0; k < m_series->barSets().count(); k++) { | |
331 | for (int i = first; i <= last; i++) { |
|
331 | for (int i = first; i <= last; i++) { | |
332 | QBar point; |
|
332 | QBar point; | |
333 | point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble()); |
|
333 | point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble()); | |
334 | point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); |
|
334 | point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); | |
335 | m_series->insert(i - m_first, point); |
|
335 | m_series->insert(i - m_first, point); | |
336 | } |
|
336 | } | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | // remove excess of slices (abouve m_count) |
|
339 | // remove excess of slices (abouve m_count) | |
340 | if (m_count != -1 && m_series->points().size() > m_count) |
|
340 | if (m_count != -1 && m_series->points().size() > m_count) | |
341 | for (int i = m_series->points().size() - 1; i >= m_count; i--) { |
|
341 | for (int i = m_series->points().size() - 1; i >= m_count; i--) { | |
342 | m_series->remove(m_series->points().at(i)); |
|
342 | m_series->remove(m_series->points().at(i)); | |
343 | } |
|
343 | } | |
344 | }*/ |
|
344 | }*/ | |
345 | } |
|
345 | } | |
346 |
|
346 | |||
347 | void QBarModelMapperPrivate::removeData(int start, int end) |
|
347 | void QBarModelMapperPrivate::removeData(int start, int end) | |
348 | { |
|
348 | { | |
349 | Q_UNUSED(end) |
|
349 | Q_UNUSED(end) | |
350 | if (m_model == 0 || m_series == 0) |
|
350 | if (m_model == 0 || m_series == 0) | |
351 | return; |
|
351 | return; | |
352 |
|
352 | |||
353 | // int removedCount = end - start + 1; |
|
353 | // int removedCount = end - start + 1; | |
354 | if (m_count != -1 && start >= m_first + m_count) { |
|
354 | if (m_count != -1 && start >= m_first + m_count) { | |
355 | return; |
|
355 | return; | |
356 | } /*else { |
|
356 | } /*else { | |
357 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed |
|
357 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed | |
358 | int first = qMax(start, m_first); // get the index of the first item that will be removed. |
|
358 | int first = qMax(start, m_first); // get the index of the first item that will be removed. | |
359 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. |
|
359 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. | |
360 | for (int i = last; i >= first; i--) { |
|
360 | for (int i = last; i >= first; i--) { | |
361 | m_series->remove(m_series->points().at(i - m_first)); |
|
361 | m_series->remove(m_series->points().at(i - m_first)); | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | if (m_count != -1) { |
|
364 | if (m_count != -1) { | |
365 | int itemsAvailable; // check how many are available to be added |
|
365 | int itemsAvailable; // check how many are available to be added | |
366 | if (m_orientation == Qt::Vertical) |
|
366 | if (m_orientation == Qt::Vertical) | |
367 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); |
|
367 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); | |
368 | else |
|
368 | else | |
369 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); |
|
369 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); | |
370 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. |
|
370 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. | |
371 | int currentSize = m_series->count(); |
|
371 | int currentSize = m_series->count(); | |
372 | if (toBeAdded > 0) |
|
372 | if (toBeAdded > 0) | |
373 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { |
|
373 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { | |
374 | QPointF point; |
|
374 | QPointF point; | |
375 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); |
|
375 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); | |
376 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); |
|
376 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); | |
377 | m_series->insert(i, point); |
|
377 | m_series->insert(i, point); | |
378 | } |
|
378 | } | |
379 | } |
|
379 | } | |
380 | }*/ |
|
380 | }*/ | |
381 | } |
|
381 | } | |
382 |
|
382 | |||
383 | void QBarModelMapperPrivate::initializeBarFromModel() |
|
383 | void QBarModelMapperPrivate::initializeBarFromModel() | |
384 | { |
|
384 | { | |
385 | if (m_model == 0 || m_series == 0) |
|
385 | if (m_model == 0 || m_series == 0) | |
386 | return; |
|
386 | return; | |
387 |
|
387 | |||
388 | blockSeriesSignals(); |
|
388 | blockSeriesSignals(); | |
389 | // clear current content |
|
389 | // clear current content | |
390 | m_series->clear(); |
|
390 | m_series->clear(); | |
391 |
|
391 | |||
392 | // create the initial bar sets |
|
392 | // create the initial bar sets | |
393 | for (int i = m_firstBarSection; i <= m_lastBarSection; i++) { |
|
393 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { | |
394 | int posInBar = 0; |
|
394 | int posInBar = 0; | |
395 | QModelIndex barIndex = barModelIndex(i, posInBar); |
|
395 | QModelIndex barIndex = barModelIndex(i, posInBar); | |
396 | QBarSet *barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal).toString()); |
|
396 | QBarSet *barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal).toString()); | |
397 | // QModelIndex yIndex = yModelIndex(pointPos); |
|
397 | // QModelIndex yIndex = yModelIndex(pointPos); | |
398 | while (barIndex.isValid()) { |
|
398 | while (barIndex.isValid()) { | |
399 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); |
|
399 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); | |
400 | posInBar++; |
|
400 | posInBar++; | |
401 | barIndex = barModelIndex(i, posInBar); |
|
401 | barIndex = barModelIndex(i, posInBar); | |
402 | } |
|
402 | } | |
403 | m_series->append(barSet); |
|
403 | m_series->append(barSet); | |
404 | } |
|
404 | } | |
405 |
|
405 | |||
406 | if (m_categoriesSection != -1) { |
|
406 | if (m_categoriesSection != -1) { | |
407 | int posInCategories = 0; |
|
407 | int posInCategories = 0; | |
408 | QStringList categories; |
|
408 | QStringList categories; | |
409 | QModelIndex categoriesIndex = categoriesModelIndex(posInCategories); |
|
409 | QModelIndex categoriesIndex = categoriesModelIndex(posInCategories); | |
410 | while (categoriesIndex.isValid()) { |
|
410 | while (categoriesIndex.isValid()) { | |
411 | categories.append(m_model->data(categoriesIndex, Qt::DisplayRole).toString()); |
|
411 | categories.append(m_model->data(categoriesIndex, Qt::DisplayRole).toString()); | |
412 | posInCategories++; |
|
412 | posInCategories++; | |
413 | categoriesIndex = categoriesModelIndex(posInCategories); |
|
413 | categoriesIndex = categoriesModelIndex(posInCategories); | |
414 | } |
|
414 | } | |
415 | m_series->setCategories(categories); |
|
415 | m_series->setCategories(categories); | |
416 | } |
|
416 | } | |
417 | blockSeriesSignals(false); |
|
417 | blockSeriesSignals(false); | |
418 | } |
|
418 | } | |
419 |
|
419 | |||
420 | #include "moc_qbarmodelmapper.cpp" |
|
420 | #include "moc_qbarmodelmapper.cpp" | |
421 | #include "moc_qbarmodelmapper_p.cpp" |
|
421 | #include "moc_qbarmodelmapper_p.cpp" | |
422 |
|
422 | |||
423 | QTCOMMERCIALCHART_END_NAMESPACE |
|
423 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,64 +1,64 | |||||
1 | #ifndef QBARMODELMAPPER_H |
|
1 | #ifndef QBARMODELMAPPER_H | |
2 | #define QBARMODELMAPPER_H |
|
2 | #define QBARMODELMAPPER_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 |
|
6 | |||
7 | class QAbstractItemModel; |
|
7 | class QAbstractItemModel; | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
10 | |||
11 | class QBarModelMapperPrivate; |
|
11 | class QBarModelMapperPrivate; | |
12 | class QBarSeries; |
|
12 | class QBarSeries; | |
13 |
|
13 | |||
14 | class QTCOMMERCIALCHART_EXPORT QBarModelMapper : public QObject |
|
14 | class QTCOMMERCIALCHART_EXPORT QBarModelMapper : public QObject | |
15 | { |
|
15 | { | |
16 | Q_OBJECT |
|
16 | Q_OBJECT | |
17 | Q_PROPERTY(QBarSeries *series READ series WRITE setSeries) |
|
17 | Q_PROPERTY(QBarSeries *series READ series WRITE setSeries) | |
18 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel) |
|
18 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel) | |
19 | Q_PROPERTY(int first READ first WRITE setFirst) |
|
19 | Q_PROPERTY(int first READ first WRITE setFirst) | |
20 | Q_PROPERTY(int count READ count WRITE setCount) |
|
20 | Q_PROPERTY(int count READ count WRITE setCount) | |
21 | Q_ENUMS(Qt::Orientation) |
|
21 | Q_ENUMS(Qt::Orientation) | |
22 |
|
22 | |||
23 | protected: |
|
23 | protected: | |
24 | explicit QBarModelMapper(QObject *parent = 0); |
|
24 | explicit QBarModelMapper(QObject *parent = 0); | |
25 |
|
25 | |||
26 | public: |
|
26 | public: | |
27 | QAbstractItemModel* model() const; |
|
27 | QAbstractItemModel* model() const; | |
28 | void setModel(QAbstractItemModel *model); |
|
28 | void setModel(QAbstractItemModel *model); | |
29 |
|
29 | |||
30 | QBarSeries* series() const; |
|
30 | QBarSeries* series() const; | |
31 | void setSeries(QBarSeries *series); |
|
31 | void setSeries(QBarSeries *series); | |
32 |
|
32 | |||
33 | int first() const; |
|
33 | int first() const; | |
34 | void setFirst(int first); |
|
34 | void setFirst(int first); | |
35 |
|
35 | |||
36 | int count() const; |
|
36 | int count() const; | |
37 | void setCount(int count); |
|
37 | void setCount(int count); | |
38 |
|
38 | |||
39 | int firstBarSection() const; |
|
39 | int firstBarSetSection() const; | |
40 | void setFirstBarSection(int firstBarSection); |
|
40 | void setFirstBarSetSection(int firstBarSetSection); | |
41 |
|
41 | |||
42 | int lastBarSection() const; |
|
42 | int lastBarSetSection() const; | |
43 | void setLastBarSection(int lastBarSection); |
|
43 | void setLastBarSetSection(int lastBarSetSection); | |
44 |
|
44 | |||
45 | int categoriesSection() const; |
|
45 | int categoriesSection() const; | |
46 | void setCategoriesSection(int categoriesSection); |
|
46 | void setCategoriesSection(int categoriesSection); | |
47 |
|
47 | |||
48 | protected: |
|
48 | protected: | |
49 | Qt::Orientation orientation() const; |
|
49 | Qt::Orientation orientation() const; | |
50 | void setOrientation(Qt::Orientation orientation); |
|
50 | void setOrientation(Qt::Orientation orientation); | |
51 |
|
51 | |||
52 | void reset(); |
|
52 | void reset(); | |
53 |
|
53 | |||
54 | Q_SIGNALS: |
|
54 | Q_SIGNALS: | |
55 | void updated(); |
|
55 | void updated(); | |
56 |
|
56 | |||
57 | protected: |
|
57 | protected: | |
58 | QBarModelMapperPrivate * const d_ptr; |
|
58 | QBarModelMapperPrivate * const d_ptr; | |
59 | Q_DECLARE_PRIVATE(QBarModelMapper) |
|
59 | Q_DECLARE_PRIVATE(QBarModelMapper) | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | QTCOMMERCIALCHART_END_NAMESPACE |
|
62 | QTCOMMERCIALCHART_END_NAMESPACE | |
63 |
|
63 | |||
64 | #endif // QBARMODELMAPPER_H |
|
64 | #endif // QBARMODELMAPPER_H |
@@ -1,63 +1,63 | |||||
1 | #ifndef QBARMODELMAPPER_P_H |
|
1 | #ifndef QBARMODELMAPPER_P_H | |
2 | #define QBARMODELMAPPER_P_H |
|
2 | #define QBARMODELMAPPER_P_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include "qbarmodelmapper.h" |
|
6 | #include "qbarmodelmapper.h" | |
7 |
|
7 | |||
8 | class QModelIndex; |
|
8 | class QModelIndex; | |
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | class QBarSet; |
|
12 | class QBarSet; | |
13 |
|
13 | |||
14 | class QBarModelMapperPrivate : public QObject |
|
14 | class QBarModelMapperPrivate : public QObject | |
15 | { |
|
15 | { | |
16 | Q_OBJECT |
|
16 | Q_OBJECT | |
17 | public: |
|
17 | public: | |
18 | explicit QBarModelMapperPrivate(QBarModelMapper *q); |
|
18 | explicit QBarModelMapperPrivate(QBarModelMapper *q); | |
19 |
|
19 | |||
20 | public Q_SLOTS: |
|
20 | public Q_SLOTS: | |
21 | // for the model |
|
21 | // for the model | |
22 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
22 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
23 | void modelRowsAdded(QModelIndex parent, int start, int end); |
|
23 | void modelRowsAdded(QModelIndex parent, int start, int end); | |
24 | void modelRowsRemoved(QModelIndex parent, int start, int end); |
|
24 | void modelRowsRemoved(QModelIndex parent, int start, int end); | |
25 | void modelColumnsAdded(QModelIndex parent, int start, int end); |
|
25 | void modelColumnsAdded(QModelIndex parent, int start, int end); | |
26 | void modelColumnsRemoved(QModelIndex parent, int start, int end); |
|
26 | void modelColumnsRemoved(QModelIndex parent, int start, int end); | |
27 |
|
27 | |||
28 | // // for the series |
|
28 | // // for the series | |
29 | // void handlePointAdded(int pointPos); |
|
29 | // void handlePointAdded(int pointPos); | |
30 | // void handlePointRemoved(int pointPos); |
|
30 | // void handlePointRemoved(int pointPos); | |
31 | // void handlePointReplaced(int pointPos); |
|
31 | // void handlePointReplaced(int pointPos); | |
32 |
|
32 | |||
33 | void initializeBarFromModel(); |
|
33 | void initializeBarFromModel(); | |
34 |
|
34 | |||
35 | private: |
|
35 | private: | |
36 | QBarSet* barSet(QModelIndex index); |
|
36 | QBarSet* barSet(QModelIndex index); | |
37 | QModelIndex barModelIndex(int barSection, int posInBar); |
|
37 | QModelIndex barModelIndex(int barSection, int posInBar); | |
38 | QModelIndex categoriesModelIndex(int posInCategories); |
|
38 | QModelIndex categoriesModelIndex(int posInCategories); | |
39 | void insertData(int start, int end); |
|
39 | void insertData(int start, int end); | |
40 | void removeData(int start, int end); |
|
40 | void removeData(int start, int end); | |
41 | void blockModelSignals(bool block = true); |
|
41 | void blockModelSignals(bool block = true); | |
42 | void blockSeriesSignals(bool block = true); |
|
42 | void blockSeriesSignals(bool block = true); | |
43 |
|
43 | |||
44 | private: |
|
44 | private: | |
45 | QBarSeries *m_series; |
|
45 | QBarSeries *m_series; | |
46 | QAbstractItemModel *m_model; |
|
46 | QAbstractItemModel *m_model; | |
47 | int m_first; |
|
47 | int m_first; | |
48 | int m_count; |
|
48 | int m_count; | |
49 | Qt::Orientation m_orientation; |
|
49 | Qt::Orientation m_orientation; | |
50 | int m_firstBarSection; |
|
50 | int m_firstBarSetSection; | |
51 | int m_lastBarSection; |
|
51 | int m_lastBarSetSection; | |
52 | int m_categoriesSection; |
|
52 | int m_categoriesSection; | |
53 | bool m_seriesSignalsBlock; |
|
53 | bool m_seriesSignalsBlock; | |
54 | bool m_modelSignalsBlock; |
|
54 | bool m_modelSignalsBlock; | |
55 |
|
55 | |||
56 | private: |
|
56 | private: | |
57 | QBarModelMapper *q_ptr; |
|
57 | QBarModelMapper *q_ptr; | |
58 | Q_DECLARE_PUBLIC(QBarModelMapper) |
|
58 | Q_DECLARE_PUBLIC(QBarModelMapper) | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE | |
62 |
|
62 | |||
63 | #endif // QBARMODELMAPPER_P_H |
|
63 | #endif // QBARMODELMAPPER_P_H |
@@ -1,43 +1,43 | |||||
1 | #include "qhbarmodelmapper.h" |
|
1 | #include "qhbarmodelmapper.h" | |
2 |
|
2 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
4 | |||
5 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : |
|
5 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : | |
6 | QBarModelMapper(parent) |
|
6 | QBarModelMapper(parent) | |
7 | { |
|
7 | { | |
8 | QBarModelMapper::setOrientation(Qt::Horizontal); |
|
8 | QBarModelMapper::setOrientation(Qt::Horizontal); | |
9 | } |
|
9 | } | |
10 |
|
10 | |||
11 | int QHBarModelMapper::firstBarRow() const |
|
11 | int QHBarModelMapper::firstBarSetRow() const | |
12 | { |
|
12 | { | |
13 | return QBarModelMapper::firstBarSection(); |
|
13 | return QBarModelMapper::firstBarSetSection(); | |
14 | } |
|
14 | } | |
15 |
|
15 | |||
16 | void QHBarModelMapper::setFirstBarRow(int firstBarRow) |
|
16 | void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow) | |
17 | { |
|
17 | { | |
18 | return QBarModelMapper::setFirstBarSection(firstBarRow); |
|
18 | return QBarModelMapper::setFirstBarSetSection(firstBarSetRow); | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | int QHBarModelMapper::lastBarRow() const |
|
21 | int QHBarModelMapper::lastBarSetRow() const | |
22 | { |
|
22 | { | |
23 | return QBarModelMapper::lastBarSection(); |
|
23 | return QBarModelMapper::lastBarSetSection(); | |
24 | } |
|
24 | } | |
25 |
|
25 | |||
26 | void QHBarModelMapper::setLastBarRow(int lastBarRow) |
|
26 | void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow) | |
27 | { |
|
27 | { | |
28 | return QBarModelMapper::setLastBarSection(lastBarRow); |
|
28 | return QBarModelMapper::setLastBarSetSection(lastBarSetRow); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | int QHBarModelMapper::categoriesRow() const |
|
31 | int QHBarModelMapper::categoriesRow() const | |
32 | { |
|
32 | { | |
33 | return QBarModelMapper::categoriesSection(); |
|
33 | return QBarModelMapper::categoriesSection(); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void QHBarModelMapper::setCategoriesRow(int categoriesRow) |
|
36 | void QHBarModelMapper::setCategoriesRow(int categoriesRow) | |
37 | { |
|
37 | { | |
38 | return QBarModelMapper::setCategoriesSection(categoriesRow); |
|
38 | return QBarModelMapper::setCategoriesSection(categoriesRow); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | #include "moc_qhbarmodelmapper.cpp" |
|
41 | #include "moc_qhbarmodelmapper.cpp" | |
42 |
|
42 | |||
43 | QTCOMMERCIALCHART_END_NAMESPACE |
|
43 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,30 +1,30 | |||||
1 | #ifndef QHBARMODELMAPPER_H |
|
1 | #ifndef QHBARMODELMAPPER_H | |
2 | #define QHBARMODELMAPPER_H |
|
2 | #define QHBARMODELMAPPER_H | |
3 |
|
3 | |||
4 | #include <QBarModelMapper> |
|
4 | #include <QBarModelMapper> | |
5 |
|
5 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
7 | |||
8 | class QTCOMMERCIALCHART_EXPORT QHBarModelMapper : public QBarModelMapper |
|
8 | class QTCOMMERCIALCHART_EXPORT QHBarModelMapper : public QBarModelMapper | |
9 | { |
|
9 | { | |
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 | Q_PROPERTY(int firstBarRow READ firstBarRow WRITE setFirstBarRow) |
|
11 | Q_PROPERTY(int firstBarSetRow READ firstBarSetRow WRITE setFirstBarSetRow) | |
12 | Q_PROPERTY(int lastBarRow READ lastBarRow WRITE setLastBarRow) |
|
12 | Q_PROPERTY(int lastBarSetRow READ lastBarSetRow WRITE setLastBarSetRow) | |
13 |
|
13 | |||
14 | public: |
|
14 | public: | |
15 | explicit QHBarModelMapper(QObject *parent = 0); |
|
15 | explicit QHBarModelMapper(QObject *parent = 0); | |
16 |
|
16 | |||
17 | int firstBarRow() const; |
|
17 | int firstBarSetRow() const; | |
18 | void setFirstBarRow(int firstBarRow); |
|
18 | void setFirstBarSetRow(int firstBarSetRow); | |
19 |
|
19 | |||
20 | int lastBarRow() const; |
|
20 | int lastBarSetRow() const; | |
21 | void setLastBarRow(int lastBarRow); |
|
21 | void setLastBarSetRow(int lastBarSetRow); | |
22 |
|
22 | |||
23 | int categoriesRow() const; |
|
23 | int categoriesRow() const; | |
24 | void setCategoriesRow(int categoriesRow); |
|
24 | void setCategoriesRow(int categoriesRow); | |
25 |
|
25 | |||
26 | }; |
|
26 | }; | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_END_NAMESPACE |
|
28 | QTCOMMERCIALCHART_END_NAMESPACE | |
29 |
|
29 | |||
30 | #endif // QHBARMODELMAPPER_H |
|
30 | #endif // QHBARMODELMAPPER_H |
@@ -1,43 +1,43 | |||||
1 | #include "qvbarmodelmapper.h" |
|
1 | #include "qvbarmodelmapper.h" | |
2 |
|
2 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
4 | |||
5 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : |
|
5 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : | |
6 | QBarModelMapper(parent) |
|
6 | QBarModelMapper(parent) | |
7 | { |
|
7 | { | |
8 | QBarModelMapper::setOrientation(Qt::Vertical); |
|
8 | QBarModelMapper::setOrientation(Qt::Vertical); | |
9 | } |
|
9 | } | |
10 |
|
10 | |||
11 | int QVBarModelMapper::firstBarColumn() const |
|
11 | int QVBarModelMapper::firstBarSetColumn() const | |
12 | { |
|
12 | { | |
13 | return QBarModelMapper::firstBarSection(); |
|
13 | return QBarModelMapper::firstBarSetSection(); | |
14 | } |
|
14 | } | |
15 |
|
15 | |||
16 | void QVBarModelMapper::setFirstBarColumn(int firstBarColumn) |
|
16 | void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn) | |
17 | { |
|
17 | { | |
18 | return QBarModelMapper::setFirstBarSection(firstBarColumn); |
|
18 | return QBarModelMapper::setFirstBarSetSection(firstBarSetColumn); | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | int QVBarModelMapper::lastBarColumn() const |
|
21 | int QVBarModelMapper::lastBarSetColumn() const | |
22 | { |
|
22 | { | |
23 | return QBarModelMapper::lastBarSection(); |
|
23 | return QBarModelMapper::lastBarSetSection(); | |
24 | } |
|
24 | } | |
25 |
|
25 | |||
26 | void QVBarModelMapper::setLastBarColumn(int lastBarColumn) |
|
26 | void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn) | |
27 | { |
|
27 | { | |
28 | return QBarModelMapper::setLastBarSection(lastBarColumn); |
|
28 | return QBarModelMapper::setLastBarSetSection(lastBarSetColumn); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | int QVBarModelMapper::categoriesColumn() const |
|
31 | int QVBarModelMapper::categoriesColumn() const | |
32 | { |
|
32 | { | |
33 | return QBarModelMapper::categoriesSection(); |
|
33 | return QBarModelMapper::categoriesSection(); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void QVBarModelMapper::setCategoriesColumn(int categoriesColumn) |
|
36 | void QVBarModelMapper::setCategoriesColumn(int categoriesColumn) | |
37 | { |
|
37 | { | |
38 | return QBarModelMapper::setCategoriesSection(categoriesColumn); |
|
38 | return QBarModelMapper::setCategoriesSection(categoriesColumn); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | #include "moc_qvbarmodelmapper.cpp" |
|
41 | #include "moc_qvbarmodelmapper.cpp" | |
42 |
|
42 | |||
43 | QTCOMMERCIALCHART_END_NAMESPACE |
|
43 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,30 +1,30 | |||||
1 | #ifndef QVBARMODELMAPPER_H |
|
1 | #ifndef QVBARMODELMAPPER_H | |
2 | #define QVBARMODELMAPPER_H |
|
2 | #define QVBARMODELMAPPER_H | |
3 |
|
3 | |||
4 | #include <QBarModelMapper> |
|
4 | #include <QBarModelMapper> | |
5 |
|
5 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
7 | |||
8 | class QTCOMMERCIALCHART_EXPORT QVBarModelMapper : public QBarModelMapper |
|
8 | class QTCOMMERCIALCHART_EXPORT QVBarModelMapper : public QBarModelMapper | |
9 | { |
|
9 | { | |
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 | Q_PROPERTY(int firstBarColumn READ firstBarColumn WRITE setFirstBarColumn) |
|
11 | Q_PROPERTY(int firstBarSetColumn READ firstBarSetColumn WRITE setFirstBarSetColumn) | |
12 | Q_PROPERTY(int lastBarColumn READ lastBarColumn WRITE setLastBarColumn) |
|
12 | Q_PROPERTY(int lastBarSetColumn READ lastBarSetColumn WRITE setLastBarSetColumn) | |
13 |
|
13 | |||
14 | public: |
|
14 | public: | |
15 | explicit QVBarModelMapper(QObject *parent = 0); |
|
15 | explicit QVBarModelMapper(QObject *parent = 0); | |
16 |
|
16 | |||
17 | int firstBarColumn() const; |
|
17 | int firstBarSetColumn() const; | |
18 | void setFirstBarColumn(int firstBarColumn); |
|
18 | void setFirstBarSetColumn(int firstBarSetColumn); | |
19 |
|
19 | |||
20 | int lastBarColumn() const; |
|
20 | int lastBarSetColumn() const; | |
21 | void setLastBarColumn(int lastBarColumn); |
|
21 | void setLastBarSetColumn(int lastBarSetColumn); | |
22 |
|
22 | |||
23 | int categoriesColumn() const; |
|
23 | int categoriesColumn() const; | |
24 | void setCategoriesColumn(int categoriesColumn); |
|
24 | void setCategoriesColumn(int categoriesColumn); | |
25 |
|
25 | |||
26 | }; |
|
26 | }; | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_END_NAMESPACE |
|
28 | QTCOMMERCIALCHART_END_NAMESPACE | |
29 |
|
29 | |||
30 | #endif // QVBARMODELMAPPER_H |
|
30 | #endif // QVBARMODELMAPPER_H |
General Comments 0
You need to be logged in to leave comments.
Login now