@@ -253,17 +253,25 void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottom | |||
|
253 | 253 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
254 | 254 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
255 | 255 | index = topLeft.sibling(row, column); |
|
256 | if (m_orientation == Qt::Vertical && (index.column() == m_xSection|| index.column() == m_ySection)) { | |
|
256 | if (m_orientation == Qt::Vertical && (index.column() == m_xSection || index.column() == m_ySection)) { | |
|
257 | 257 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
258 |
|
|
|
259 | newPoint.setX(m_model->data(m_model->index(index.row(), m_xSection)).toReal()); | |
|
260 | newPoint.setY(m_model->data(m_model->index(index.row(), m_ySection)).toReal()); | |
|
258 | QModelIndex xIndex = xModelIndex(index.row() - m_first); | |
|
259 | QModelIndex yIndex = yModelIndex(index.row() - m_first); | |
|
260 | if (xIndex.isValid() && yIndex.isValid()) { | |
|
261 | oldPoint = m_series->points().at(index.row() - m_first); | |
|
262 | newPoint.setX(m_model->data(xIndex).toReal()); | |
|
263 | newPoint.setY(m_model->data(yIndex).toReal()); | |
|
264 | } | |
|
261 | 265 | } |
|
262 | 266 | } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) { |
|
263 | 267 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) { |
|
264 |
|
|
|
265 | newPoint.setX(m_model->data(m_model->index(m_xSection, index.column())).toReal()); | |
|
266 | newPoint.setY(m_model->data(m_model->index(m_ySection, index.column())).toReal()); | |
|
268 | QModelIndex xIndex = xModelIndex(index.column() - m_first); | |
|
269 | QModelIndex yIndex = yModelIndex(index.column() - m_first); | |
|
270 | if (xIndex.isValid() && yIndex.isValid()) { | |
|
271 | oldPoint = m_series->points().at(index.column() - m_first); | |
|
272 | newPoint.setX(m_model->data(xIndex).toReal()); | |
|
273 | newPoint.setY(m_model->data(yIndex).toReal()); | |
|
274 | } | |
|
267 | 275 | } |
|
268 | 276 | } else { |
|
269 | 277 | continue; |
@@ -345,9 +353,13 void QXYModelMapperPrivate::insertData(int start, int end) | |||
|
345 | 353 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); |
|
346 | 354 | for (int i = first; i <= last; i++) { |
|
347 | 355 | QPointF point; |
|
348 | point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble()); | |
|
349 | point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); | |
|
350 | m_series->insert(i - m_first, point); | |
|
356 | QModelIndex xIndex = xModelIndex(i - m_first); | |
|
357 | QModelIndex yIndex = yModelIndex(i - m_first); | |
|
358 | if (xIndex.isValid() && yIndex.isValid()) { | |
|
359 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); | |
|
360 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); | |
|
361 | m_series->insert(i - m_first, point); | |
|
362 | } | |
|
351 | 363 | } |
|
352 | 364 | |
|
353 | 365 | // remove excess of slices (abouve m_count) |
@@ -385,9 +397,13 void QXYModelMapperPrivate::removeData(int start, int end) | |||
|
385 | 397 | if (toBeAdded > 0) |
|
386 | 398 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { |
|
387 | 399 | QPointF point; |
|
388 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); | |
|
389 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); | |
|
390 | m_series->insert(i, point); | |
|
400 | QModelIndex xIndex = xModelIndex(i); | |
|
401 | QModelIndex yIndex = yModelIndex(i); | |
|
402 | if (xIndex.isValid() && yIndex.isValid()) { | |
|
403 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); | |
|
404 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); | |
|
405 | m_series->insert(i, point); | |
|
406 | } | |
|
391 | 407 | } |
|
392 | 408 | } |
|
393 | 409 | } |
@@ -30,7 +30,7 CustomTableModel::CustomTableModel(QObject *parent) : | |||
|
30 | 30 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
31 | 31 | |
|
32 | 32 | m_columnCount = 7; |
|
33 | m_rowCount = 9; | |
|
33 | m_rowCount = 1029; | |
|
34 | 34 | |
|
35 | 35 | m_labels.append("Apples"); |
|
36 | 36 | m_labels.append("Oranges"); |
@@ -67,7 +67,7 int CustomTableModel::rowCount(const QModelIndex & parent) const | |||
|
67 | 67 | int CustomTableModel::columnCount(const QModelIndex & parent) const |
|
68 | 68 | { |
|
69 | 69 | Q_UNUSED(parent) |
|
70 |
return m_columnCount |
|
|
70 | return m_columnCount;// + 1; | |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | QVariant CustomTableModel::headerData (int section, Qt::Orientation orientation, int role ) const |
@@ -102,8 +102,8 QVariant CustomTableModel::data(const QModelIndex & index, int role) const | |||
|
102 | 102 | { |
|
103 | 103 | switch(index.column()) |
|
104 | 104 | { |
|
105 | case 7: | |
|
106 | return m_labels[index.row()]; | |
|
105 | // case 7: | |
|
106 | // return m_labels[index.row()]; | |
|
107 | 107 | default: |
|
108 | 108 | return m_data[index.row()]->at(index.column()); |
|
109 | 109 | break; |
@@ -113,8 +113,8 QVariant CustomTableModel::data(const QModelIndex & index, int role) const | |||
|
113 | 113 | { |
|
114 | 114 | switch(index.column()) |
|
115 | 115 | { |
|
116 | case 7: | |
|
117 | return m_labels[index.row()]; | |
|
116 | // case 7: | |
|
117 | // return m_labels[index.row()]; | |
|
118 | 118 | default: |
|
119 | 119 | return m_data[index.row()]->at(index.column()); |
|
120 | 120 | break; |
@@ -236,27 +236,27 void TableWidget::updateChartType(bool toggle) | |||
|
236 | 236 | |
|
237 | 237 | if (m_lineRadioButton->isChecked()) |
|
238 | 238 | { |
|
239 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
239 | // m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
240 | 240 | |
|
241 | 241 | // series 1 |
|
242 | 242 | m_series = new QLineSeries; |
|
243 | 243 | |
|
244 | m_mapper = new QHXYModelMapper; | |
|
245 | m_mapper->setModel(m_model); | |
|
246 | m_mapper->setSeries(m_series); | |
|
247 | m_mapper->setXRow(0); | |
|
248 | m_mapper->setYRow(1); | |
|
249 | m_mapper->setFirst(3); | |
|
250 | m_mapper->setCount(4); | |
|
251 | ||
|
252 | // m_mapper = new QVXYModelMapper; | |
|
244 | // m_mapper = new QHXYModelMapper; | |
|
253 | 245 | // m_mapper->setModel(m_model); |
|
254 | 246 | // m_mapper->setSeries(m_series); |
|
255 |
// m_mapper->setX |
|
|
256 |
// m_mapper->setY |
|
|
247 | // m_mapper->setXRow(0); | |
|
248 | // m_mapper->setYRow(1); | |
|
257 | 249 | // m_mapper->setFirst(3); |
|
258 | 250 | // m_mapper->setCount(4); |
|
259 | 251 | |
|
252 | m_mapper = new QVXYModelMapper; | |
|
253 | m_mapper->setModel(m_model); | |
|
254 | m_mapper->setSeries(m_series); | |
|
255 | m_mapper->setXColumn(0); | |
|
256 | m_mapper->setYColumn(1); | |
|
257 | m_mapper->setFirst(3); | |
|
258 | // m_mapper->setCount(4); | |
|
259 | ||
|
260 | 260 | // m_series->setModelMapping(0,1, Qt::Vertical); |
|
261 | 261 | // m_series->setModelMappingRange(3, 4); |
|
262 | 262 | m_chart->addSeries(m_series); |
@@ -505,8 +505,8 void TableWidget::updateChartType(bool toggle) | |||
|
505 | 505 | |
|
506 | 506 | |
|
507 | 507 | if (!m_barRadioButton->isChecked()) { |
|
508 | m_chart->axisX()->setRange(0, 500); | |
|
509 | m_chart->axisY()->setRange(0, 220); | |
|
508 | // m_chart->axisX()->setRange(0, 500); | |
|
509 | // m_chart->axisY()->setRange(0, 220); | |
|
510 | 510 | } |
|
511 | 511 | m_chart->legend()->setVisible(true); |
|
512 | 512 |
General Comments 0
You need to be logged in to leave comments.
Login now