diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-06-24 12:20:29 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-06-25 09:54:13 +0200 |
commit | 1818334beafcf8668b30b8ee63031f871a0c8d03 (patch) | |
tree | 6d04c661a20e392ad3c214f53cf027f95142e863 /examples | |
parent | 2c9a117e49497c55a22621d86d452fa7c22a489b (diff) |
Use QList instead of QVector
Task-number: QTBUG-84469
Change-Id: Id8d07836a66e4d9223341483bfe0ed251ba2806c
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'examples')
11 files changed, 39 insertions, 40 deletions
diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp index 9dd3368e0..4eecae835 100644 --- a/examples/multimedia/audiorecorder/audiorecorder.cpp +++ b/examples/multimedia/audiorecorder/audiorecorder.cpp @@ -61,10 +61,10 @@ #include <QStandardPaths> static qreal getPeakValue(const QAudioFormat &format); -static QVector<qreal> getBufferLevels(const QAudioBuffer &buffer); +static QList<qreal> getBufferLevels(const QAudioBuffer &buffer); -template <class T> -static QVector<qreal> getBufferLevels(const T *buffer, int frames, int channels); +template<class T> +static QList<qreal> getBufferLevels(const T *buffer, int frames, int channels); AudioRecorder::AudioRecorder() : ui(new Ui::AudioRecorder) @@ -287,9 +287,9 @@ qreal getPeakValue(const QAudioFormat& format) } // returns the audio level for each channel -QVector<qreal> getBufferLevels(const QAudioBuffer& buffer) +QList<qreal> getBufferLevels(const QAudioBuffer &buffer) { - QVector<qreal> values; + QList<qreal> values; if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian) return values; @@ -337,10 +337,10 @@ QVector<qreal> getBufferLevels(const QAudioBuffer& buffer) return values; } -template <class T> -QVector<qreal> getBufferLevels(const T *buffer, int frames, int channels) +template<class T> +QList<qreal> getBufferLevels(const T *buffer, int frames, int channels) { - QVector<qreal> max_values; + QList<qreal> max_values; max_values.fill(0, channels); for (int i = 0; i < frames; ++i) { @@ -366,7 +366,7 @@ void AudioRecorder::processBuffer(const QAudioBuffer& buffer) } } - QVector<qreal> levels = getBufferLevels(buffer); + QList<qreal> levels = getBufferLevels(buffer); for (int i = 0; i < levels.count(); ++i) m_audioLevels.at(i)->setLevel(levels.at(i)); } diff --git a/examples/multimedia/spectrum/app/engine.h b/examples/multimedia/spectrum/app/engine.h index ff56d7c8b..714af4d9d 100644 --- a/examples/multimedia/spectrum/app/engine.h +++ b/examples/multimedia/spectrum/app/engine.h @@ -60,8 +60,8 @@ #include <QBuffer> #include <QByteArray> #include <QDir> +#include <QList> #include <QObject> -#include <QVector> #ifdef DUMP_CAPTURED_AUDIO #define DUMP_DATA diff --git a/examples/multimedia/spectrum/app/frequencyspectrum.h b/examples/multimedia/spectrum/app/frequencyspectrum.h index 82206de84..4b13cbb99 100644 --- a/examples/multimedia/spectrum/app/frequencyspectrum.h +++ b/examples/multimedia/spectrum/app/frequencyspectrum.h @@ -51,7 +51,7 @@ #ifndef FREQUENCYSPECTRUM_H #define FREQUENCYSPECTRUM_H -#include <QtCore/QVector> +#include <QtCore/QList> /** * Represents a frequency spectrum as a series of elements, each of which @@ -87,8 +87,8 @@ public: bool clipped; }; - typedef QVector<Element>::iterator iterator; - typedef QVector<Element>::const_iterator const_iterator; + typedef QList<Element>::iterator iterator; + typedef QList<Element>::const_iterator const_iterator; void reset(); @@ -101,8 +101,7 @@ public: const_iterator end() const; private: - QVector<Element> m_elements; - + QList<Element> m_elements; }; #endif // FREQUENCYSPECTRUM_H diff --git a/examples/multimedia/spectrum/app/spectrograph.cpp b/examples/multimedia/spectrum/app/spectrograph.cpp index 7a5305435..04ef51e80 100644 --- a/examples/multimedia/spectrum/app/spectrograph.cpp +++ b/examples/multimedia/spectrum/app/spectrograph.cpp @@ -125,7 +125,7 @@ void Spectrograph::paintEvent(QPaintEvent *event) painter.drawLine(rect().bottomRight(), rect().bottomLeft()); painter.drawLine(rect().bottomLeft(), rect().topLeft()); - QVector<qreal> dashes; + QList<qreal> dashes; dashes << 2 << 2; gridPen.setDashPattern(dashes); painter.setPen(gridPen); diff --git a/examples/multimedia/spectrum/app/spectrograph.h b/examples/multimedia/spectrum/app/spectrograph.h index 0ef6dadd2..0e7b11717 100644 --- a/examples/multimedia/spectrum/app/spectrograph.h +++ b/examples/multimedia/spectrum/app/spectrograph.h @@ -97,7 +97,7 @@ private: bool clipped; }; - QVector<Bar> m_bars; + QList<Bar> m_bars; int m_barSelected; int m_timerId; qreal m_lowFreq; diff --git a/examples/multimedia/spectrum/app/spectrumanalyser.h b/examples/multimedia/spectrum/app/spectrumanalyser.h index ebebfcd9f..799143489 100644 --- a/examples/multimedia/spectrum/app/spectrumanalyser.h +++ b/examples/multimedia/spectrum/app/spectrumanalyser.h @@ -53,7 +53,7 @@ #include <QByteArray> #include <QObject> -#include <QVector> +#include <QList> #ifdef DUMP_SPECTRUMANALYSER #include <QDir> @@ -113,10 +113,10 @@ private: #else typedef FFTRealFixLenParam::DataType DataType; #endif - QVector<DataType> m_window; + QList<DataType> m_window; - QVector<DataType> m_input; - QVector<DataType> m_output; + QList<DataType> m_input; + QList<DataType> m_output; FrequencySpectrum m_spectrum; diff --git a/examples/multimedia/spectrum/app/waveform.cpp b/examples/multimedia/spectrum/app/waveform.cpp index d0058b2e3..3e7462157 100644 --- a/examples/multimedia/spectrum/app/waveform.cpp +++ b/examples/multimedia/spectrum/app/waveform.cpp @@ -435,7 +435,7 @@ void Waveform::resetTiles(qint64 newStartPos) { WAVEFORM_DEBUG << "Waveform::resetTiles" << "newStartPos" << newStartPos; - QVector<Tile>::iterator i = m_tiles.begin(); + QList<Tile>::iterator i = m_tiles.begin(); for ( ; i != m_tiles.end(); ++i) i->painted = false; diff --git a/examples/multimedia/spectrum/app/waveform.h b/examples/multimedia/spectrum/app/waveform.h index 194681fff..8c26e99b2 100644 --- a/examples/multimedia/spectrum/app/waveform.h +++ b/examples/multimedia/spectrum/app/waveform.h @@ -187,7 +187,7 @@ private: bool m_active; QSize m_pixmapSize; - QVector<QPixmap*> m_pixmaps; + QList<QPixmap*> m_pixmaps; struct Tile { // Pointer into parent m_pixmaps array @@ -197,7 +197,7 @@ private: bool painted; }; - QVector<Tile> m_tiles; + QList<Tile> m_tiles; // Length of audio data in bytes depicted by each tile qint64 m_tileLength; diff --git a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp index cf2fcbd7b..255c0b61b 100644 --- a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp +++ b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp @@ -157,7 +157,7 @@ CLFilterRunnable::CLFilterRunnable(CLFilter *filter) : qWarning("No OpenCL platform found"); return; } - QVector<cl_platform_id> platformIds; + QList<cl_platform_id> platformIds; platformIds.resize(n); if (clGetPlatformIDs(n, platformIds.data(), 0) != CL_SUCCESS) { qWarning("Failed to get platform IDs"); diff --git a/examples/multimediawidgets/player/histogramwidget.cpp b/examples/multimediawidgets/player/histogramwidget.cpp index a0de8516a..bb214cad5 100644 --- a/examples/multimediawidgets/player/histogramwidget.cpp +++ b/examples/multimediawidgets/player/histogramwidget.cpp @@ -52,8 +52,8 @@ #include <QPainter> #include <QHBoxLayout> -template <class T> -static QVector<qreal> getBufferLevels(const T *buffer, int frames, int channels); +template<class T> +static QList<qreal> getBufferLevels(const T *buffer, int frames, int channels); class QAudioLevel : public QWidget { @@ -102,7 +102,7 @@ HistogramWidget::HistogramWidget(QWidget *parent) : QWidget(parent) { m_processor.moveToThread(&m_processorThread); - qRegisterMetaType<QVector<qreal>>("QVector<qreal>"); + qRegisterMetaType<QList<qreal>>("QList<qreal>"); connect(&m_processor, &FrameProcessor::histogramReady, this, &HistogramWidget::setHistogram); m_processorThread.start(QThread::LowestPriority); setLayout(new QHBoxLayout); @@ -163,9 +163,9 @@ qreal getPeakValue(const QAudioFormat& format) } // returns the audio level for each channel -QVector<qreal> getBufferLevels(const QAudioBuffer& buffer) +QList<qreal> getBufferLevels(const QAudioBuffer &buffer) { - QVector<qreal> values; + QList<qreal> values; if (!buffer.isValid()) return values; @@ -216,10 +216,10 @@ QVector<qreal> getBufferLevels(const QAudioBuffer& buffer) return values; } -template <class T> -QVector<qreal> getBufferLevels(const T *buffer, int frames, int channels) +template<class T> +QList<qreal> getBufferLevels(const T *buffer, int frames, int channels) { - QVector<qreal> max_values; + QList<qreal> max_values; max_values.fill(0, channels); for (int i = 0; i < frames; ++i) { @@ -245,12 +245,12 @@ void HistogramWidget::processBuffer(const QAudioBuffer &buffer) } } - QVector<qreal> levels = getBufferLevels(buffer); + QList<qreal> levels = getBufferLevels(buffer); for (int i = 0; i < levels.count(); ++i) m_audioLevels.at(i)->setLevel(levels.at(i)); } -void HistogramWidget::setHistogram(const QVector<qreal> &histogram) +void HistogramWidget::setHistogram(const QList<qreal> &histogram) { m_isBusy = false; m_histogram = histogram; @@ -284,7 +284,7 @@ void HistogramWidget::paintEvent(QPaintEvent *event) void FrameProcessor::processFrame(QVideoFrame frame, int levels) { - QVector<qreal> histogram(levels); + QList<qreal> histogram(levels); do { if (!levels) diff --git a/examples/multimediawidgets/player/histogramwidget.h b/examples/multimediawidgets/player/histogramwidget.h index a5c697dfb..08ba4f342 100644 --- a/examples/multimediawidgets/player/histogramwidget.h +++ b/examples/multimediawidgets/player/histogramwidget.h @@ -66,7 +66,7 @@ public slots: void processFrame(QVideoFrame frame, int levels); signals: - void histogramReady(const QVector<qreal> &histogram); + void histogramReady(const QList<qreal> &histogram); }; class HistogramWidget : public QWidget @@ -81,18 +81,18 @@ public: public slots: void processFrame(const QVideoFrame &frame); void processBuffer(const QAudioBuffer &buffer); - void setHistogram(const QVector<qreal> &histogram); + void setHistogram(const QList<qreal> &histogram); protected: void paintEvent(QPaintEvent *event) override; private: - QVector<qreal> m_histogram; + QList<qreal> m_histogram; int m_levels = 128; FrameProcessor m_processor; QThread m_processorThread; bool m_isBusy = false; - QVector<QAudioLevel *> m_audioLevels; + QList<QAudioLevel *> m_audioLevels; }; #endif // HISTOGRAMWIDGET_H |