┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistview.h
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2023-07-17 17:13:51 +0300
committerFelix Ernst <[email protected]>2023-10-05 12:09:25 +0000
commit549fad2daeeccac53b88b4777dcc9effbc2110e5 (patch)
treecb1783e7d0695eb18aa4192a4e0632e3b80b5bc8 /src/kitemviews/kitemlistview.h
parent7a6cba7f51068a367c2dcd1908d1f3f329e8d50f (diff)
Fix accessibility ancestor tree
Before this commit, KItemListViewAccessible would always return nullptr as its parent. This meant that accessibility software would have to guess to which window/hierarchy the KItemListView belongs to. Guessing shouldn't be necessary here. This commit makes sure that the KItemListView always returns a sensible parent in the accessible hierarchy. It does so by explicitly setting the accessible parent for every KItemListView after construction in the DolphinView contructor. Since KItemListView now always knows about its accessible parent, the accessibleInterfaceFactory can always ask the KItemListView for that information when constructing the QAccessibleInterfaces. Fixes https://invent.kde.org/system/dolphin/-/issues/47.
Diffstat (limited to 'src/kitemviews/kitemlistview.h')
-rw-r--r--src/kitemviews/kitemlistview.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h
index ff51af922..7bcaec704 100644
--- a/src/kitemviews/kitemlistview.h
+++ b/src/kitemviews/kitemlistview.h
@@ -21,6 +21,8 @@
#include <QGraphicsWidget>
#include <QSet>
+class KItemListContainer;
+class KItemListContainerAccessible;
class KItemListController;
class KItemListGroupHeaderCreatorBase;
class KItemListHeader;
@@ -142,6 +144,18 @@ public:
void setGroupHeaderCreator(KItemListGroupHeaderCreatorBase *groupHeaderCreator);
KItemListGroupHeaderCreatorBase *groupHeaderCreator() const;
+#ifndef QT_NO_ACCESSIBILITY
+ /**
+ * Uses \a parent to create an accessible object for \a parent. That accessible object will
+ * then be used as the accessible parent of the accessible object for this KItemListView.
+ * Make sure \a parent is the container which contains this specific KItemListView.
+ * This method must be called once before the accessible interface is queried for this class.
+ */
+ void setAccessibleParentsObject(KItemListContainer *accessibleParentsObject);
+ /** The parent of the QAccessibilityInterface of this class. */
+ KItemListContainerAccessible *accessibleParent();
+#endif
+
/**
* @return The basic size of all items. The size of an item may be larger than
* the basic size (see KItemListView::itemRect()).
@@ -711,6 +725,10 @@ private:
QList<QByteArray> m_visibleRoles;
mutable KItemListWidgetCreatorBase *m_widgetCreator;
mutable KItemListGroupHeaderCreatorBase *m_groupHeaderCreator;
+#ifndef QT_NO_ACCESSIBILITY
+ /** The object that will be the parent of this classes QAccessibleInterface. */
+ KItemListContainerAccessible *m_accessibleParent = nullptr;
+#endif
KItemListStyleOption m_styleOption;
QHash<int, KItemListWidget *> m_visibleItems;