19 #include "personactionsmodel_p.h"
20 #include <kpeople/persondata.h>
21 #include <kpeople/actions.h>
28 struct PersonActionsPrivate {
29 PersonActionsPrivate()
33 QList<QAction *> actions;
41 PersonActionsModel::PersonActionsModel(QObject *parent)
42 : QAbstractListModel(parent),
43 d_ptr(new PersonActionsPrivate)
47 PersonActionsModel::~PersonActionsModel()
52 QHash<int, QByteArray> PersonActionsModel::roleNames()
const
54 QHash<int, QByteArray> roles = QAbstractListModel::roleNames();
55 roles[IconNameRole] =
"iconName";
56 roles[ActionRole] =
"action";
60 void PersonActionsModel::setPersonUri(
const QString &
id)
74 void PersonActionsModel::resetActions()
83 QString PersonActionsModel::personUri()
const
85 Q_D(
const PersonActions);
89 QVariant PersonActionsModel::data(
const QModelIndex &index,
int role)
const
91 Q_D(
const PersonActions);
93 if (!index.isValid()) {
99 return d->actions[index.row()]->text();
100 case Qt::DecorationRole:
101 return d->actions[index.row()]->icon();
103 return d->actions[index.row()]->toolTip();
105 return d->actions[index.row()]->icon().name();
107 return QVariant::fromValue<QObject *>(d->actions[index.row()]);
113 int PersonActionsModel::rowCount(
const QModelIndex &parent)
const
115 Q_D(
const PersonActions);
117 return parent.isValid() ? 0 : d->actions.size();
120 void PersonActionsModel::triggerAction(
int row)
const
122 Q_D(
const PersonActions);
123 d->actions[row]->trigger();
126 QList< QAction * > PersonActionsModel::actions()
const
128 Q_D(
const PersonActions);
QList< QAction * > actionsForPerson(const QString &contactUri, QObject *parent)
Returns a list of actions relevant to the specified contactUri.
Allows to query the information about a given person.
The KPeople namespace contains all the classes for Libkpeople.
void dataChanged()
One of the contact sources has changed.