summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qwindowsstyle.cpp
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-02-15 11:16:39 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-08 19:35:26 +0000
commit89034600939bbfe241ba3d6136abf7bb6961db52 (patch)
tree569ed773351a496ddac552fff66859967695351f /src/widgets/styles/qwindowsstyle.cpp
parentf931e5e72d4617023bbea46cba2c0d61bb1efa4f (diff)
QtBase: use erase and std::remove_if with QList and QVector
... instead of using removeAt in a loop, with quadratic complexity. Change-Id: I38b49e56b12c396db9fc0f1b75d8fb43c503a7f6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/styles/qwindowsstyle.cpp')
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 23f886e5b1..f6323bb41c 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -71,6 +71,8 @@
#include <private/qstylehelper_p.h>
#include <private/qstyleanimation_p.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
#if defined(Q_OS_WIN)
@@ -159,12 +161,11 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
// Alt has been pressed - find all widgets that care
QList<QWidget *> l = widget->findChildren<QWidget *>();
- for (int pos=0 ; pos < l.size() ; ++pos) {
- QWidget *w = l.at(pos);
- if (w->isWindow() || !w->isVisible() ||
- w->style()->styleHint(SH_UnderlineShortcut, 0, w))
- l.removeAt(pos);
- }
+ auto ignorable = [](QWidget *w) {
+ return w->isWindow() || !w->isVisible()
+ || w->style()->styleHint(SH_UnderlineShortcut, 0, w);
+ };
+ l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end());
// Update states before repainting
d->seenAlt.append(widget);
d->alt_down = true;