|
@@
-179,6
+179,21
void QBarModelMapperPrivate::blockSeriesSignals(bool block)
|
|
179
|
m_seriesSignalsBlock = block;
|
|
179
|
m_seriesSignalsBlock = block;
|
|
180
|
}
|
|
180
|
}
|
|
181
|
|
|
181
|
|
|
|
|
|
182
|
QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index)
|
|
|
|
|
183
|
{
|
|
|
|
|
184
|
if (!index.isValid())
|
|
|
|
|
185
|
return 0;
|
|
|
|
|
186
|
|
|
|
|
|
187
|
if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSection && index.column() <= m_lastBarSection) {
|
|
|
|
|
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);
|
|
|
|
|
190
|
} else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSection && index.row() <= m_lastBarSection) {
|
|
|
|
|
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);
|
|
|
|
|
193
|
}
|
|
|
|
|
194
|
return 0; // This part of model has not been mapped to any slice
|
|
|
|
|
195
|
}
|
|
|
|
|
196
|
|
|
182
|
QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar)
|
|
197
|
QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar)
|
|
183
|
{
|
|
198
|
{
|
|
184
|
if (m_count != -1 && posInBar >= m_count)
|
|
199
|
if (m_count != -1 && posInBar >= m_count)
|
|
@@
-215,43
+230,36
void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex botto
|
|
215
|
if (m_modelSignalsBlock)
|
|
230
|
if (m_modelSignalsBlock)
|
|
216
|
return;
|
|
231
|
return;
|
|
217
|
|
|
232
|
|
|
218
|
// blockSeriesSignals();
|
|
233
|
blockSeriesSignals();
|
|
219
|
// QModelIndex index;
|
|
234
|
QModelIndex index;
|
|
220
|
// QPointF oldPoint;
|
|
235
|
// QPointF oldPoint;
|
|
221
|
// QPointF newPoint;
|
|
236
|
// QPointF newPoint;
|
|
222
|
// for (int row = topLeft.row(); row <= bottomRight.row(); row++) {
|
|
237
|
for (int row = topLeft.row(); row <= bottomRight.row(); row++) {
|
|
223
|
// for (int column = topLeft.column(); column <= bottomRight.column(); column++) {
|
|
238
|
for (int column = topLeft.column(); column <= bottomRight.column(); column++) {
|
|
224
|
// index = topLeft.sibling(row, column);
|
|
239
|
index = topLeft.sibling(row, column);
|
|
225
|
// if (m_orientation == Qt::Vertical && (index.column() == m_xSection|| index.column() == m_ySection)) {
|
|
240
|
QBarSet* bar = barSet(index);
|
|
226
|
// if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) {
|
|
241
|
if (bar) {
|
|
227
|
// oldPoint = m_series->points().at(index.row() - m_first);
|
|
242
|
if (m_orientation == Qt::Vertical)
|
|
228
|
// newPoint.setX(m_model->data(m_model->index(index.row(), m_xSection)).toReal());
|
|
243
|
bar->replace(row - m_first, m_model->data(index).toReal());
|
|
229
|
// newPoint.setY(m_model->data(m_model->index(index.row(), m_ySection)).toReal());
|
|
244
|
else
|
|
230
|
// }
|
|
245
|
bar->replace(column - m_first, m_model->data(index).toReal());
|
|
231
|
// } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) {
|
|
246
|
}
|
|
232
|
// if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) {
|
|
247
|
}
|
|
233
|
// oldPoint = m_series->points().at(index.column() - m_first);
|
|
248
|
}
|
|
234
|
// newPoint.setX(m_model->data(m_model->index(m_xSection, index.column())).toReal());
|
|
249
|
blockSeriesSignals(false);
|
|
235
|
// newPoint.setY(m_model->data(m_model->index(m_ySection, index.column())).toReal());
|
|
|
|
|
236
|
// }
|
|
|
|
|
237
|
// } else {
|
|
|
|
|
238
|
// continue;
|
|
|
|
|
239
|
// }
|
|
|
|
|
240
|
// m_series->replace(oldPoint, newPoint);
|
|
|
|
|
241
|
// }
|
|
|
|
|
242
|
// blockSeriesSignals(false);
|
|
|
|
|
243
|
// }
|
|
|
|
|
244
|
}
|
|
250
|
}
|
|
245
|
|
|
251
|
|
|
246
|
void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end)
|
|
252
|
void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end)
|
|
247
|
{
|
|
253
|
{
|
|
248
|
Q_UNUSED(parent);
|
|
254
|
Q_UNUSED(parent);
|
|
|
|
|
255
|
Q_UNUSED(end)
|
|
249
|
if (m_modelSignalsBlock)
|
|
256
|
if (m_modelSignalsBlock)
|
|
250
|
return;
|
|
257
|
return;
|
|
251
|
|
|
258
|
|
|
252
|
blockSeriesSignals();
|
|
259
|
blockSeriesSignals();
|
|
253
|
if (m_orientation == Qt::Vertical)
|
|
260
|
if (m_orientation == Qt::Vertical)
|
|
254
|
insertData(start, end);
|
|
261
|
// insertData(start, end);
|
|
|
|
|
262
|
initializeBarFromModel();
|
|
255
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
263
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
256
|
initializeBarFromModel();
|
|
264
|
initializeBarFromModel();
|
|
257
|
blockSeriesSignals(false);
|
|
265
|
blockSeriesSignals(false);
|
|
@@
-260,12
+268,14
void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int e
|
|
260
|
void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end)
|
|
268
|
void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end)
|
|
261
|
{
|
|
269
|
{
|
|
262
|
Q_UNUSED(parent);
|
|
270
|
Q_UNUSED(parent);
|
|
|
|
|
271
|
Q_UNUSED(end)
|
|
263
|
if (m_modelSignalsBlock)
|
|
272
|
if (m_modelSignalsBlock)
|
|
264
|
return;
|
|
273
|
return;
|
|
265
|
|
|
274
|
|
|
266
|
blockSeriesSignals();
|
|
275
|
blockSeriesSignals();
|
|
267
|
if (m_orientation == Qt::Vertical)
|
|
276
|
if (m_orientation == Qt::Vertical)
|
|
268
|
removeData(start, end);
|
|
277
|
// removeData(start, end);
|
|
|
|
|
278
|
initializeBarFromModel();
|
|
269
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
279
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
270
|
initializeBarFromModel();
|
|
280
|
initializeBarFromModel();
|
|
271
|
blockSeriesSignals(false);
|
|
281
|
blockSeriesSignals(false);
|
|
@@
-274,12
+284,14
void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int
|
|
274
|
void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end)
|
|
284
|
void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end)
|
|
275
|
{
|
|
285
|
{
|
|
276
|
Q_UNUSED(parent);
|
|
286
|
Q_UNUSED(parent);
|
|
|
|
|
287
|
Q_UNUSED(end)
|
|
277
|
if (m_modelSignalsBlock)
|
|
288
|
if (m_modelSignalsBlock)
|
|
278
|
return;
|
|
289
|
return;
|
|
279
|
|
|
290
|
|
|
280
|
blockSeriesSignals();
|
|
291
|
blockSeriesSignals();
|
|
281
|
if (m_orientation == Qt::Horizontal)
|
|
292
|
if (m_orientation == Qt::Horizontal)
|
|
282
|
insertData(start, end);
|
|
293
|
// insertData(start, end);
|
|
|
|
|
294
|
initializeBarFromModel();
|
|
283
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
295
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
284
|
initializeBarFromModel();
|
|
296
|
initializeBarFromModel();
|
|
285
|
blockSeriesSignals(false);
|
|
297
|
blockSeriesSignals(false);
|
|
@@
-288,12
+300,14
void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, in
|
|
288
|
void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end)
|
|
300
|
void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end)
|
|
289
|
{
|
|
301
|
{
|
|
290
|
Q_UNUSED(parent);
|
|
302
|
Q_UNUSED(parent);
|
|
|
|
|
303
|
Q_UNUSED(end)
|
|
291
|
if (m_modelSignalsBlock)
|
|
304
|
if (m_modelSignalsBlock)
|
|
292
|
return;
|
|
305
|
return;
|
|
293
|
|
|
306
|
|
|
294
|
blockSeriesSignals();
|
|
307
|
blockSeriesSignals();
|
|
295
|
if (m_orientation == Qt::Horizontal)
|
|
308
|
if (m_orientation == Qt::Horizontal)
|
|
296
|
removeData(start, end);
|
|
309
|
// removeData(start, end);
|
|
|
|
|
310
|
initializeBarFromModel();
|
|
297
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
311
|
else if (start <= m_firstBarSection || start <= m_lastBarSection || start <= m_categoriesSection) // if the changes affect the map - reinitialize
|
|
298
|
initializeBarFromModel();
|
|
312
|
initializeBarFromModel();
|
|
299
|
blockSeriesSignals(false);
|
|
313
|
blockSeriesSignals(false);
|
|
@@
-313,12
+327,14
void QBarModelMapperPrivate::insertData(int start, int end)
|
|
313
|
addedCount = m_count;
|
|
327
|
addedCount = m_count;
|
|
314
|
int first = qMax(start, m_first);
|
|
328
|
int first = qMax(start, m_first);
|
|
315
|
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++) {
|
|
316
|
for (int i = first; i <= last; i++) {
|
|
331
|
for (int i = first; i <= last; i++) {
|
|
317
|
QPointF point;
|
|
332
|
QBar point;
|
|
318
|
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());
|
|
319
|
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());
|
|
320
|
m_series->insert(i - m_first, point);
|
|
335
|
m_series->insert(i - m_first, point);
|
|
321
|
}
|
|
336
|
}
|
|
|
|
|
337
|
}
|
|
322
|
|
|
338
|
|
|
323
|
// remove excess of slices (abouve m_count)
|
|
339
|
// remove excess of slices (abouve m_count)
|
|
324
|
if (m_count != -1 && m_series->points().size() > m_count)
|
|
340
|
if (m_count != -1 && m_series->points().size() > m_count)
|
|
@@
-371,7
+387,7
void QBarModelMapperPrivate::initializeBarFromModel()
|
|
371
|
|
|
387
|
|
|
372
|
blockSeriesSignals();
|
|
388
|
blockSeriesSignals();
|
|
373
|
// clear current content
|
|
389
|
// clear current content
|
|
374
|
// m_series->clear();
|
|
390
|
m_series->clear();
|
|
375
|
|
|
391
|
|
|
376
|
// create the initial bar sets
|
|
392
|
// create the initial bar sets
|
|
377
|
for (int i = m_firstBarSection; i <= m_lastBarSection; i++) {
|
|
393
|
for (int i = m_firstBarSection; i <= m_lastBarSection; i++) {
|