File indexing completed on 2025-01-26 03:28:30
0001 /* 0002 SPDX-FileCopyrightText: 2012 Frederik Gladhorn <gladhorn@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractItemModel> 0010 0011 #include <qaccessibilityclient/registry.h> 0012 0013 class AccessibleObjectTreeModel; 0014 class AccessibleWrapper; 0015 0016 class AccessibleObjectTreeModel : public QAbstractItemModel 0017 { 0018 Q_OBJECT 0019 public: 0020 enum AccessibleObjectTreeModelRoles { 0021 Accessible, 0022 Role, 0023 ChildrenCount, 0024 LastColumn = ChildrenCount, 0025 }; 0026 Q_ENUM(AccessibleObjectTreeModelRoles) 0027 explicit AccessibleObjectTreeModel(QObject *parent = nullptr); 0028 ~AccessibleObjectTreeModel() override; 0029 0030 void setRegistry(QAccessibleClient::Registry *registry); 0031 0032 [[nodiscard]] QModelIndex indexForAccessible(const QAccessibleClient::AccessibleObject &object); 0033 bool addAccessible(const QAccessibleClient::AccessibleObject &object); 0034 bool removeAccessible(const QAccessibleClient::AccessibleObject &object); 0035 bool removeAccessible(const QModelIndex &index); 0036 void updateAccessible(const QAccessibleClient::AccessibleObject &object); 0037 0038 [[nodiscard]] QList<AccessibleWrapper *> apps() const; 0039 0040 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0041 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0042 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0043 [[nodiscard]] QModelIndex parent(const QModelIndex &child) const override; 0044 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0045 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0046 0047 void resetModel(); 0048 /*! 0049 \brief Updates all applications in the tree. 0050 0051 Removes and adds top level applications. This is less invasive then modelReset. 0052 */ 0053 void updateTopLevelApps(); 0054 0055 Q_SIGNALS: 0056 void navigationError(const QModelIndex &) const; 0057 0058 private: 0059 QAccessibleClient::Registry *mRegistry = nullptr; 0060 QList<AccessibleWrapper *> mApps; 0061 };