diff options
-rw-r--r-- | src/gui/styles/qwindowsvistastyle.cpp | 9 | ||||
-rw-r--r-- | src/gui/styles/qwindowsxpstyle.cpp | 21 | ||||
-rw-r--r-- | src/gui/styles/qwindowsxpstyle_p.h | 2 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index abe729b..c380dc7 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -646,14 +646,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/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index f65fd79..99ec5d6 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -287,6 +287,19 @@ void QWindowsXPStylePrivate::cleanupHandleMap() handleMap = 0; } +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. @@ -1466,13 +1479,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/gui/styles/qwindowsxpstyle_p.h b/src/gui/styles/qwindowsxpstyle_p.h index 13d0c94..91560ce 100644 --- a/src/gui/styles/qwindowsxpstyle_p.h +++ b/src/gui/styles/qwindowsxpstyle_p.h @@ -321,6 +321,8 @@ public: bool fixAlphaChannel(const QRect &rect); bool swapAlphaChannel(const QRect &rect, bool allPixels = false); + static bool isItemViewDelegateLineEdit(const QWidget *widget); + QRgb groupBoxTextColor; QRgb groupBoxTextColorDisabled; QRgb sliderTickColor; |