diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-06-22 14:52:01 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-07-02 21:57:06 +0200 |
commit | 2a6cdec718934ca2cc7f6f9c616ebe62f6912123 (patch) | |
tree | c8b9ed8db47912dccd2e8d125d23760936820c29 /src/widgets/kernel | |
parent | d4c04acc65657d29df5b790281a8d1ba896dd868 (diff) |
Use QList instead of QVector in widgets
Task-number: QTBUG-84469
Change-Id: I3007734f8e4f164ece9dd8850ef007cbef9e12ef
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qboxlayout.cpp | 15 | ||||
-rw-r--r-- | src/widgets/kernel/qformlayout.cpp | 12 | ||||
-rw-r--r-- | src/widgets/kernel/qgridlayout.cpp | 47 | ||||
-rw-r--r-- | src/widgets/kernel/qlayoutengine.cpp | 5 | ||||
-rw-r--r-- | src/widgets/kernel/qlayoutengine_p.h | 5 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetrepaintmanager.cpp | 18 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetrepaintmanager_p.h | 6 |
7 files changed, 53 insertions, 55 deletions
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index 7b09adfbf0..a23b89a8a5 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -37,15 +37,14 @@ ** ****************************************************************************/ -#include "qboxlayout.h" #include "qapplication.h" -#include "qwidget.h" +#include "qboxlayout.h" #include "qlist.h" #include "qsizepolicy.h" -#include "qvector.h" +#include "qwidget.h" -#include "qlayoutengine_p.h" #include "qlayout_p.h" +#include "qlayoutengine_p.h" QT_BEGIN_NAMESPACE @@ -104,7 +103,7 @@ public: } QList<QBoxLayoutItem *> list; - QVector<QLayoutStruct> geomArray; + QList<QLayoutStruct> geomArray; int hfwWidth; int hfwHeight; int hfwMinHeight; @@ -271,7 +270,7 @@ void QBoxLayoutPrivate::setupGeom() int n = list.count(); geomArray.clear(); - QVector<QLayoutStruct> a(n); + QList<QLayoutStruct> a(n); QSizePolicy::ControlTypes controlTypes1; QSizePolicy::ControlTypes controlTypes2; @@ -400,7 +399,7 @@ void QBoxLayoutPrivate::setupGeom() */ void QBoxLayoutPrivate::calcHfw(int w) { - QVector<QLayoutStruct> &a = geomArray; + QList<QLayoutStruct> &a = geomArray; int n = a.count(); int h = 0; int mh = 0; @@ -770,7 +769,7 @@ void QBoxLayout::setGeometry(const QRect &r) cr.width() - (left + right), cr.height() - (top + bottom)); - QVector<QLayoutStruct> a = d->geomArray; + QList<QLayoutStruct> a = d->geomArray; int pos = horz(d->dir) ? s.x() : s.y(); int space = horz(d->dir) ? s.width() : s.height(); int n = a.count(); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 4ffa226d7f..ec1e5e4156 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -43,8 +43,8 @@ #include "qlabel.h" #include "qlayout_p.h" #include "qlayoutengine_p.h" +#include "qlist.h" #include "qrect.h" -#include "qvector.h" #include "qwidget.h" QT_BEGIN_NAMESPACE @@ -55,7 +55,7 @@ namespace { template <class T, int NumColumns> class FixedColumnMatrix { public: - typedef QVector<T> Storage; + typedef QList<T> Storage; FixedColumnMatrix() { } @@ -169,7 +169,7 @@ public: void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout); void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget); - void arrangeWidgets(const QVector<QLayoutStruct>& layouts, QRect &rect); + void arrangeWidgets(const QList<QLayoutStruct> &layouts, QRect &rect); void updateSizes(); @@ -215,11 +215,11 @@ public: int formMaxWidth; void calcSizeHints(); - QVector<QLayoutStruct> vLayouts; // set by setupVerticalLayoutData; + QList<QLayoutStruct> vLayouts; // set by setupVerticalLayoutData; int vLayoutCount; // Number of rows we calculated in setupVerticalLayoutData int maxLabelWidth; // the label width we calculated in setupVerticalLayoutData - QVector<QLayoutStruct> hfwLayouts; + QList<QLayoutStruct> hfwLayouts; int hSpacing = -1; int vSpacing = -1; @@ -2167,7 +2167,7 @@ int QFormLayout::spacing() const } } -void QFormLayoutPrivate::arrangeWidgets(const QVector<QLayoutStruct>& layouts, QRect &rect) +void QFormLayoutPrivate::arrangeWidgets(const QList<QLayoutStruct> &layouts, QRect &rect) { Q_Q(QFormLayout); diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index b4ac263c2b..51797b0cf1 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -37,13 +37,13 @@ ** ****************************************************************************/ -#include "qgridlayout.h" #include "qapplication.h" -#include "qwidget.h" +#include "qgridlayout.h" #include "qlist.h" #include "qsizepolicy.h" -#include "qvector.h" #include "qvarlengtharray.h" +#include "qwidget.h" + #include "qlayoutengine_p.h" #include "qlayout_p.h" @@ -204,7 +204,7 @@ private: QSize findSize(int QLayoutStruct::*, int hSpacing, int vSpacing) const; void addData(QGridBox *b, const QGridLayoutSizeTriple &sizes, bool r, bool c); void setSize(int rows, int cols); - void setupSpacings(QVector<QLayoutStruct> &chain, QGridBox *grid[], int fixedSpacing, + void setupSpacings(QList<QLayoutStruct> &chain, QGridBox *grid[], int fixedSpacing, Qt::Orientation orientation); void setupLayoutData(int hSpacing, int vSpacing); void setupHfwLayoutData(); @@ -212,13 +212,13 @@ private: int rr; int cc; - QVector<QLayoutStruct> rowData; - QVector<QLayoutStruct> colData; - QVector<QLayoutStruct> *hfwData; - QVector<int> rStretch; - QVector<int> cStretch; - QVector<int> rMinHeights; - QVector<int> cMinWidths; + QList<QLayoutStruct> rowData; + QList<QLayoutStruct> colData; + QList<QLayoutStruct> *hfwData; + QList<int> rStretch; + QList<int> cStretch; + QList<int> rMinHeights; + QList<int> cMinWidths; QList<QGridBox *> things; int hfw_width; @@ -390,9 +390,9 @@ void QGridLayoutPrivate::recalcHFW(int w) and put the results in hfwData. */ if (!hfwData) - hfwData = new QVector<QLayoutStruct>(rr); + hfwData = new QList<QLayoutStruct>(rr); setupHfwLayoutData(); - QVector<QLayoutStruct> &rData = *hfwData; + QList<QLayoutStruct> &rData = *hfwData; int h = 0; int mh = 0; @@ -615,7 +615,7 @@ void QGridLayoutPrivate::addData(QGridBox *box, const QGridLayoutSizeTriple &siz } } -static void initEmptyMultiBox(QVector<QLayoutStruct> &chain, int start, int end) +static void initEmptyMultiBox(QList<QLayoutStruct> &chain, int start, int end) { for (int i = start; i <= end; i++) { QLayoutStruct *data = &chain[i]; @@ -625,8 +625,8 @@ static void initEmptyMultiBox(QVector<QLayoutStruct> &chain, int start, int end) } } -static void distributeMultiBox(QVector<QLayoutStruct> &chain, int start, int end, int minSize, - int sizeHint, QVector<int> &stretchArray, int stretch) +static void distributeMultiBox(QList<QLayoutStruct> &chain, int start, int end, int minSize, + int sizeHint, QList<int> &stretchArray, int stretch) { int i; int w = 0; @@ -698,9 +698,8 @@ static QGridBox *&gridAt(QGridBox *grid[], int r, int c, int cc, return grid[(r * cc) + c]; } -void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain, - QGridBox *grid[], int fixedSpacing, - Qt::Orientation orientation) +void QGridLayoutPrivate::setupSpacings(QList<QLayoutStruct> &chain, QGridBox *grid[], + int fixedSpacing, Qt::Orientation orientation) { Q_Q(QGridLayout); int numRows = rr; // or columns if orientation is horizontal @@ -868,7 +867,7 @@ void QGridLayoutPrivate::setupLayoutData(int hSpacing, int vSpacing) void QGridLayoutPrivate::addHfwData(QGridBox *box, int width) { - QVector<QLayoutStruct> &rData = *hfwData; + QList<QLayoutStruct> &rData = *hfwData; if (box->hasHeightForWidth()) { int hint = box->heightForWidth(width); rData[box->row].sizeHint = qMax(hint, rData.at(box->row).sizeHint); @@ -888,7 +887,7 @@ void QGridLayoutPrivate::addHfwData(QGridBox *box, int width) */ void QGridLayoutPrivate::setupHfwLayoutData() { - QVector<QLayoutStruct> &rData = *hfwData; + QList<QLayoutStruct> &rData = *hfwData; for (int i = 0; i < rr; i++) { rData[i] = rowData.at(i); rData[i].minimumSize = rData[i].sizeHint = rMinHeights.at(i); @@ -944,7 +943,7 @@ void QGridLayoutPrivate::distribute(QRect r, int hSpacing, int vSpacing) r.adjust(+left, +top, -right, -bottom); qGeomCalc(colData, 0, cc, r.x(), r.width()); - QVector<QLayoutStruct> *rDataPtr; + QList<QLayoutStruct> *rDataPtr; if (has_hfw) { recalcHFW(r.width()); qGeomCalc(*hfwData, 0, rr, r.y(), r.height()); @@ -953,7 +952,7 @@ void QGridLayoutPrivate::distribute(QRect r, int hSpacing, int vSpacing) qGeomCalc(rowData, 0, rr, r.y(), r.height()); rDataPtr = &rowData; } - QVector<QLayoutStruct> &rData = *rDataPtr; + QList<QLayoutStruct> &rData = *rDataPtr; int i; bool reverse = ((r.bottom() > rect.bottom()) || (r.bottom() == rect.bottom() @@ -985,7 +984,7 @@ QRect QGridLayoutPrivate::cellRect(int row, int col) const if (row < 0 || row >= rr || col < 0 || col >= cc) return QRect(); - const QVector<QLayoutStruct> *rDataPtr; + const QList<QLayoutStruct> *rDataPtr; if (has_hfw && hfwData) rDataPtr = hfwData; else diff --git a/src/widgets/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp index 3018dca5c6..98fc85c3c4 100644 --- a/src/widgets/kernel/qlayoutengine.cpp +++ b/src/widgets/kernel/qlayoutengine.cpp @@ -40,7 +40,7 @@ #include "qlayout.h" #include "private/qlayoutengine_p.h" -#include "qvector.h" +#include "qlist.h" #include "qwidget.h" #include <qvarlengtharray.h> @@ -73,8 +73,7 @@ static inline int fRound(Fixed64 i) { count is the count of items in the chain; pos and space give the interval (relative to parentWidget topLeft). */ -void qGeomCalc(QVector<QLayoutStruct> &chain, int start, int count, - int pos, int space, int spacer) +void qGeomCalc(QList<QLayoutStruct> &chain, int start, int count, int pos, int space, int spacer) { int cHint = 0; int cMin = 0; diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 9d221cb34e..4eefb36c68 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -94,9 +94,8 @@ struct QLayoutStruct int size; }; - -Q_WIDGETS_EXPORT void qGeomCalc(QVector<QLayoutStruct> &chain, int start, int count, - int pos, int space, int spacer = -1); +Q_WIDGETS_EXPORT void qGeomCalc(QList<QLayoutStruct> &chain, int start, int count, int pos, + int space, int spacer = -1); Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy); diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index e7e85c39e7..c8871b0bac 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -416,9 +416,9 @@ static bool hasPlatformWindow(QWidget *widget) return widget && widget->windowHandle() && widget->windowHandle()->handle(); } -static QVector<QRect> getSortedRectsToScroll(const QRegion ®ion, int dx, int dy) +static QList<QRect> getSortedRectsToScroll(const QRegion ®ion, int dx, int dy) { - QVector<QRect> rects; + QList<QRect> rects; std::copy(region.begin(), region.end(), std::back_inserter(rects)); if (rects.count() > 1) { std::sort(rects.begin(), rects.end(), [=](const QRect &r1, const QRect &r2) { @@ -488,8 +488,8 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy) const qreal factor = QHighDpiScaling::factor(q->windowHandle()); if (overlappedExpose.isEmpty() || qFloor(factor) == factor) { - const QVector<QRect> rectsToScroll - = getSortedRectsToScroll(QRegion(sourceRect) - overlappedExpose, dx, dy); + const QList<QRect> rectsToScroll = + getSortedRectsToScroll(QRegion(sourceRect) - overlappedExpose, dx, dy); for (QRect rect : rectsToScroll) { if (repaintManager->bltRect(rect, dx, dy, pw)) { childExpose -= rect.translated(dx, dy); @@ -570,8 +570,8 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) const qreal factor = QHighDpiScaling::factor(q->windowHandle()); if (overlappedExpose.isEmpty() || qFloor(factor) == factor) { - const QVector<QRect> rectsToScroll - = getSortedRectsToScroll(QRegion(sourceRect) - overlappedExpose, dx, dy); + const QList<QRect> rectsToScroll = + getSortedRectsToScroll(QRegion(sourceRect) - overlappedExpose, dx, dy); for (const QRect &rect : rectsToScroll) { if (repaintManager->bltRect(rect, dx, dy, q)) { childExpose -= rect.translated(dx, dy); @@ -627,7 +627,9 @@ bool QWidgetRepaintManager::bltRect(const QRect &rect, int dx, int dy, QWidget * // --------------------------------------------------------------------------- #ifndef QT_NO_OPENGL -static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatformTextureList *widgetTextures, QVector<QWidget *> *nativeChildren) +static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, + QPlatformTextureList *widgetTextures, + QList<QWidget *> *nativeChildren) { QWidgetPrivate *wd = QWidgetPrivate::get(widget); if (wd->renderToTexture) { @@ -650,7 +652,7 @@ static void findAllTextureWidgetsRecursively(QWidget *tlw, QWidget *widget) { // textureChildSeen does not take native child widgets into account and that's good. if (QWidgetPrivate::get(widget)->textureChildSeen) { - QVector<QWidget *> nativeChildren; + QList<QWidget *> nativeChildren; auto tl = qt_make_unique<QPlatformTextureList>(); // Look for texture widgets (incl. widget itself) from 'widget' down, // but skip subtrees with a parent of a native child widget. diff --git a/src/widgets/kernel/qwidgetrepaintmanager_p.h b/src/widgets/kernel/qwidgetrepaintmanager_p.h index 58687383f4..8b792617ec 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager_p.h +++ b/src/widgets/kernel/qwidgetrepaintmanager_p.h @@ -130,11 +130,11 @@ private: QBackingStore *store = nullptr; QRegion dirty; // needsRepaint - QVector<QWidget *> dirtyWidgets; - QVector<QWidget *> dirtyRenderToTextureWidgets; + QList<QWidget *> dirtyWidgets; + QList<QWidget *> dirtyRenderToTextureWidgets; QRegion topLevelNeedsFlush; - QVector<QWidget *> needsFlushWidgets; + QList<QWidget *> needsFlushWidgets; QList<QWidget *> staticWidgets; |