summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qwindowsxpstyle.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-03-13 14:10:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-14 22:40:36 +0100
commit176342e70a1ba7864a5b5dac14d12d4091ef5bd9 (patch)
tree4026a23bc6d2c0c21cf39ebe56916ca08034aaac /src/widgets/styles/qwindowsxpstyle.cpp
parent9ceeaaac7984523fdc08c2040fcadf5698254c2d (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/styles/qwindowsxpstyle.cpp')
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp21
1 files changed, 14 insertions, 7 deletions
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));