File indexing completed on 2025-01-26 03:28:30

0001 /*
0002     SPDX-FileCopyrightText: 2012 Sebastian Sauer <sebastian.sauer@kdab.com>
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 "qaccessibilityclient/accessibleobject.h"
0010 #include <QObject>
0011 #include <QStandardItemModel>
0012 
0013 class ObjectPropertiesModel : public QStandardItemModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum ObjectPropertiesModelRoles {
0018         Name,
0019         Value,
0020         LastColumn = Value,
0021     };
0022     explicit ObjectPropertiesModel(QObject *parent = nullptr);
0023     ~ObjectPropertiesModel() override;
0024 
0025     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0026 
0027     [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
0028     void setAccessibleObject(const QAccessibleClient::AccessibleObject &acc);
0029     [[nodiscard]] QAccessibleClient::AccessibleObject currentObject() const;
0030     void doubleClicked(const QModelIndex &index);
0031 
0032     [[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
0033 
0034 private:
0035     void slotDataChanged(QStandardItem *item);
0036     void setFontBold(QStandardItem *item);
0037     QStandardItem *
0038     append(const QString &name, const QVariant &value = QVariant(), QStandardItem *parentItem = nullptr, QStandardItem **changeHandler = nullptr);
0039     QString stateString(const QAccessibleClient::AccessibleObject &acc);
0040     QAccessibleClient::AccessibleObject mAccessibleObject;
0041     QStandardItem *mTextItem = nullptr;
0042     QStandardItem *mValueItem = nullptr;
0043 };