From 77bb50de8f3f7defe1329e6c4a6e066d510afc55 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 6 Jul 2020 13:13:05 +0200 Subject: [PATCH] Use QList instead of QVector in qtbase Fixes all other QVector occurrences Task-number: QTBUG-84469 Change-Id: I5f9311298d341a9a3061a6a640539583d1618939 Reviewed-by: Friedemann Kleint --- .../src_concurrent_qtconcurrentfilter.cpp | 22 +++++++------- .../code/src_concurrent_qtconcurrentmap.cpp | 10 +++---- .../doc/src/qtconcurrent-index.qdoc | 4 +-- src/concurrent/qtconcurrentreducekernel.h | 1 - src/sql/kernel/qsqlcachedresult.cpp | 3 +- src/sql/kernel/qsqlindex.h | 2 +- src/sql/kernel/qsqlquery.cpp | 5 ++-- src/sql/kernel/qsqlrecord.cpp | 6 ++-- src/sql/kernel/qsqlresult.cpp | 8 ++--- src/sql/models/qsqlquerymodel_p.h | 2 +- src/testlib/qsignalspy.h | 3 +- src/testlib/qtestcase.cpp | 22 +++++++------- src/testlib/qtestlog.cpp | 6 ++-- src/tools/cmake_automoc_parser/main.cpp | 30 +++++++++---------- src/tools/moc/symbols.h | 8 ++--- src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 9 +++--- src/tools/qlalr/compress.h | 2 +- src/tools/qvkgen/qvkgen.cpp | 2 +- src/tools/tracegen/helpers.h | 2 +- src/tools/tracegen/provider.h | 2 +- src/tools/uic/treewalker.h | 2 +- src/tools/uic/ui4.h | 1 - .../doc/snippets/code/doc_src_layout.cpp | 10 +++---- .../doc/src/widgets-and-layouts/layout.qdoc | 2 +- src/widgets/util/qcolormap.qdoc | 10 +++---- 25 files changed, 84 insertions(+), 90 deletions(-) diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp index ef87a60080..0e0f414b13 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp @@ -184,19 +184,19 @@ QFuture fooString = //! [15] // keep only even integers -QVector vector { 1, 2, 3, 4 }; -QtConcurrent::blockingFilter(vector, [](int n) { return (n & 1) == 0; }); +QList list { 1, 2, 3, 4 }; +QtConcurrent::blockingFilter(list, [](int n) { return (n & 1) == 0; }); // retrieve only even integers -QVector vector2 { 1, 2, 3, 4 }; -QFuture future = QtConcurrent::filtered(vector2, [](int x) { +QList list2 { 1, 2, 3, 4 }; +QFuture future = QtConcurrent::filtered(list2, [](int x) { return (x & 1) == 0; }); -QVector results = future.results(); +QList results = future.results(); // add up all even integers -QVector vector3 { 1, 2, 3, 4 }; -int sum = QtConcurrent::filteredReduced(vector3, +QList list3 { 1, 2, 3, 4 }; +int sum = QtConcurrent::filteredReduced(list3, [](int x) { return (x & 1) == 0; }, @@ -212,8 +212,8 @@ void intSumReduce(int &sum, int x) sum += x; } -QVector vector { 1, 2, 3, 4 }; -int sum = QtConcurrent::filteredReduced(vector, +QList list { 1, 2, 3, 4 }; +int sum = QtConcurrent::filteredReduced(list, [] (int x) { return (x & 1) == 0; }, @@ -227,8 +227,8 @@ bool keepEvenIntegers(int x) return (x & 1) == 0; } -QVector vector { 1, 2, 3, 4 }; -int sum = QtConcurrent::filteredReduced(vector, +QList list { 1, 2, 3, 4 }; +int sum = QtConcurrent::filteredReduced(list, keepEvenIntegers, [](int &sum, int x) { sum += x; diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp index dd3e0103bb..659925a1c6 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp @@ -200,13 +200,13 @@ QFuture thumbnails = QtConcurrent::mapped(images, Scaled(100)); //! [14] //! [15] -QVector vector { 1, 2, 3, 4 }; +QList vector { 1, 2, 3, 4 }; QtConcurrent::blockingMap(vector, [](int &x) { x *= 2; }); int size = 100; -QVector images = ...; +QList images = ...; -QVector thumbnails = QtConcurrent::mapped(images, +QList thumbnails = QtConcurrent::mapped(images, [&size](const QImage &image) { return image.scaled(size, size); } @@ -214,7 +214,7 @@ QVector thumbnails = QtConcurrent::mapped(images, //! [15] //! [16] -QVector collage = QtConcurrent::mappedReduced(images, +QList collage = QtConcurrent::mappedReduced(images, [&size](const QImage &image) { return image.scaled(size, size); }, @@ -223,7 +223,7 @@ QVector collage = QtConcurrent::mappedReduced(images, //! [16] //! [17] -QVector collage = QtConcurrent::mappedReduced(images, +QList collage = QtConcurrent::mappedReduced(images, [&size](const QImage &image) { return image.scaled(size, size); }, diff --git a/src/concurrent/doc/src/qtconcurrent-index.qdoc b/src/concurrent/doc/src/qtconcurrent-index.qdoc index 4338977221..cf4711476c 100644 --- a/src/concurrent/doc/src/qtconcurrent-index.qdoc +++ b/src/concurrent/doc/src/qtconcurrent-index.qdoc @@ -107,7 +107,7 @@ Qt Concurrent supports several STL-compatible container and iterator types, 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: @@ -134,7 +134,7 @@ \li Supported \row \li Random Access Iterator - \li QList, QVector, std::vector + \li QList, std::vector \li Supported and Recommended \endtable diff --git a/src/concurrent/qtconcurrentreducekernel.h b/src/concurrent/qtconcurrentreducekernel.h index de25b19453..694ac2b5a9 100644 --- a/src/concurrent/qtconcurrentreducekernel.h +++ b/src/concurrent/qtconcurrentreducekernel.h @@ -50,7 +50,6 @@ #include #include #include -#include #include diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index 1e76154f82..8f387c6083 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -39,9 +39,8 @@ #include "private/qsqlcachedresult_p.h" -#include #include -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/sql/kernel/qsqlindex.h b/src/sql/kernel/qsqlindex.h index b704cef685..a051b4c118 100644 --- a/src/sql/kernel/qsqlindex.h +++ b/src/sql/kernel/qsqlindex.h @@ -42,8 +42,8 @@ #include #include +#include #include -#include QT_BEGIN_NAMESPACE diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index 1e848f4168..8a3c50ac64 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -41,16 +41,15 @@ //#define QT_DEBUG_SQL +#include "qatomic.h" #include "qdebug.h" #include "qelapsedtimer.h" -#include "qatomic.h" +#include "qmap.h" #include "qsqlrecord.h" #include "qsqlresult.h" #include "qsqldriver.h" #include "qsqldatabase.h" #include "private/qsqlnulldriver_p.h" -#include "qvector.h" -#include "qmap.h" QT_BEGIN_NAMESPACE diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp index 0afeafe416..5f4a4a8ab1 100644 --- a/src/sql/kernel/qsqlrecord.cpp +++ b/src/sql/kernel/qsqlrecord.cpp @@ -39,12 +39,12 @@ #include "qsqlrecord.h" -#include "qdebug.h" -#include "qstringlist.h" #include "qatomic.h" +#include "qdebug.h" +#include "qlist.h" #include "qsqlfield.h" #include "qstring.h" -#include "qvector.h" +#include "qstringlist.h" QT_BEGIN_NAMESPACE diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 067afd9448..f3ab4c10cf 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -39,15 +39,15 @@ #include "qsqlresult.h" -#include "qvariant.h" #include "qhash.h" +#include "qlist.h" +#include "qpointer.h" +#include "qsqldriver.h" #include "qsqlerror.h" #include "qsqlfield.h" #include "qsqlrecord.h" -#include "qvector.h" -#include "qsqldriver.h" -#include "qpointer.h" #include "qsqlresult_p.h" +#include "qvariant.h" #include "private/qsqldriver_p.h" #include diff --git a/src/sql/models/qsqlquerymodel_p.h b/src/sql/models/qsqlquerymodel_p.h index abacd64cde..3772847eb1 100644 --- a/src/sql/models/qsqlquerymodel_p.h +++ b/src/sql/models/qsqlquerymodel_p.h @@ -57,8 +57,8 @@ #include "QtSql/qsqlquery.h" #include "QtSql/qsqlrecord.h" #include "QtCore/qhash.h" +#include "QtCore/qlist.h" #include "QtCore/qvarlengtharray.h" -#include "QtCore/qvector.h" QT_REQUIRE_CONFIG(sqlmodel); diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index a91e3032c8..b514a71a2c 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -44,9 +44,8 @@ #include #include #include -#include -#include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 002709a736..dffbfbe9a3 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -42,23 +42,23 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include #include +#include #include #include diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 51dbc89963..3341c235e6 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -58,9 +58,9 @@ #include #include -#include -#include -#include +#include +#include +#include #if QT_CONFIG(regularexpression) #include #endif diff --git a/src/tools/cmake_automoc_parser/main.cpp b/src/tools/cmake_automoc_parser/main.cpp index 60eb4b2977..7ef57a1d6c 100644 --- a/src/tools/cmake_automoc_parser/main.cpp +++ b/src/tools/cmake_automoc_parser/main.cpp @@ -31,26 +31,26 @@ #include #include +#include +#include +#include +#include +#include #include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE using AutoGenHeaderMap = QMap; -using AutoGenSourcesList = QVector; +using AutoGenSourcesList = QList; static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &sources, QStringList &headerExts, const QString &autoGenInfoJsonPath) @@ -194,7 +194,7 @@ static bool readParseCache(ParseCacheMap &entries, const QString &parseCacheFile return true; } -static bool readJsonFiles(QVector &entries, const QString &filePath) +static bool readJsonFiles(QList &entries, const QString &filePath) { QFile file(filePath); @@ -212,7 +212,7 @@ static bool readJsonFiles(QVector &entries, const QString &filePath) return true; } -static bool writeJsonFiles(const QVector &fileList, const QString &fileListFilePath) +static bool writeJsonFiles(const QList &fileList, const QString &fileListFilePath) { QFile file(fileListFilePath); 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 // moc.json file - QVector jsonFileList; + QList jsonFileList; QDir dir(cmakeIncludeDir); jsonFileList.reserve(autoGenSources.size()); @@ -379,7 +379,7 @@ int main(int argc, char **argv) // Read Previous file list (if any) const QString fileListFilePath = parser.value(outputFileOption); - QVector previousList; + QList previousList; QFile prev_file(fileListFilePath); // Only try to open file if it exists to avoid error messages diff --git a/src/tools/moc/symbols.h b/src/tools/moc/symbols.h index a28cad602f..dfc682f0bf 100644 --- a/src/tools/moc/symbols.h +++ b/src/tools/moc/symbols.h @@ -31,11 +31,11 @@ #define SYMBOLS_H #include "token.h" -#include -#include -#include -#include #include +#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 5d6ee665c7..e48ac6a75e 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -26,14 +26,13 @@ ** ****************************************************************************/ +#include #include -#include -#include +#include #include #include -#include -#include -#include +#include +#include #include #include diff --git a/src/tools/qlalr/compress.h b/src/tools/qlalr/compress.h index e61ba32440..84b804e234 100644 --- a/src/tools/qlalr/compress.h +++ b/src/tools/qlalr/compress.h @@ -29,7 +29,7 @@ #ifndef COMPRESS_H #define COMPRESS_H -#include +#include class Compress { diff --git a/src/tools/qvkgen/qvkgen.cpp b/src/tools/qvkgen/qvkgen.cpp index 74137c8a63..efbe54e0a5 100644 --- a/src/tools/qvkgen/qvkgen.cpp +++ b/src/tools/qvkgen/qvkgen.cpp @@ -27,9 +27,9 @@ ****************************************************************************/ #include -#include #include #include +#include #include class VkSpecParser diff --git a/src/tools/tracegen/helpers.h b/src/tools/tracegen/helpers.h index d55a956834..8acf6e2292 100644 --- a/src/tools/tracegen/helpers.h +++ b/src/tools/tracegen/helpers.h @@ -42,7 +42,7 @@ #include "provider.h" -#include +#include #include enum ParamType { diff --git a/src/tools/tracegen/provider.h b/src/tools/tracegen/provider.h index b9ebc2ec5a..a62522adc7 100644 --- a/src/tools/tracegen/provider.h +++ b/src/tools/tracegen/provider.h @@ -40,7 +40,7 @@ #ifndef PROVIDER_H #define PROVIDER_H -#include +#include #include #include #include diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h index 05b5dbf9fc..abc5658924 100644 --- a/src/tools/uic/treewalker.h +++ b/src/tools/uic/treewalker.h @@ -29,7 +29,7 @@ #ifndef TREEWALKER_H #define TREEWALKER_H -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 3e0e09a4e0..a5ac51f521 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -45,7 +45,6 @@ #include #include #include -#include #include #include diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp index 7bbd781bb2..3cf5ffbef4 100644 --- a/src/widgets/doc/snippets/code/doc_src_layout.cpp +++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp @@ -53,7 +53,7 @@ #define CARD_H #include -#include +#include class CardLayout : public QLayout { @@ -73,7 +73,7 @@ public: void setGeometry(const QRect &rect) override; private: - QVector m_items; + QList m_items; }; #endif //! [0] @@ -86,7 +86,7 @@ private: //! [2] 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(); } //! [2] @@ -94,14 +94,14 @@ int CardLayout::count() const //! [3] 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 return m_items.value(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; } //! [3] diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc index 24f8cd836f..c72c3e8c68 100644 --- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc @@ -299,7 +299,7 @@ \list \li A data structure to store the items handled by the layout. Each 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::}{setGeometry()}, how to perform the layout. \li \l{QLayout::}{sizeHint()}, the preferred size of the layout. diff --git a/src/widgets/util/qcolormap.qdoc b/src/widgets/util/qcolormap.qdoc index 2e1c7c504b..d262fcc9cb 100644 --- a/src/widgets/util/qcolormap.qdoc +++ b/src/widgets/util/qcolormap.qdoc @@ -42,11 +42,11 @@ \value Direct Pixel values are derived directly from the RGB 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 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 tone that most closely matches the computed gray tone of an RGB value. @@ -113,11 +113,11 @@ */ /*! - \fn const QVector QColormap::colormap() const + \fn const QList 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 - vector for \c Direct mode. + list for \c Direct mode. \sa size() */