summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-06-22 14:52:01 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-07-02 21:57:06 +0200
commit2a6cdec718934ca2cc7f6f9c616ebe62f6912123 (patch)
treec8b9ed8db47912dccd2e8d125d23760936820c29 /src/widgets/styles
parentd4c04acc65657d29df5b790281a8d1ba896dd868 (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/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp2
-rw-r--r--src/widgets/styles/qdrawutil.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp47
-rw-r--r--src/widgets/styles/qstylesheetstyle_p.h12
4 files changed, 37 insertions, 26 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index cc7af2ccc8..1f1fc73727 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -244,7 +244,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1;
int posY = opt->rect.y() + (opt->rect.height() - markH)/2;
- QVector<QLineF> a;
+ QList<QLineF> a;
a.reserve(markH);
int i, xx, yy;
diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp
index 66729e4dc7..c19ce5dd89 100644
--- a/src/widgets/styles/qdrawutil.cpp
+++ b/src/widgets/styles/qdrawutil.cpp
@@ -379,7 +379,7 @@ void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
light = pal.midlight().color();
}
QPen oldPen = p->pen(); // save pen
- QVector<QLineF> lines;
+ QList<QLineF> lines;
lines.reserve(2*lineWidth);
if (sunken)
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 412bf27f3a..b2b72fb6a8 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -508,7 +508,7 @@ class QRenderRule
{
public:
QRenderRule() : features(0), hasFont(false), pal(nullptr), b(nullptr), bg(nullptr), bd(nullptr), ou(nullptr), geo(nullptr), p(nullptr), img(nullptr), clipset(0) { }
- QRenderRule(const QVector<QCss::Declaration> &, const QObject *);
+ QRenderRule(const QList<QCss::Declaration> &, const QObject *);
QRect borderRect(const QRect &r) const;
QRect outlineRect(const QRect &r) const;
@@ -803,7 +803,7 @@ QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget
int offsets[3] = { 0, 0, 0 };
enum Where { Left, Right, Center, NoWhere } where = Left;
- QVector<ButtonInfo> infos;
+ QList<ButtonInfo> infos;
const int numLayouts = layout.size();
infos.reserve(numLayouts);
for (int i = 0; i < numLayouts; i++) {
@@ -915,8 +915,18 @@ static QStyle::StandardPixmap subControlIcon(int pe)
return QStyle::SP_CustomBase;
}
-QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject *object)
-: features(0), hasFont(false), pal(nullptr), b(nullptr), bg(nullptr), bd(nullptr), ou(nullptr), geo(nullptr), p(nullptr), img(nullptr), clipset(0)
+QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject *object)
+ : features(0),
+ hasFont(false),
+ pal(nullptr),
+ b(nullptr),
+ bg(nullptr),
+ bd(nullptr),
+ ou(nullptr),
+ geo(nullptr),
+ p(nullptr),
+ img(nullptr),
+ clipset(0)
{
QPalette palette = QGuiApplication::palette(); // ###: ideally widget's palette
ValueExtractor v(declarations, palette);
@@ -1602,14 +1612,15 @@ private:
mutable QHash<const QObject *, QHash<QString, QString> > m_attributeCache;
};
-QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const
+QList<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const
{
- QHash<const QObject *, QVector<StyleRule> >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(obj);
+ QHash<const QObject *, QList<StyleRule>>::const_iterator cacheIt =
+ styleSheetCaches->styleRulesCache.constFind(obj);
if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
return cacheIt.value();
if (!initObject(obj)) {
- return QVector<StyleRule>();
+ return QList<StyleRule>();
}
QStyleSheetStyleSelector styleSelector;
@@ -1645,7 +1656,7 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const
styleSelector.styleSheets += appSs;
}
- QVector<QCss::StyleSheet> objectSs;
+ QList<QCss::StyleSheet> objectSs;
for (const QObject *o = obj; o; o = parentObject(o)) {
QString styleSheet = o->property("styleSheet").toString();
if (styleSheet.isEmpty())
@@ -1674,16 +1685,17 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const
StyleSelector::NodePtr n;
n.ptr = const_cast<QObject *>(obj);
- QVector<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n);
+ QList<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n);
styleSheetCaches->styleRulesCache.insert(obj, rules);
return rules;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Rendering rules
-static QVector<Declaration> declarations(const QVector<StyleRule> &styleRules, const QString &part, quint64 pseudoClass = PseudoClass_Unspecified)
+static QList<Declaration> declarations(const QList<StyleRule> &styleRules, const QString &part,
+ quint64 pseudoClass = PseudoClass_Unspecified)
{
- QVector<Declaration> decls;
+ QList<Declaration> decls;
for (int i = 0; i < styleRules.count(); i++) {
const Selector& selector = styleRules.at(i).selectors.at(0);
// Rules with pseudo elements don't cascade. This is an intentional
@@ -1813,7 +1825,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint6
return QRenderRule();
quint64 stateMask = 0;
- const QVector<StyleRule> rules = styleRules(obj);
+ const QList<StyleRule> rules = styleRules(obj);
for (int i = 0; i < rules.count(); i++) {
const Selector& selector = rules.at(i).selectors.at(0);
quint64 negated = 0;
@@ -1830,7 +1842,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint6
const QString part = QLatin1String(knownPseudoElements[element].name);
- QVector<Declaration> decls = declarations(rules, part, state);
+ QList<Declaration> decls = declarations(rules, part, state);
QRenderRule newRule(decls, obj);
cache[state] = newRule;
if ((state & stateMask) != state)
@@ -2120,8 +2132,7 @@ bool QStyleSheetStyle::hasStyleRule(const QObject *obj, int part) const
if (!initObject(obj))
return false;
-
- const QVector<StyleRule> &rules = styleRules(obj);
+ const QList<StyleRule> &rules = styleRules(obj);
if (part == PseudoElement_None) {
bool result = obj && !rules.isEmpty();
cache[part] = result;
@@ -2580,8 +2591,8 @@ void QStyleSheetStyle::setProperties(QWidget *w)
// Set value for each property in the order of property final occurrence
// since properties interact.
- const QVector<Declaration> decls = declarations(styleRules(w), QString());
- QVector<int> finals; // indices in reverse order of each property's final occurrence
+ const QList<Declaration> decls = declarations(styleRules(w), QString());
+ QList<int> finals; // indices in reverse order of each property's final occurrence
{
// scan decls for final occurrence of each "qproperty"
@@ -2844,7 +2855,7 @@ void QStyleSheetStyle::polish(QWidget *w)
setPalette(w);
//set the WA_Hover attribute if one of the selector depends of the hover state
- QVector<StyleRule> rules = styleRules(w);
+ QList<StyleRule> rules = styleRules(w);
for (int i = 0; i < rules.count(); i++) {
const Selector& selector = rules.at(i).selectors.at(0);
quint64 negated = 0;
diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h
index 3c3503b964..879ddec4d3 100644
--- a/src/widgets/styles/qstylesheetstyle_p.h
+++ b/src/widgets/styles/qstylesheetstyle_p.h
@@ -45,14 +45,14 @@
#ifndef QT_NO_STYLE_STYLESHEET
+#include "QtWidgets/qapplication.h"
#include "QtWidgets/qstyleoption.h"
#include "QtCore/qhash.h"
-#include "QtGui/qevent.h"
-#include "QtCore/qvector.h"
+#include "QtCore/qlist.h"
#include "QtCore/qset.h"
-#include "QtWidgets/qapplication.h"
-#include "private/qcssparser_p.h"
#include "QtGui/qbrush.h"
+#include "QtGui/qevent.h"
+#include "private/qcssparser_p.h"
QT_BEGIN_NAMESPACE
@@ -158,7 +158,7 @@ private:
void setProperties(QWidget *);
void setGeometry(QWidget *);
void unsetStyleSheetFont(QWidget *) const;
- QVector<QCss::StyleRule> styleRules(const QObject *obj) const;
+ QList<QCss::StyleRule> styleRules(const QObject *obj) const;
bool hasStyleRule(const QObject *obj, int part) const;
QHash<QStyle::SubControl, QRect> titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const;
@@ -184,7 +184,7 @@ public Q_SLOTS:
void objectDestroyed(QObject *);
void styleDestroyed(QObject *);
public:
- QHash<const QObject *, QVector<QCss::StyleRule> > styleRulesCache;
+ QHash<const QObject *, QList<QCss::StyleRule>> styleRulesCache;
QHash<const QObject *, QHash<int, bool> > hasStyleRuleCache;
typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules;
QHash<const QObject *, QRenderRules> renderRulesCache;