summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-03-13 13:10:09 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-17 09:56:48 (GMT)
commit14d436698c53f070e8cc51bc2e3ef34a751af934 (patch)
treeda463a11e48ba529c43826b423dbb0b325e4522a /src/gui
parent6ede9f99f98ed511b78935f7c6537470dce94239 (diff)
downloadQt-14d436698c53f070e8cc51bc2e3ef34a751af934.zip
Qt-14d436698c53f070e8cc51bc2e3ef34a751af934.tar.gz
Qt-14d436698c53f070e8cc51bc2e3ef34a751af934.tar.bz2
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> (cherry picked from qtbase/176342e70a1ba7864a5b5dac14d12d4091ef5bd9)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp9
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp21
-rw-r--r--src/gui/styles/qwindowsxpstyle_p.h2
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;