diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-07-12 13:22:28 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-07-12 13:49:21 +0300 |
commit | 260593c8c54c1130a513bbf85b053292ae5ea4c7 (patch) | |
tree | 063c14d183dac2016548fdc5c39e35e1778c9096 /examples/spectrum/spectrumapp/main.cpp | |
parent | 308b3c4754f0d3231a9b5a3adbafb1b477d5a858 (diff) |
Bring new data proxies to maps
Maps now has the basic QMapDataProxy and the specialized
QItemModelMapDataProxy to choose from.
Removed the last vestiges of old QDataSet and related classes.
Bunch of misc fixes also included.
Change-Id: I3993ac2a669b818f89bd771ea9dc8b7e458c4b8c
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'examples/spectrum/spectrumapp/main.cpp')
-rw-r--r-- | examples/spectrum/spectrumapp/main.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/examples/spectrum/spectrumapp/main.cpp b/examples/spectrum/spectrumapp/main.cpp index 2fa0be8f..11f89bc3 100644 --- a/examples/spectrum/spectrumapp/main.cpp +++ b/examples/spectrum/spectrumapp/main.cpp @@ -41,7 +41,7 @@ #include "q3dbars.h" #include "engine.h" #include "utils.h" -#include "qolddataproxy.h" +#include "qbardataproxy.h" #include <QGuiApplication> #include <QAudio> @@ -120,7 +120,7 @@ MainApp::MainApp(Q3DBars *window) m_restartTimer->setSingleShot(true); QObject::connect(m_restartTimer, &QTimer::timeout, this, &MainApp::restart); - QOldDataProxy *proxy = new QOldDataProxy; + QBarDataProxy *proxy = new QBarDataProxy; m_chart->setDataProxy(proxy); } @@ -145,22 +145,20 @@ void MainApp::spectrumChanged(qint64 position, qint64 length, const FrequencySpe Q_UNUSED(position); Q_UNUSED(length); //qDebug() << "updating bar values" << position << length; - QVector<float> data; + QBarDataRow *data = new QBarDataRow(SpectrumNumBands); for (int bar = 0; bar < SpectrumNumBands; bar++) { // init data set - data.append(0.0f); + (*data)[bar].setValue(qreal(0.0)); } FrequencySpectrum::const_iterator i = spectrum.begin(); const FrequencySpectrum::const_iterator end = spectrum.end(); for ( ; i != end; ++i) { const FrequencySpectrum::Element e = *i; if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) { - data.replace(barIndex(e.frequency) - , qMax(data.at(barIndex(e.frequency)), (float)e.amplitude)); + (*data)[barIndex(e.frequency)].setValue(qMax(data->at(barIndex(e.frequency)).value(), qreal(e.amplitude))); } } - if (data.size() > 0) - static_cast<QOldDataProxy *>(m_chart->dataProxy())->addDataRow(data); + static_cast<QBarDataProxy *>(m_chart->dataProxy())->insertRow(0, data); } void MainApp::stateChanged(QAudio::Mode mode, QAudio::State state) |