Use QList instead of QVector in qtbase

Fixes all other QVector occurrences

Task-number: QTBUG-84469
Change-Id: I5f9311298d341a9a3061a6a640539583d1618939
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Jarek Kobus 2020-07-06 13:13:05 +02:00
parent 989fca660c
commit 77bb50de8f
25 changed files with 84 additions and 90 deletions

View File

@ -184,19 +184,19 @@ QFuture<QString> fooString =
//! [15] //! [15]
// keep only even integers // keep only even integers
QVector<int> vector { 1, 2, 3, 4 }; QList<int> list { 1, 2, 3, 4 };
QtConcurrent::blockingFilter(vector, [](int n) { return (n & 1) == 0; }); QtConcurrent::blockingFilter(list, [](int n) { return (n & 1) == 0; });
// retrieve only even integers // retrieve only even integers
QVector<int> vector2 { 1, 2, 3, 4 }; QList<int> list2 { 1, 2, 3, 4 };
QFuture<int> future = QtConcurrent::filtered(vector2, [](int x) { QFuture<int> future = QtConcurrent::filtered(list2, [](int x) {
return (x & 1) == 0; return (x & 1) == 0;
}); });
QVector<int> results = future.results(); QList<int> results = future.results();
// add up all even integers // add up all even integers
QVector<int> vector3 { 1, 2, 3, 4 }; QList<int> list3 { 1, 2, 3, 4 };
int sum = QtConcurrent::filteredReduced<int>(vector3, int sum = QtConcurrent::filteredReduced<int>(list3,
[](int x) { [](int x) {
return (x & 1) == 0; return (x & 1) == 0;
}, },
@ -212,8 +212,8 @@ void intSumReduce(int &sum, int x)
sum += x; sum += x;
} }
QVector<int> vector { 1, 2, 3, 4 }; QList<int> list { 1, 2, 3, 4 };
int sum = QtConcurrent::filteredReduced(vector, int sum = QtConcurrent::filteredReduced(list,
[] (int x) { [] (int x) {
return (x & 1) == 0; return (x & 1) == 0;
}, },
@ -227,8 +227,8 @@ bool keepEvenIntegers(int x)
return (x & 1) == 0; return (x & 1) == 0;
} }
QVector<int> vector { 1, 2, 3, 4 }; QList<int> list { 1, 2, 3, 4 };
int sum = QtConcurrent::filteredReduced<int>(vector, int sum = QtConcurrent::filteredReduced<int>(list,
keepEvenIntegers, keepEvenIntegers,
[](int &sum, int x) { [](int &sum, int x) {
sum += x; sum += x;

View File

@ -200,13 +200,13 @@ QFuture<QImage> thumbnails = QtConcurrent::mapped(images, Scaled(100));
//! [14] //! [14]
//! [15] //! [15]
QVector<int> vector { 1, 2, 3, 4 }; QList<int> vector { 1, 2, 3, 4 };
QtConcurrent::blockingMap(vector, [](int &x) { x *= 2; }); QtConcurrent::blockingMap(vector, [](int &x) { x *= 2; });
int size = 100; int size = 100;
QVector<QImage> images = ...; QList<QImage> images = ...;
QVector<QImage> thumbnails = QtConcurrent::mapped(images, QList<QImage> thumbnails = QtConcurrent::mapped(images,
[&size](const QImage &image) { [&size](const QImage &image) {
return image.scaled(size, size); return image.scaled(size, size);
} }
@ -214,7 +214,7 @@ QVector<QImage> thumbnails = QtConcurrent::mapped(images,
//! [15] //! [15]
//! [16] //! [16]
QVector<QImage> collage = QtConcurrent::mappedReduced(images, QList<QImage> collage = QtConcurrent::mappedReduced(images,
[&size](const QImage &image) { [&size](const QImage &image) {
return image.scaled(size, size); return image.scaled(size, size);
}, },
@ -223,7 +223,7 @@ QVector<QImage> collage = QtConcurrent::mappedReduced(images,
//! [16] //! [16]
//! [17] //! [17]
QVector<QImage> collage = QtConcurrent::mappedReduced<QImage>(images, QList<QImage> collage = QtConcurrent::mappedReduced<QImage>(images,
[&size](const QImage &image) { [&size](const QImage &image) {
return image.scaled(size, size); return image.scaled(size, size);
}, },

View File

@ -107,7 +107,7 @@
Qt Concurrent supports several STL-compatible container and iterator types, Qt Concurrent supports several STL-compatible container and iterator types,
but works best with Qt containers that have random-access iterators, such as but works best with Qt containers that have random-access iterators, such as
QList or QVector. The map and filter functions accept both containers and begin/end iterators. QList. The map and filter functions accept both containers and begin/end iterators.
STL Iterator support overview: STL Iterator support overview:
@ -134,7 +134,7 @@
\li Supported \li Supported
\row \row
\li Random Access Iterator \li Random Access Iterator
\li QList, QVector, std::vector \li QList, std::vector
\li Supported and Recommended \li Supported and Recommended
\endtable \endtable

View File

@ -50,7 +50,6 @@
#include <QtCore/qmutex.h> #include <QtCore/qmutex.h>
#include <QtCore/qthread.h> #include <QtCore/qthread.h>
#include <QtCore/qthreadpool.h> #include <QtCore/qthreadpool.h>
#include <QtCore/qvector.h>
#include <mutex> #include <mutex>

View File

@ -39,9 +39,8 @@
#include "private/qsqlcachedresult_p.h" #include "private/qsqlcachedresult_p.h"
#include <qvariant.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <qvector.h> #include <qvariant.h>
#include <QtSql/private/qsqldriver_p.h> #include <QtSql/private/qsqldriver_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -42,8 +42,8 @@
#include <QtSql/qtsqlglobal.h> #include <QtSql/qtsqlglobal.h>
#include <QtSql/qsqlrecord.h> #include <QtSql/qsqlrecord.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qvector.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -41,16 +41,15 @@
//#define QT_DEBUG_SQL //#define QT_DEBUG_SQL
#include "qatomic.h"
#include "qdebug.h" #include "qdebug.h"
#include "qelapsedtimer.h" #include "qelapsedtimer.h"
#include "qatomic.h" #include "qmap.h"
#include "qsqlrecord.h" #include "qsqlrecord.h"
#include "qsqlresult.h" #include "qsqlresult.h"
#include "qsqldriver.h" #include "qsqldriver.h"
#include "qsqldatabase.h" #include "qsqldatabase.h"
#include "private/qsqlnulldriver_p.h" #include "private/qsqlnulldriver_p.h"
#include "qvector.h"
#include "qmap.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -39,12 +39,12 @@
#include "qsqlrecord.h" #include "qsqlrecord.h"
#include "qdebug.h"
#include "qstringlist.h"
#include "qatomic.h" #include "qatomic.h"
#include "qdebug.h"
#include "qlist.h"
#include "qsqlfield.h" #include "qsqlfield.h"
#include "qstring.h" #include "qstring.h"
#include "qvector.h" #include "qstringlist.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -39,15 +39,15 @@
#include "qsqlresult.h" #include "qsqlresult.h"
#include "qvariant.h"
#include "qhash.h" #include "qhash.h"
#include "qlist.h"
#include "qpointer.h"
#include "qsqldriver.h"
#include "qsqlerror.h" #include "qsqlerror.h"
#include "qsqlfield.h" #include "qsqlfield.h"
#include "qsqlrecord.h" #include "qsqlrecord.h"
#include "qvector.h"
#include "qsqldriver.h"
#include "qpointer.h"
#include "qsqlresult_p.h" #include "qsqlresult_p.h"
#include "qvariant.h"
#include "private/qsqldriver_p.h" #include "private/qsqldriver_p.h"
#include <QDebug> #include <QDebug>

View File

@ -57,8 +57,8 @@
#include "QtSql/qsqlquery.h" #include "QtSql/qsqlquery.h"
#include "QtSql/qsqlrecord.h" #include "QtSql/qsqlrecord.h"
#include "QtCore/qhash.h" #include "QtCore/qhash.h"
#include "QtCore/qlist.h"
#include "QtCore/qvarlengtharray.h" #include "QtCore/qvarlengtharray.h"
#include "QtCore/qvector.h"
QT_REQUIRE_CONFIG(sqlmodel); QT_REQUIRE_CONFIG(sqlmodel);

View File

@ -44,9 +44,8 @@
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qmetaobject.h> #include <QtCore/qmetaobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
#include <QtTest/qtesteventloop.h> #include <QtTest/qtesteventloop.h>
#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -42,23 +42,23 @@
#include <QtTest/qtestassert.h> #include <QtTest/qtestassert.h>
#include <QtCore/qbytearray.h> #include <QtCore/qbytearray.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qdiriterator.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qfloat16.h>
#include <QtCore/qlibraryinfo.h>
#include <QtCore/qlist.h>
#include <QtCore/qmetaobject.h> #include <QtCore/qmetaobject.h>
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qstringlist.h> #include <QtCore/qstringlist.h>
#include <QtCore/qvector.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
#include <QtCore/qdebug.h>
#include <QtCore/qfloat16.h>
#include <QtCore/qlibraryinfo.h>
#include <QtCore/private/qtools_p.h>
#include <QtCore/qdiriterator.h>
#include <QtCore/qtemporarydir.h> #include <QtCore/qtemporarydir.h>
#include <QtCore/qthread.h> #include <QtCore/qthread.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/private/qlocking_p.h> #include <QtCore/private/qlocking_p.h>
#include <QtCore/private/qtools_p.h>
#include <QtCore/private/qwaitcondition_p.h> #include <QtCore/private/qwaitcondition_p.h>
#include <QtCore/qtestsupport_core.h> #include <QtCore/qtestsupport_core.h>

View File

@ -58,9 +58,9 @@
#include <QtCore/qatomic.h> #include <QtCore/qatomic.h>
#include <QtCore/qbytearray.h> #include <QtCore/qbytearray.h>
#include <QtCore/QElapsedTimer> #include <QtCore/qelapsedtimer.h>
#include <QtCore/QVariant> #include <QtCore/qlist.h>
#include <QtCore/qvector.h> #include <QtCore/qvariant.h>
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
#include <QtCore/QRegularExpression> #include <QtCore/QRegularExpression>
#endif #endif

View File

@ -31,26 +31,26 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <qcommandlineoption.h>
#include <qcommandlineparser.h>
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qdir.h>
#include <qfile.h> #include <qfile.h>
#include <qhash.h>
#include <qjsonarray.h> #include <qjsonarray.h>
#include <qjsondocument.h> #include <qjsondocument.h>
#include <qjsonobject.h> #include <qjsonobject.h>
#include <qdir.h> #include <qlist.h>
#include <qstring.h>
#include <qhash.h>
#include <qvector.h>
#include <qstack.h>
#include <qdebug.h>
#include <qset.h>
#include <qmap.h> #include <qmap.h>
#include <qcoreapplication.h> #include <qset.h>
#include <qcommandlineoption.h> #include <qstring.h>
#include <qcommandlineparser.h> #include <qstack.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using AutoGenHeaderMap = QMap<QString, QString>; using AutoGenHeaderMap = QMap<QString, QString>;
using AutoGenSourcesList = QVector<QString>; using AutoGenSourcesList = QList<QString>;
static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &sources, static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &sources,
QStringList &headerExts, const QString &autoGenInfoJsonPath) QStringList &headerExts, const QString &autoGenInfoJsonPath)
@ -194,7 +194,7 @@ static bool readParseCache(ParseCacheMap &entries, const QString &parseCacheFile
return true; return true;
} }
static bool readJsonFiles(QVector<QString> &entries, const QString &filePath) static bool readJsonFiles(QList<QString> &entries, const QString &filePath)
{ {
QFile file(filePath); QFile file(filePath);
@ -212,7 +212,7 @@ static bool readJsonFiles(QVector<QString> &entries, const QString &filePath)
return true; return true;
} }
static bool writeJsonFiles(const QVector<QString> &fileList, const QString &fileListFilePath) static bool writeJsonFiles(const QList<QString> &fileList, const QString &fileListFilePath)
{ {
QFile file(fileListFilePath); QFile file(fileListFilePath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
@ -308,7 +308,7 @@ int main(int argc, char **argv)
// entry for it in the parse cache. Use the value for the location of the // entry for it in the parse cache. Use the value for the location of the
// moc.json file // moc.json file
QVector<QString> jsonFileList; QList<QString> jsonFileList;
QDir dir(cmakeIncludeDir); QDir dir(cmakeIncludeDir);
jsonFileList.reserve(autoGenSources.size()); jsonFileList.reserve(autoGenSources.size());
@ -379,7 +379,7 @@ int main(int argc, char **argv)
// Read Previous file list (if any) // Read Previous file list (if any)
const QString fileListFilePath = parser.value(outputFileOption); const QString fileListFilePath = parser.value(outputFileOption);
QVector<QString> previousList; QList<QString> previousList;
QFile prev_file(fileListFilePath); QFile prev_file(fileListFilePath);
// Only try to open file if it exists to avoid error messages // Only try to open file if it exists to avoid error messages

View File

@ -31,11 +31,11 @@
#define SYMBOLS_H #define SYMBOLS_H
#include "token.h" #include "token.h"
#include <qstring.h>
#include <qhash.h>
#include <qvector.h>
#include <qstack.h>
#include <qdebug.h> #include <qdebug.h>
#include <qhash.h>
#include <qlist.h>
#include <qstack.h>
#include <qstring.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -26,14 +26,13 @@
** **
****************************************************************************/ ****************************************************************************/
#include <qbuffer.h>
#include <qbytearray.h> #include <qbytearray.h>
#include <qstring.h> #include <qdebug.h>
#include <qvarlengtharray.h>
#include <qfile.h> #include <qfile.h>
#include <qlist.h> #include <qlist.h>
#include <qbuffer.h> #include <qstring.h>
#include <qvector.h> #include <qvarlengtharray.h>
#include <qdebug.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -29,7 +29,7 @@
#ifndef COMPRESS_H #ifndef COMPRESS_H
#define COMPRESS_H #define COMPRESS_H
#include <QtCore/qvector.h> #include <QtCore/qlist.h>
class Compress class Compress
{ {

View File

@ -27,9 +27,9 @@
****************************************************************************/ ****************************************************************************/
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include <QtCore/qvector.h>
#include <QtCore/qfile.h> #include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h> #include <QtCore/qfileinfo.h>
#include <QtCore/qlist.h>
#include <QtCore/qxmlstream.h> #include <QtCore/qxmlstream.h>
class VkSpecParser class VkSpecParser

View File

@ -42,7 +42,7 @@
#include "provider.h" #include "provider.h"
#include <qvector.h> #include <qlist.h>
#include <qstring.h> #include <qstring.h>
enum ParamType { enum ParamType {

View File

@ -40,7 +40,7 @@
#ifndef PROVIDER_H #ifndef PROVIDER_H
#define PROVIDER_H #define PROVIDER_H
#include <qvector.h> #include <qlist.h>
#include <qstring.h> #include <qstring.h>
#include <qstringlist.h> #include <qstringlist.h>
#include <qtypeinfo.h> #include <qtypeinfo.h>

View File

@ -29,7 +29,7 @@
#ifndef TREEWALKER_H #ifndef TREEWALKER_H
#define TREEWALKER_H #define TREEWALKER_H
#include <qvector.h> #include <qlist.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -45,7 +45,6 @@
#include <qlist.h> #include <qlist.h>
#include <qstring.h> #include <qstring.h>
#include <qstringlist.h> #include <qstringlist.h>
#include <qvector.h>
#include <qxmlstream.h> #include <qxmlstream.h>
#include <qglobal.h> #include <qglobal.h>

View File

@ -53,7 +53,7 @@
#define CARD_H #define CARD_H
#include <QtWidgets> #include <QtWidgets>
#include <QVector> #include <QList>
class CardLayout : public QLayout class CardLayout : public QLayout
{ {
@ -73,7 +73,7 @@ public:
void setGeometry(const QRect &rect) override; void setGeometry(const QRect &rect) override;
private: private:
QVector<QLayoutItem*> m_items; QList<QLayoutItem *> m_items;
}; };
#endif #endif
//! [0] //! [0]
@ -86,7 +86,7 @@ private:
//! [2] //! [2]
int CardLayout::count() const int CardLayout::count() const
{ {
// QVector::size() returns the number of QLayoutItems in m_items // QList::size() returns the number of QLayoutItems in m_items
return m_items.size(); return m_items.size();
} }
//! [2] //! [2]
@ -94,14 +94,14 @@ int CardLayout::count() const
//! [3] //! [3]
QLayoutItem *CardLayout::itemAt(int idx) const QLayoutItem *CardLayout::itemAt(int idx) const
{ {
// QVector::value() performs index checking, and returns nullptr if we are // QList::value() performs index checking, and returns nullptr if we are
// outside the valid range // outside the valid range
return m_items.value(idx); return m_items.value(idx);
} }
QLayoutItem *CardLayout::takeAt(int idx) QLayoutItem *CardLayout::takeAt(int idx)
{ {
// QVector::take does not do index checking // QList::take does not do index checking
return idx >= 0 && idx < m_items.size() ? m_items.takeAt(idx) : 0; return idx >= 0 && idx < m_items.size() ? m_items.takeAt(idx) : 0;
} }
//! [3] //! [3]

View File

@ -299,7 +299,7 @@
\list \list
\li A data structure to store the items handled by the layout. Each \li A data structure to store the items handled by the layout. Each
item is a \l{QLayoutItem}{QLayoutItem}. We will use a item is a \l{QLayoutItem}{QLayoutItem}. We will use a
QVector in this example. QList in this example.
\li \l{QLayout::}{addItem()}, how to add items to the layout. \li \l{QLayout::}{addItem()}, how to add items to the layout.
\li \l{QLayout::}{setGeometry()}, how to perform the layout. \li \l{QLayout::}{setGeometry()}, how to perform the layout.
\li \l{QLayout::}{sizeHint()}, the preferred size of the layout. \li \l{QLayout::}{sizeHint()}, the preferred size of the layout.

View File

@ -42,11 +42,11 @@
\value Direct Pixel values are derived directly from the RGB \value Direct Pixel values are derived directly from the RGB
values, also known as "True Color." values, also known as "True Color."
\value Indexed Pixel values represent indexes into a vector of \value Indexed Pixel values represent indexes into a list of
available colors, i.e. QColormap uses the index of the color that available colors, i.e. QColormap uses the index of the color that
most closely matches an RGB value. most closely matches an RGB value.
\value Gray Similar to \c Indexed, pixel values represent a vector \value Gray Similar to \c Indexed, pixel values represent a list
of available gray tones. QColormap uses the index of the gray of available gray tones. QColormap uses the index of the gray
tone that most closely matches the computed gray tone of an RGB tone that most closely matches the computed gray tone of an RGB
value. value.
@ -113,11 +113,11 @@
*/ */
/*! /*!
\fn const QVector<QColor> QColormap::colormap() const \fn const QList<QColor> QColormap::colormap() const
Returns a vector of colors which represents the devices colormap Returns a list of colors which represents the devices colormap
for \c Indexed and \c Gray modes. This function returns an empty for \c Indexed and \c Gray modes. This function returns an empty
vector for \c Direct mode. list for \c Direct mode.
\sa size() \sa size()
*/ */