@@ -41,16 +41,16 DataSource::DataSource(QDeclarativeView *appViewer, QObject *parent) : | |||||
41 |
|
41 | |||
42 | void DataSource::update(QAbstractSeries *series) |
|
42 | void DataSource::update(QAbstractSeries *series) | |
43 | { |
|
43 | { | |
44 | QXYSeries *xySeries = qobject_cast<QXYSeries *>(series); |
|
44 | if (series) { | |
45 | Q_ASSERT(xySeries); |
|
45 | QXYSeries *xySeries = static_cast<QXYSeries *>(series); | |
|
46 | m_index++; | |||
|
47 | if (m_index > m_data.count() - 1) | |||
|
48 | m_index = 0; | |||
46 |
|
49 | |||
47 | m_index++; |
|
50 | QList<QPointF> points = m_data.at(m_index); | |
48 | if (m_index > m_data.count() - 1) |
|
51 | // Use replace instead of clear + append, it's optimized for performance | |
49 | m_index = 0; |
|
52 | xySeries->replace(points); | |
50 |
|
53 | } | ||
51 | QList<QPointF> points = m_data.at(m_index); |
|
|||
52 | // Use replace instead of clear + append, it's optimized for performance |
|
|||
53 | xySeries->replace(points); |
|
|||
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | void DataSource::generateData(int type, int rowCount, int colCount) |
|
56 | void DataSource::generateData(int type, int rowCount, int colCount) |
@@ -42,16 +42,16 DataSource::DataSource(QQuickView *appViewer, QObject *parent) : | |||||
42 |
|
42 | |||
43 | void DataSource::update(QAbstractSeries *series) |
|
43 | void DataSource::update(QAbstractSeries *series) | |
44 | { |
|
44 | { | |
45 | QXYSeries *xySeries = qobject_cast<QXYSeries *>(series); |
|
45 | if (series) { | |
46 | Q_ASSERT(xySeries); |
|
46 | QXYSeries *xySeries = static_cast<QXYSeries *>(series); | |
|
47 | m_index++; | |||
|
48 | if (m_index > m_data.count() - 1) | |||
|
49 | m_index = 0; | |||
47 |
|
50 | |||
48 | m_index++; |
|
51 | QList<QPointF> points = m_data.at(m_index); | |
49 | if (m_index > m_data.count() - 1) |
|
52 | // Use replace instead of clear + append, it's optimized for performance | |
50 | m_index = 0; |
|
53 | xySeries->replace(points); | |
51 |
|
54 | } | ||
52 | QList<QPointF> points = m_data.at(m_index); |
|
|||
53 | // Use replace instead of clear + append, it's optimized for performance |
|
|||
54 | xySeries->replace(points); |
|
|||
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | void DataSource::generateData(int type, int rowCount, int colCount) |
|
57 | void DataSource::generateData(int type, int rowCount, int colCount) |
General Comments 0
You need to be logged in to leave comments.
Login now