diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-03-13 14:10:09 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-14 22:40:36 +0100 |
commit | 176342e70a1ba7864a5b5dac14d12d4091ef5bd9 (patch) | |
tree | 4026a23bc6d2c0c21cf39ebe56916ca08034aaac /src/widgets | |
parent | 9ceeaaac7984523fdc08c2040fcadf5698254c2d (diff) |
QWindowsXP/VistaStyle: Fix detection of item view delegate line edits.
The old code tried to check the 2nd parent for inheritance from
QAbstractItemView. This also triggers for line edits on a QDialog parented
on the item view. Introduce convenience function that checks for
top levels in the chain.
Task-number: QTBUG-37504
Change-Id: I932f8efdb4764e9b1eea84c802bf7e8718338e1d
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qwindowsvistastyle.cpp | 9 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 21 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 1 |
3 files changed, 16 insertions, 15 deletions
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 6955ec83e0..9c3e1eac99 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -626,14 +626,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt anim->paint(painter, option); } else { QPainter *p = painter; - QWidget *parentWidget = 0; - if (widget) { - parentWidget = widget->parentWidget(); - if (parentWidget) - parentWidget = parentWidget->parentWidget(); - } - if (widget && widget->inherits("QLineEdit") - && parentWidget && parentWidget->inherits("QAbstractItemView")) { + if (QWindowsXPStylePrivate::isItemViewDelegateLineEdit(widget)) { // we try to check if this lineedit is a delegate on a QAbstractItemView-derived class. QPen oldPen = p->pen(); // Inner white border diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 63ed3ef7c8..e694eb4e7e 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -346,6 +346,19 @@ QString QWindowsXPStylePrivate::themeName(int theme) QString(); } +bool QWindowsXPStylePrivate::isItemViewDelegateLineEdit(const QWidget *widget) +{ + if (!widget) + return false; + const QWidget *parent1 = widget->parentWidget(); + // Exlude dialogs or other toplevels parented on item views. + if (!parent1 || parent1->isWindow()) + return false; + const QWidget *parent2 = parent1->parentWidget(); + return parent2 && widget->inherits("QLineEdit") + && parent2->inherits("QAbstractItemView"); +} + /*! \internal This function will always return a valid window handle, and might create a limbo widget to do so. @@ -1548,13 +1561,7 @@ case PE_Frame: } case PE_FrameLineEdit: { // we try to check if this lineedit is a delegate on a QAbstractItemView-derived class. - QWidget *parentWidget = 0; - if (widget) - parentWidget = widget->parentWidget(); - if (parentWidget) - parentWidget = parentWidget->parentWidget(); - if (widget && widget->inherits("QLineEdit") - && parentWidget && parentWidget->inherits("QAbstractItemView")) { + if (QWindowsXPStylePrivate::isItemViewDelegateLineEdit(widget)) { QPen oldPen = p->pen(); // Inner white border p->setPen(QPen(option->palette.base().color(), 1)); diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 27d9c9acc9..7327fa5581 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -350,6 +350,7 @@ public: static HTHEME createTheme(int theme, HWND hwnd); static QString themeName(int theme); static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; } + static bool isItemViewDelegateLineEdit(const QWidget *widget); QIcon dockFloat, dockClose; |