File indexing completed on 2024-05-05 16:16:35
0001 /* 0002 SPDX-FileCopyrightText: 2013 Martin Klapetek <mklapetek@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef PERSON_ACTIONS_H 0008 #define PERSON_ACTIONS_H 0009 0010 #include <QAbstractListModel> 0011 0012 class QAction; 0013 0014 namespace KPeople 0015 { 0016 class PersonActionsPrivate; 0017 0018 class PersonActionsModel : public QAbstractListModel 0019 { 0020 Q_OBJECT 0021 Q_PROPERTY(int count READ rowCount NOTIFY personChanged) 0022 Q_PROPERTY(QString personUri READ personUri WRITE setPersonUri NOTIFY personChanged) 0023 0024 public: 0025 enum Roles { 0026 IconNameRole = Qt::UserRole + 1, 0027 ActionRole, 0028 ActionTypeRole, 0029 }; 0030 0031 explicit PersonActionsModel(QObject *parent = nullptr); 0032 ~PersonActionsModel() override; 0033 0034 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0035 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0036 0037 QString personUri() const; 0038 void setPersonUri(const QString &personUri); 0039 0040 QList<QAction *> actions() const; 0041 0042 QHash<int, QByteArray> roleNames() const override; 0043 0044 Q_INVOKABLE void triggerAction(int row) const; 0045 0046 Q_SIGNALS: 0047 void personChanged(); 0048 0049 private: 0050 void resetActions(); 0051 0052 Q_DECLARE_PRIVATE(PersonActions) 0053 PersonActionsPrivate *const d_ptr; 0054 }; 0055 } 0056 0057 #endif // PERSON_ACTIONS_H