diff options
-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; |