@@ -1,568 +1,561 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qbarmodelmapper.h" |
|
21 | #include "qbarmodelmapper.h" | |
22 | #include "qbarmodelmapper_p.h" |
|
22 | #include "qbarmodelmapper_p.h" | |
23 | #include "qabstractbarseries.h" |
|
23 | #include "qabstractbarseries.h" | |
24 | #include "qbarset.h" |
|
24 | #include "qbarset.h" | |
25 | #include "qchart.h" |
|
25 | #include "qchart.h" | |
26 | #include <QAbstractItemModel> |
|
26 | #include <QAbstractItemModel> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | QBarModelMapper::QBarModelMapper(QObject *parent) : |
|
30 | QBarModelMapper::QBarModelMapper(QObject *parent) : | |
31 | QObject(parent), |
|
31 | QObject(parent), | |
32 | d_ptr(new QBarModelMapperPrivate(this)) |
|
32 | d_ptr(new QBarModelMapperPrivate(this)) | |
33 | { |
|
33 | { | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | QAbstractItemModel *QBarModelMapper::model() const |
|
36 | QAbstractItemModel *QBarModelMapper::model() const | |
37 | { |
|
37 | { | |
38 | Q_D(const QBarModelMapper); |
|
38 | Q_D(const QBarModelMapper); | |
39 | return d->m_model; |
|
39 | return d->m_model; | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void QBarModelMapper::setModel(QAbstractItemModel *model) |
|
42 | void QBarModelMapper::setModel(QAbstractItemModel *model) | |
43 | { |
|
43 | { | |
44 | if (model == 0) |
|
44 | if (model == 0) | |
45 | return; |
|
45 | return; | |
46 |
|
46 | |||
47 | Q_D(QBarModelMapper); |
|
47 | Q_D(QBarModelMapper); | |
48 | if (d->m_model) |
|
48 | if (d->m_model) | |
49 | disconnect(d->m_model, 0, d, 0); |
|
49 | disconnect(d->m_model, 0, d, 0); | |
50 |
|
50 | |||
51 | d->m_model = model; |
|
51 | d->m_model = model; | |
52 | d->initializeBarFromModel(); |
|
52 | d->initializeBarFromModel(); | |
53 | // connect signals from the model |
|
53 | // connect signals from the model | |
54 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
54 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
55 | connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); |
|
55 | connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); | |
56 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
56 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
57 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
57 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
58 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
58 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
59 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
59 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
60 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); |
|
60 | connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | QAbstractBarSeries *QBarModelMapper::series() const |
|
63 | QAbstractBarSeries *QBarModelMapper::series() const | |
64 | { |
|
64 | { | |
65 | Q_D(const QBarModelMapper); |
|
65 | Q_D(const QBarModelMapper); | |
66 | return d->m_series; |
|
66 | return d->m_series; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void QBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
69 | void QBarModelMapper::setSeries(QAbstractBarSeries *series) | |
70 | { |
|
70 | { | |
71 | Q_D(QBarModelMapper); |
|
71 | Q_D(QBarModelMapper); | |
72 | if (d->m_series) |
|
72 | if (d->m_series) | |
73 | disconnect(d->m_series, 0, d, 0); |
|
73 | disconnect(d->m_series, 0, d, 0); | |
74 |
|
74 | |||
75 | if (series == 0) |
|
75 | if (series == 0) | |
76 | return; |
|
76 | return; | |
77 |
|
77 | |||
78 | d->m_series = series; |
|
78 | d->m_series = series; | |
79 | d->initializeBarFromModel(); |
|
79 | d->initializeBarFromModel(); | |
80 | // connect the signals from the series |
|
80 | // connect the signals from the series | |
81 | connect(d->m_series, SIGNAL(barsetsAdded(QList<QBarSet*>)), d, SLOT(barSetsAdded(QList<QBarSet*>))); |
|
81 | connect(d->m_series, SIGNAL(barsetsAdded(QList<QBarSet*>)), d, SLOT(barSetsAdded(QList<QBarSet*>))); | |
82 | connect(d->m_series, SIGNAL(barsetsRemoved(QList<QBarSet*>)), d, SLOT(barSetsRemoved(QList<QBarSet*>))); |
|
82 | connect(d->m_series, SIGNAL(barsetsRemoved(QList<QBarSet*>)), d, SLOT(barSetsRemoved(QList<QBarSet*>))); | |
83 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); |
|
83 | connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | Returns which row/column of the model contains the first values of the QBarSets in the series. |
|
87 | Returns which row/column of the model contains the first values of the QBarSets in the series. | |
88 | The default value is 0. |
|
88 | The default value is 0. | |
89 | */ |
|
89 | */ | |
90 | int QBarModelMapper::first() const |
|
90 | int QBarModelMapper::first() const | |
91 | { |
|
91 | { | |
92 | Q_D(const QBarModelMapper); |
|
92 | Q_D(const QBarModelMapper); | |
93 | return d->m_first; |
|
93 | return d->m_first; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | /*! |
|
96 | /*! | |
97 | Sets which row of the model contains the \a first values of the QBarSets in the series. |
|
97 | Sets which row of the model contains the \a first values of the QBarSets in the series. | |
98 | The default value is 0. |
|
98 | The default value is 0. | |
99 | */ |
|
99 | */ | |
100 | void QBarModelMapper::setFirst(int first) |
|
100 | void QBarModelMapper::setFirst(int first) | |
101 | { |
|
101 | { | |
102 | Q_D(QBarModelMapper); |
|
102 | Q_D(QBarModelMapper); | |
103 | d->m_first = qMax(first, 0); |
|
103 | d->m_first = qMax(first, 0); | |
104 | d->initializeBarFromModel(); |
|
104 | d->initializeBarFromModel(); | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | Returns the number of rows/columns of the model that are mapped as the data for QAbstractBarSeries |
|
108 | Returns the number of rows/columns of the model that are mapped as the data for QAbstractBarSeries | |
109 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
109 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
110 | */ |
|
110 | */ | |
111 | int QBarModelMapper::count() const |
|
111 | int QBarModelMapper::count() const | |
112 | { |
|
112 | { | |
113 | Q_D(const QBarModelMapper); |
|
113 | Q_D(const QBarModelMapper); | |
114 | return d->m_count; |
|
114 | return d->m_count; | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
118 | Sets the \a count of rows/columns of the model that are mapped as the data for QAbstractBarSeries |
|
118 | Sets the \a count of rows/columns of the model that are mapped as the data for QAbstractBarSeries | |
119 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
119 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
120 | */ |
|
120 | */ | |
121 | void QBarModelMapper::setCount(int count) |
|
121 | void QBarModelMapper::setCount(int count) | |
122 | { |
|
122 | { | |
123 | Q_D(QBarModelMapper); |
|
123 | Q_D(QBarModelMapper); | |
124 | d->m_count = qMax(count, -1); |
|
124 | d->m_count = qMax(count, -1); | |
125 | d->initializeBarFromModel(); |
|
125 | d->initializeBarFromModel(); | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | Returns the orientation that is used when QBarModelMapper accesses the model. |
|
129 | Returns the orientation that is used when QBarModelMapper accesses the model. | |
130 | This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal) |
|
130 | This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal) | |
131 | or from columns (Qt::Vertical) |
|
131 | or from columns (Qt::Vertical) | |
132 | */ |
|
132 | */ | |
133 | Qt::Orientation QBarModelMapper::orientation() const |
|
133 | Qt::Orientation QBarModelMapper::orientation() const | |
134 | { |
|
134 | { | |
135 | Q_D(const QBarModelMapper); |
|
135 | Q_D(const QBarModelMapper); | |
136 | return d->m_orientation; |
|
136 | return d->m_orientation; | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | /*! |
|
139 | /*! | |
140 | Returns the \a orientation that is used when QBarModelMapper accesses the model. |
|
140 | Returns the \a orientation that is used when QBarModelMapper accesses the model. | |
141 | This mean whether the consecutive values of the pie are read from row (Qt::Horizontal) |
|
141 | This mean whether the consecutive values of the pie are read from row (Qt::Horizontal) | |
142 | or from columns (Qt::Vertical) |
|
142 | or from columns (Qt::Vertical) | |
143 | */ |
|
143 | */ | |
144 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) |
|
144 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) | |
145 | { |
|
145 | { | |
146 | Q_D(QBarModelMapper); |
|
146 | Q_D(QBarModelMapper); | |
147 | d->m_orientation = orientation; |
|
147 | d->m_orientation = orientation; | |
148 | d->initializeBarFromModel(); |
|
148 | d->initializeBarFromModel(); | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | /*! |
|
151 | /*! | |
152 | Returns which section of the model is used as the data source for the first bar set |
|
152 | Returns which section of the model is used as the data source for the first bar set | |
153 | */ |
|
153 | */ | |
154 | int QBarModelMapper::firstBarSetSection() const |
|
154 | int QBarModelMapper::firstBarSetSection() const | |
155 | { |
|
155 | { | |
156 | Q_D(const QBarModelMapper); |
|
156 | Q_D(const QBarModelMapper); | |
157 | return d->m_firstBarSetSection; |
|
157 | return d->m_firstBarSetSection; | |
158 | } |
|
158 | } | |
159 |
|
159 | |||
160 | /*! |
|
160 | /*! | |
161 | Sets the model section that is used as the data source for the first bar set |
|
161 | Sets the model section that is used as the data source for the first bar set | |
162 | Parameter \a firstBarSetSection specifies the section of the model. |
|
162 | Parameter \a firstBarSetSection specifies the section of the model. | |
163 | */ |
|
163 | */ | |
164 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) |
|
164 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) | |
165 | { |
|
165 | { | |
166 | Q_D(QBarModelMapper); |
|
166 | Q_D(QBarModelMapper); | |
167 | d->m_firstBarSetSection = qMax(-1, firstBarSetSection); |
|
167 | d->m_firstBarSetSection = qMax(-1, firstBarSetSection); | |
168 | d->initializeBarFromModel(); |
|
168 | d->initializeBarFromModel(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | Returns which section of the model is used as the data source for the last bar set |
|
172 | Returns which section of the model is used as the data source for the last bar set | |
173 | */ |
|
173 | */ | |
174 | int QBarModelMapper::lastBarSetSection() const |
|
174 | int QBarModelMapper::lastBarSetSection() const | |
175 | { |
|
175 | { | |
176 | Q_D(const QBarModelMapper); |
|
176 | Q_D(const QBarModelMapper); | |
177 | return d->m_lastBarSetSection; |
|
177 | return d->m_lastBarSetSection; | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | /*! |
|
180 | /*! | |
181 | Sets the model section that is used as the data source for the last bar set |
|
181 | Sets the model section that is used as the data source for the last bar set | |
182 | Parameter \a lastBarSetSection specifies the section of the model. |
|
182 | Parameter \a lastBarSetSection specifies the section of the model. | |
183 | */ |
|
183 | */ | |
184 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) |
|
184 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) | |
185 | { |
|
185 | { | |
186 | Q_D(QBarModelMapper); |
|
186 | Q_D(QBarModelMapper); | |
187 | d->m_lastBarSetSection = qMax(-1, lastBarSetSection); |
|
187 | d->m_lastBarSetSection = qMax(-1, lastBarSetSection); | |
188 | d->initializeBarFromModel(); |
|
188 | d->initializeBarFromModel(); | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
191 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
192 |
|
192 | |||
193 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : |
|
193 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : | |
194 | QObject(q), |
|
194 | QObject(q), | |
195 | m_series(0), |
|
195 | m_series(0), | |
196 | m_model(0), |
|
196 | m_model(0), | |
197 | m_first(0), |
|
197 | m_first(0), | |
198 | m_count(-1), |
|
198 | m_count(-1), | |
199 | m_orientation(Qt::Vertical), |
|
199 | m_orientation(Qt::Vertical), | |
200 | m_firstBarSetSection(-1), |
|
200 | m_firstBarSetSection(-1), | |
201 | m_lastBarSetSection(-1), |
|
201 | m_lastBarSetSection(-1), | |
202 | m_seriesSignalsBlock(false), |
|
202 | m_seriesSignalsBlock(false), | |
203 | m_modelSignalsBlock(false), |
|
203 | m_modelSignalsBlock(false), | |
204 | q_ptr(q) |
|
204 | q_ptr(q) | |
205 | { |
|
205 | { | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | void QBarModelMapperPrivate::blockModelSignals(bool block) |
|
208 | void QBarModelMapperPrivate::blockModelSignals(bool block) | |
209 | { |
|
209 | { | |
210 | m_modelSignalsBlock = block; |
|
210 | m_modelSignalsBlock = block; | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) |
|
213 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) | |
214 | { |
|
214 | { | |
215 | m_seriesSignalsBlock = block; |
|
215 | m_seriesSignalsBlock = block; | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | QBarSet *QBarModelMapperPrivate::barSet(QModelIndex index) |
|
218 | QBarSet *QBarModelMapperPrivate::barSet(QModelIndex index) | |
219 | { |
|
219 | { | |
220 | if (!index.isValid()) |
|
220 | if (!index.isValid()) | |
221 | return 0; |
|
221 | return 0; | |
222 |
|
222 | |||
223 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { |
|
223 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { | |
224 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
224 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { | |
225 | // if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) |
|
|||
226 | return m_series->barSets().at(index.column() - m_firstBarSetSection); |
|
225 | return m_series->barSets().at(index.column() - m_firstBarSetSection); | |
227 | // else |
|
|||
228 | // return 0; |
|
|||
229 | } |
|
226 | } | |
230 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { |
|
227 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { | |
231 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
228 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) | |
232 | return m_series->barSets().at(index.row() - m_firstBarSetSection); |
|
229 | return m_series->barSets().at(index.row() - m_firstBarSetSection); | |
233 | } |
|
230 | } | |
234 | return 0; // This part of model has not been mapped to any slice |
|
231 | return 0; // This part of model has not been mapped to any slice | |
235 | } |
|
232 | } | |
236 |
|
233 | |||
237 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) |
|
234 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) | |
238 | { |
|
235 | { | |
239 | if (m_count != -1 && posInBar >= m_count) |
|
236 | if (m_count != -1 && posInBar >= m_count) | |
240 | return QModelIndex(); // invalid |
|
237 | return QModelIndex(); // invalid | |
241 |
|
238 | |||
242 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) |
|
239 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) | |
243 | return QModelIndex(); // invalid |
|
240 | return QModelIndex(); // invalid | |
244 |
|
241 | |||
245 | if (m_orientation == Qt::Vertical) |
|
242 | if (m_orientation == Qt::Vertical) | |
246 | return m_model->index(posInBar + m_first, barSection); |
|
243 | return m_model->index(posInBar + m_first, barSection); | |
247 | else |
|
244 | else | |
248 | return m_model->index(barSection, posInBar + m_first); |
|
245 | return m_model->index(barSection, posInBar + m_first); | |
249 | } |
|
246 | } | |
250 |
|
247 | |||
251 | void QBarModelMapperPrivate::handleSeriesDestroyed() |
|
248 | void QBarModelMapperPrivate::handleSeriesDestroyed() | |
252 | { |
|
249 | { | |
253 | m_series = 0; |
|
250 | m_series = 0; | |
254 | } |
|
251 | } | |
255 |
|
252 | |||
256 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
253 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
257 | { |
|
254 | { | |
258 | Q_UNUSED(topLeft) |
|
255 | Q_UNUSED(topLeft) | |
259 | Q_UNUSED(bottomRight) |
|
256 | Q_UNUSED(bottomRight) | |
260 |
|
257 | |||
261 | if (m_model == 0 || m_series == 0) |
|
258 | if (m_model == 0 || m_series == 0) | |
262 | return; |
|
259 | return; | |
263 |
|
260 | |||
264 | if (m_modelSignalsBlock) |
|
261 | if (m_modelSignalsBlock) | |
265 | return; |
|
262 | return; | |
266 |
|
263 | |||
267 | blockSeriesSignals(); |
|
264 | blockSeriesSignals(); | |
268 | QModelIndex index; |
|
265 | QModelIndex index; | |
269 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
266 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
270 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
267 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
271 | index = topLeft.sibling(row, column); |
|
268 | index = topLeft.sibling(row, column); | |
272 | QBarSet *bar = barSet(index); |
|
269 | QBarSet *bar = barSet(index); | |
273 | if (bar) { |
|
270 | if (bar) { | |
274 | if (m_orientation == Qt::Vertical) |
|
271 | if (m_orientation == Qt::Vertical) | |
275 | bar->replace(row - m_first, m_model->data(index).toReal()); |
|
272 | bar->replace(row - m_first, m_model->data(index).toReal()); | |
276 | else |
|
273 | else | |
277 | bar->replace(column - m_first, m_model->data(index).toReal()); |
|
274 | bar->replace(column - m_first, m_model->data(index).toReal()); | |
278 | } |
|
275 | } | |
279 | } |
|
276 | } | |
280 | } |
|
277 | } | |
281 | blockSeriesSignals(false); |
|
278 | blockSeriesSignals(false); | |
282 | } |
|
279 | } | |
283 |
|
280 | |||
284 | void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) |
|
281 | void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) | |
285 | { |
|
282 | { | |
286 | if (m_model == 0 || m_series == 0) |
|
283 | if (m_model == 0 || m_series == 0) | |
287 | return; |
|
284 | return; | |
288 |
|
285 | |||
289 | if (m_modelSignalsBlock) |
|
286 | if (m_modelSignalsBlock) | |
290 | return; |
|
287 | return; | |
291 |
|
288 | |||
292 | blockSeriesSignals(); |
|
289 | blockSeriesSignals(); | |
293 | if (orientation != m_orientation) { |
|
290 | if (orientation != m_orientation) { | |
294 | for (int section = first; section <= last; section++) { |
|
291 | for (int section = first; section <= last; section++) { | |
295 | if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) { |
|
292 | if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) { | |
296 | QBarSet *bar = m_series->barSets().at(section - m_firstBarSetSection); |
|
293 | QBarSet *bar = m_series->barSets().at(section - m_firstBarSetSection); | |
297 | if (bar) |
|
294 | if (bar) | |
298 | bar->setLabel(m_model->headerData(section, orientation).toString()); |
|
295 | bar->setLabel(m_model->headerData(section, orientation).toString()); | |
299 | } |
|
296 | } | |
300 | } |
|
297 | } | |
301 | } |
|
298 | } | |
302 | blockSeriesSignals(false); |
|
299 | blockSeriesSignals(false); | |
303 | } |
|
300 | } | |
304 |
|
301 | |||
305 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
302 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
306 | { |
|
303 | { | |
307 |
Q_UNUSED(parent) |
|
304 | Q_UNUSED(parent) | |
308 | Q_UNUSED(end) |
|
|||
309 | if (m_modelSignalsBlock) |
|
305 | if (m_modelSignalsBlock) | |
310 | return; |
|
306 | return; | |
311 |
|
307 | |||
312 | blockSeriesSignals(); |
|
308 | blockSeriesSignals(); | |
313 | if (m_orientation == Qt::Vertical) |
|
309 | if (m_orientation == Qt::Vertical) | |
314 |
|
|
310 | insertData(start, end); | |
315 | initializeBarFromModel(); |
|
|||
316 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
311 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
317 | initializeBarFromModel(); |
|
312 | initializeBarFromModel(); | |
318 | blockSeriesSignals(false); |
|
313 | blockSeriesSignals(false); | |
319 | } |
|
314 | } | |
320 |
|
315 | |||
321 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
316 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
322 | { |
|
317 | { | |
323 |
Q_UNUSED(parent) |
|
318 | Q_UNUSED(parent) | |
324 | Q_UNUSED(end) |
|
|||
325 | if (m_modelSignalsBlock) |
|
319 | if (m_modelSignalsBlock) | |
326 | return; |
|
320 | return; | |
327 |
|
321 | |||
328 | blockSeriesSignals(); |
|
322 | blockSeriesSignals(); | |
329 | if (m_orientation == Qt::Vertical) |
|
323 | if (m_orientation == Qt::Vertical) | |
330 |
|
|
324 | removeData(start, end); | |
331 | initializeBarFromModel(); |
|
|||
332 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
325 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
333 | initializeBarFromModel(); |
|
326 | initializeBarFromModel(); | |
334 | blockSeriesSignals(false); |
|
327 | blockSeriesSignals(false); | |
335 | } |
|
328 | } | |
336 |
|
329 | |||
337 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
330 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
338 | { |
|
331 | { | |
339 |
Q_UNUSED(parent) |
|
332 | Q_UNUSED(parent) | |
340 | Q_UNUSED(end) |
|
|||
341 | if (m_modelSignalsBlock) |
|
333 | if (m_modelSignalsBlock) | |
342 | return; |
|
334 | return; | |
343 |
|
335 | |||
344 | blockSeriesSignals(); |
|
336 | blockSeriesSignals(); | |
345 | if (m_orientation == Qt::Horizontal) |
|
337 | if (m_orientation == Qt::Horizontal) | |
346 |
|
|
338 | insertData(start, end); | |
347 | initializeBarFromModel(); |
|
|||
348 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
339 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
349 | initializeBarFromModel(); |
|
340 | initializeBarFromModel(); | |
350 | blockSeriesSignals(false); |
|
341 | blockSeriesSignals(false); | |
351 | } |
|
342 | } | |
352 |
|
343 | |||
353 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
344 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
354 | { |
|
345 | { | |
355 |
Q_UNUSED(parent) |
|
346 | Q_UNUSED(parent) | |
356 | Q_UNUSED(end) |
|
|||
357 | if (m_modelSignalsBlock) |
|
347 | if (m_modelSignalsBlock) | |
358 | return; |
|
348 | return; | |
359 |
|
349 | |||
360 | blockSeriesSignals(); |
|
350 | blockSeriesSignals(); | |
361 | if (m_orientation == Qt::Horizontal) |
|
351 | if (m_orientation == Qt::Horizontal) | |
362 |
|
|
352 | removeData(start, end); | |
363 | initializeBarFromModel(); |
|
|||
364 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
353 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
365 | initializeBarFromModel(); |
|
354 | initializeBarFromModel(); | |
366 | blockSeriesSignals(false); |
|
355 | blockSeriesSignals(false); | |
367 | } |
|
356 | } | |
368 |
|
357 | |||
369 | void QBarModelMapperPrivate::handleModelDestroyed() |
|
358 | void QBarModelMapperPrivate::handleModelDestroyed() | |
370 | { |
|
359 | { | |
371 | m_model = 0; |
|
360 | m_model = 0; | |
372 | } |
|
361 | } | |
373 |
|
362 | |||
374 | void QBarModelMapperPrivate::insertData(int start, int end) |
|
363 | void QBarModelMapperPrivate::insertData(int start, int end) | |
375 | { |
|
364 | { | |
376 | Q_UNUSED(end) |
|
365 | Q_UNUSED(end) | |
377 | Q_UNUSED(start) |
|
366 | Q_UNUSED(start) | |
378 | Q_UNUSED(end) |
|
367 | Q_UNUSED(end) | |
379 | // To be implemented |
|
368 | // Currently barchart needs to be fully recalculated when change is made. | |
|
369 | // Re-initialize | |||
|
370 | initializeBarFromModel(); | |||
380 | } |
|
371 | } | |
381 |
|
372 | |||
382 | void QBarModelMapperPrivate::removeData(int start, int end) |
|
373 | void QBarModelMapperPrivate::removeData(int start, int end) | |
383 | { |
|
374 | { | |
384 | Q_UNUSED(end) |
|
375 | Q_UNUSED(end) | |
385 | Q_UNUSED(start) |
|
376 | Q_UNUSED(start) | |
386 | Q_UNUSED(end) |
|
377 | Q_UNUSED(end) | |
387 | // To be implemented |
|
378 | // Currently barchart needs to be fully recalculated when change is made. | |
|
379 | // Re-initialize | |||
|
380 | initializeBarFromModel(); | |||
388 | } |
|
381 | } | |
389 |
|
382 | |||
390 | void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet *> sets) |
|
383 | void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet *> sets) | |
391 | { |
|
384 | { | |
392 | if (m_seriesSignalsBlock) |
|
385 | if (m_seriesSignalsBlock) | |
393 | return; |
|
386 | return; | |
394 |
|
387 | |||
395 | if (sets.count() == 0) |
|
388 | if (sets.count() == 0) | |
396 | return; |
|
389 | return; | |
397 |
|
390 | |||
398 | int firstIndex = m_series->barSets().indexOf(sets.at(0)); |
|
391 | int firstIndex = m_series->barSets().indexOf(sets.at(0)); | |
399 | if (firstIndex == -1) |
|
392 | if (firstIndex == -1) | |
400 | return; |
|
393 | return; | |
401 |
|
394 | |||
402 | int maxCount = 0; |
|
395 | int maxCount = 0; | |
403 | for (int i = 0; i < sets.count(); i++) { |
|
396 | for (int i = 0; i < sets.count(); i++) { | |
404 | if (sets.at(i)->count() > m_count) |
|
397 | if (sets.at(i)->count() > m_count) | |
405 | maxCount = sets.at(i)->count(); |
|
398 | maxCount = sets.at(i)->count(); | |
406 | } |
|
399 | } | |
407 |
|
400 | |||
408 | if (m_count != -1 && m_count < maxCount) |
|
401 | if (m_count != -1 && m_count < maxCount) | |
409 | m_count = maxCount; |
|
402 | m_count = maxCount; | |
410 |
|
403 | |||
411 | m_lastBarSetSection += sets.count(); |
|
404 | m_lastBarSetSection += sets.count(); | |
412 |
|
405 | |||
413 | blockModelSignals(); |
|
406 | blockModelSignals(); | |
414 | int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; |
|
407 | int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; | |
415 | if (maxCount > modelCapacity) { |
|
408 | if (maxCount > modelCapacity) { | |
416 | if (m_orientation == Qt::Vertical) |
|
409 | if (m_orientation == Qt::Vertical) | |
417 | m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); |
|
410 | m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); | |
418 | else |
|
411 | else | |
419 | m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); |
|
412 | m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); | |
420 | } |
|
413 | } | |
421 |
|
414 | |||
422 | if (m_orientation == Qt::Vertical) |
|
415 | if (m_orientation == Qt::Vertical) | |
423 | m_model->insertColumns(firstIndex + m_firstBarSetSection, sets.count()); |
|
416 | m_model->insertColumns(firstIndex + m_firstBarSetSection, sets.count()); | |
424 | else |
|
417 | else | |
425 | m_model->insertRows(firstIndex + m_firstBarSetSection, sets.count()); |
|
418 | m_model->insertRows(firstIndex + m_firstBarSetSection, sets.count()); | |
426 |
|
419 | |||
427 |
|
420 | |||
428 | for (int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) { |
|
421 | for (int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) { | |
429 | m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label()); |
|
422 | m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label()); | |
430 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++) |
|
423 | for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++) | |
431 | m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j)); |
|
424 | m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j)); | |
432 | } |
|
425 | } | |
433 | blockModelSignals(false); |
|
426 | blockModelSignals(false); | |
434 | initializeBarFromModel(); |
|
427 | initializeBarFromModel(); | |
435 | } |
|
428 | } | |
436 |
|
429 | |||
437 | void QBarModelMapperPrivate::barSetsRemoved(QList<QBarSet *> sets) |
|
430 | void QBarModelMapperPrivate::barSetsRemoved(QList<QBarSet *> sets) | |
438 | { |
|
431 | { | |
439 | if (m_seriesSignalsBlock) |
|
432 | if (m_seriesSignalsBlock) | |
440 | return; |
|
433 | return; | |
441 |
|
434 | |||
442 | if (sets.count() == 0) |
|
435 | if (sets.count() == 0) | |
443 | return; |
|
436 | return; | |
444 |
|
437 | |||
445 | int firstIndex = m_barSets.indexOf(sets.at(0)); |
|
438 | int firstIndex = m_barSets.indexOf(sets.at(0)); | |
446 | if (firstIndex == -1) |
|
439 | if (firstIndex == -1) | |
447 | return; |
|
440 | return; | |
448 |
|
441 | |||
449 | m_lastBarSetSection -= sets.count(); |
|
442 | m_lastBarSetSection -= sets.count(); | |
450 |
|
443 | |||
451 | for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) |
|
444 | for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) | |
452 | m_barSets.removeAt(i); |
|
445 | m_barSets.removeAt(i); | |
453 |
|
446 | |||
454 | blockModelSignals(); |
|
447 | blockModelSignals(); | |
455 | if (m_orientation == Qt::Vertical) |
|
448 | if (m_orientation == Qt::Vertical) | |
456 | m_model->removeColumns(firstIndex + m_firstBarSetSection, sets.count()); |
|
449 | m_model->removeColumns(firstIndex + m_firstBarSetSection, sets.count()); | |
457 | else |
|
450 | else | |
458 | m_model->removeRows(firstIndex + m_firstBarSetSection, sets.count()); |
|
451 | m_model->removeRows(firstIndex + m_firstBarSetSection, sets.count()); | |
459 | blockModelSignals(false); |
|
452 | blockModelSignals(false); | |
460 | initializeBarFromModel(); |
|
453 | initializeBarFromModel(); | |
461 | } |
|
454 | } | |
462 |
|
455 | |||
463 | void QBarModelMapperPrivate::valuesAdded(int index, int count) |
|
456 | void QBarModelMapperPrivate::valuesAdded(int index, int count) | |
464 | { |
|
457 | { | |
465 | if (m_seriesSignalsBlock) |
|
458 | if (m_seriesSignalsBlock) | |
466 | return; |
|
459 | return; | |
467 |
|
460 | |||
468 | if (m_count != -1) |
|
461 | if (m_count != -1) | |
469 | m_count += count; |
|
462 | m_count += count; | |
470 |
|
463 | |||
471 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
464 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
472 |
|
465 | |||
473 | blockModelSignals(); |
|
466 | blockModelSignals(); | |
474 | if (m_orientation == Qt::Vertical) |
|
467 | if (m_orientation == Qt::Vertical) | |
475 | m_model->insertRows(index + m_first, count); |
|
468 | m_model->insertRows(index + m_first, count); | |
476 | else |
|
469 | else | |
477 | m_model->insertColumns(index + m_first, count); |
|
470 | m_model->insertColumns(index + m_first, count); | |
478 |
|
471 | |||
479 | for (int j = index; j < index + count; j++) |
|
472 | for (int j = index; j < index + count; j++) | |
480 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j)); |
|
473 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j)); | |
481 |
|
474 | |||
482 | blockModelSignals(false); |
|
475 | blockModelSignals(false); | |
483 | initializeBarFromModel(); |
|
476 | initializeBarFromModel(); | |
484 | } |
|
477 | } | |
485 |
|
478 | |||
486 | void QBarModelMapperPrivate::valuesRemoved(int index, int count) |
|
479 | void QBarModelMapperPrivate::valuesRemoved(int index, int count) | |
487 | { |
|
480 | { | |
488 | if (m_seriesSignalsBlock) |
|
481 | if (m_seriesSignalsBlock) | |
489 | return; |
|
482 | return; | |
490 |
|
483 | |||
491 | if (m_count != -1) |
|
484 | if (m_count != -1) | |
492 | m_count -= count; |
|
485 | m_count -= count; | |
493 |
|
486 | |||
494 | blockModelSignals(); |
|
487 | blockModelSignals(); | |
495 | if (m_orientation == Qt::Vertical) |
|
488 | if (m_orientation == Qt::Vertical) | |
496 | m_model->removeRows(index + m_first, count); |
|
489 | m_model->removeRows(index + m_first, count); | |
497 | else |
|
490 | else | |
498 | m_model->removeColumns(index + m_first, count); |
|
491 | m_model->removeColumns(index + m_first, count); | |
499 |
|
492 | |||
500 | blockModelSignals(false); |
|
493 | blockModelSignals(false); | |
501 | initializeBarFromModel(); |
|
494 | initializeBarFromModel(); | |
502 | } |
|
495 | } | |
503 |
|
496 | |||
504 | void QBarModelMapperPrivate::barLabelChanged() |
|
497 | void QBarModelMapperPrivate::barLabelChanged() | |
505 | { |
|
498 | { | |
506 | if (m_seriesSignalsBlock) |
|
499 | if (m_seriesSignalsBlock) | |
507 | return; |
|
500 | return; | |
508 |
|
501 | |||
509 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
502 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
510 |
|
503 | |||
511 | blockModelSignals(); |
|
504 | blockModelSignals(); | |
512 | m_model->setHeaderData(barSetIndex + m_firstBarSetSection, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, m_barSets.at(barSetIndex)->label()); |
|
505 | m_model->setHeaderData(barSetIndex + m_firstBarSetSection, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, m_barSets.at(barSetIndex)->label()); | |
513 | blockModelSignals(false); |
|
506 | blockModelSignals(false); | |
514 | initializeBarFromModel(); |
|
507 | initializeBarFromModel(); | |
515 | } |
|
508 | } | |
516 |
|
509 | |||
517 | void QBarModelMapperPrivate::barValueChanged(int index) |
|
510 | void QBarModelMapperPrivate::barValueChanged(int index) | |
518 | { |
|
511 | { | |
519 | if (m_seriesSignalsBlock) |
|
512 | if (m_seriesSignalsBlock) | |
520 | return; |
|
513 | return; | |
521 |
|
514 | |||
522 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); |
|
515 | int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender())); | |
523 |
|
516 | |||
524 | blockModelSignals(); |
|
517 | blockModelSignals(); | |
525 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index)); |
|
518 | m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index)); | |
526 | blockModelSignals(false); |
|
519 | blockModelSignals(false); | |
527 | initializeBarFromModel(); |
|
520 | initializeBarFromModel(); | |
528 | } |
|
521 | } | |
529 |
|
522 | |||
530 | void QBarModelMapperPrivate::initializeBarFromModel() |
|
523 | void QBarModelMapperPrivate::initializeBarFromModel() | |
531 | { |
|
524 | { | |
532 | if (m_model == 0 || m_series == 0) |
|
525 | if (m_model == 0 || m_series == 0) | |
533 | return; |
|
526 | return; | |
534 |
|
527 | |||
535 | blockSeriesSignals(); |
|
528 | blockSeriesSignals(); | |
536 | // clear current content |
|
529 | // clear current content | |
537 | m_series->clear(); |
|
530 | m_series->clear(); | |
538 | m_barSets.clear(); |
|
531 | m_barSets.clear(); | |
539 |
|
532 | |||
540 | // create the initial bar sets |
|
533 | // create the initial bar sets | |
541 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { |
|
534 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { | |
542 | int posInBar = 0; |
|
535 | int posInBar = 0; | |
543 | QModelIndex barIndex = barModelIndex(i, posInBar); |
|
536 | QModelIndex barIndex = barModelIndex(i, posInBar); | |
544 | // check if there is such model index |
|
537 | // check if there is such model index | |
545 | if (barIndex.isValid()) { |
|
538 | if (barIndex.isValid()) { | |
546 | QBarSet *barSet = new QBarSet(m_model->headerData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical).toString()); |
|
539 | QBarSet *barSet = new QBarSet(m_model->headerData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical).toString()); | |
547 | while (barIndex.isValid()) { |
|
540 | while (barIndex.isValid()) { | |
548 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); |
|
541 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); | |
549 | posInBar++; |
|
542 | posInBar++; | |
550 | barIndex = barModelIndex(i, posInBar); |
|
543 | barIndex = barModelIndex(i, posInBar); | |
551 | } |
|
544 | } | |
552 | connect(barSet, SIGNAL(valuesAdded(int,int)), this, SLOT(valuesAdded(int,int))); |
|
545 | connect(barSet, SIGNAL(valuesAdded(int,int)), this, SLOT(valuesAdded(int,int))); | |
553 | connect(barSet, SIGNAL(valuesRemoved(int,int)), this, SLOT(valuesRemoved(int,int))); |
|
546 | connect(barSet, SIGNAL(valuesRemoved(int,int)), this, SLOT(valuesRemoved(int,int))); | |
554 | connect(barSet, SIGNAL(valueChanged(int)), this, SLOT(barValueChanged(int))); |
|
547 | connect(barSet, SIGNAL(valueChanged(int)), this, SLOT(barValueChanged(int))); | |
555 | connect(barSet, SIGNAL(labelChanged()), this, SLOT(barLabelChanged())); |
|
548 | connect(barSet, SIGNAL(labelChanged()), this, SLOT(barLabelChanged())); | |
556 | m_series->append(barSet); |
|
549 | m_series->append(barSet); | |
557 | m_barSets.append(barSet); |
|
550 | m_barSets.append(barSet); | |
558 | } else { |
|
551 | } else { | |
559 | break; |
|
552 | break; | |
560 | } |
|
553 | } | |
561 | } |
|
554 | } | |
562 | blockSeriesSignals(false); |
|
555 | blockSeriesSignals(false); | |
563 | } |
|
556 | } | |
564 |
|
557 | |||
565 | #include "moc_qbarmodelmapper.cpp" |
|
558 | #include "moc_qbarmodelmapper.cpp" | |
566 | #include "moc_qbarmodelmapper_p.cpp" |
|
559 | #include "moc_qbarmodelmapper_p.cpp" | |
567 |
|
560 | |||
568 | QTCOMMERCIALCHART_END_NAMESPACE |
|
561 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now