diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-01-07 13:17:38 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-07 21:57:33 +0100 |
commit | 2c241d0604be95227ad535e0d5c846d4e7ff685c (patch) | |
tree | c9b58c1938b6c9a6d561748296f2a646eac332a3 /src | |
parent | 99e5496ff7abc6bf1436783e951231ffd9a83ca0 (diff) |
Add QStyleHelper:isInstanceOf()
Task-number: QTBUG-28876
Change-Id: I343dff1c47c52e0431c09b6097da09f34e626f54
Reviewed-by: Jonathan Liu <net147@gmail.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 18 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper_p.h | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 1630130de2..ee44d01634 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -86,6 +86,20 @@ qreal dpiScaled(qreal value) #endif } +bool isInstanceOf(QObject *obj, QAccessible::Role role) +{ + bool match = false; +#ifndef QT_NO_ACCESSIBILITY + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(obj); + match = iface && iface->role() == role; + delete iface; +#else + Q_UNUSED(obj) + Q_UNUSED(role) +#endif // QT_NO_ACCESSIBILITY + return match; +} + // Searches for an ancestor of a particular accessible role bool hasAncestor(QObject *obj, QAccessible::Role role) { @@ -93,10 +107,8 @@ bool hasAncestor(QObject *obj, QAccessible::Role role) #ifndef QT_NO_ACCESSIBILITY QObject *parent = obj ? obj->parent() : 0; while (parent && !found) { - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parent); - if (iface && iface->role() == role) + if (isInstanceOf(parent, role)) found = true; - delete iface; parent = parent->parent(); } #else diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index ab6a97e59a..642db68d9e 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -82,6 +82,7 @@ namespace QStyleHelper void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left = 0, int top = 0, int right = 0, int bottom = 0); + bool isInstanceOf(QObject *obj, QAccessible::Role role); bool hasAncestor(QObject *obj, QAccessible::Role role); } |