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>
This commit is contained in:
parent
9ceeaaac79
commit
176342e70a
@ -626,14 +626,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
anim->paint(painter, option);
|
anim->paint(painter, option);
|
||||||
} else {
|
} else {
|
||||||
QPainter *p = painter;
|
QPainter *p = painter;
|
||||||
QWidget *parentWidget = 0;
|
if (QWindowsXPStylePrivate::isItemViewDelegateLineEdit(widget)) {
|
||||||
if (widget) {
|
|
||||||
parentWidget = widget->parentWidget();
|
|
||||||
if (parentWidget)
|
|
||||||
parentWidget = parentWidget->parentWidget();
|
|
||||||
}
|
|
||||||
if (widget && widget->inherits("QLineEdit")
|
|
||||||
&& parentWidget && parentWidget->inherits("QAbstractItemView")) {
|
|
||||||
// we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
|
// we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
|
||||||
QPen oldPen = p->pen();
|
QPen oldPen = p->pen();
|
||||||
// Inner white border
|
// Inner white border
|
||||||
|
@ -346,6 +346,19 @@ QString QWindowsXPStylePrivate::themeName(int theme)
|
|||||||
QString();
|
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
|
/*! \internal
|
||||||
This function will always return a valid window handle, and might
|
This function will always return a valid window handle, and might
|
||||||
create a limbo widget to do so.
|
create a limbo widget to do so.
|
||||||
@ -1548,13 +1561,7 @@ case PE_Frame:
|
|||||||
}
|
}
|
||||||
case PE_FrameLineEdit: {
|
case PE_FrameLineEdit: {
|
||||||
// we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
|
// we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
|
||||||
QWidget *parentWidget = 0;
|
if (QWindowsXPStylePrivate::isItemViewDelegateLineEdit(widget)) {
|
||||||
if (widget)
|
|
||||||
parentWidget = widget->parentWidget();
|
|
||||||
if (parentWidget)
|
|
||||||
parentWidget = parentWidget->parentWidget();
|
|
||||||
if (widget && widget->inherits("QLineEdit")
|
|
||||||
&& parentWidget && parentWidget->inherits("QAbstractItemView")) {
|
|
||||||
QPen oldPen = p->pen();
|
QPen oldPen = p->pen();
|
||||||
// Inner white border
|
// Inner white border
|
||||||
p->setPen(QPen(option->palette.base().color(), 1));
|
p->setPen(QPen(option->palette.base().color(), 1));
|
||||||
|
@ -350,6 +350,7 @@ public:
|
|||||||
static HTHEME createTheme(int theme, HWND hwnd);
|
static HTHEME createTheme(int theme, HWND hwnd);
|
||||||
static QString themeName(int theme);
|
static QString themeName(int theme);
|
||||||
static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; }
|
static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; }
|
||||||
|
static bool isItemViewDelegateLineEdit(const QWidget *widget);
|
||||||
|
|
||||||
QIcon dockFloat, dockClose;
|
QIcon dockFloat, dockClose;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user