KPeople 5.109.0
personsmodel.h
1/*
2 Persons Model
3 SPDX-FileCopyrightText: 2012 Martin Klapetek <martin.klapetek@gmail.com>
4 SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
5 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.1-or-later
8*/
9
10#ifndef PERSONS_MODEL_H
11#define PERSONS_MODEL_H
12
13#include <kpeople/kpeople_export.h>
14
15#include "global.h"
16
17#include <QAbstractItemModel>
18
19namespace KPeople
20{
21class ContactItem;
22class PersonItem;
23class MetaContact;
24class PersonsModelPrivate;
25
33class KPEOPLE_EXPORT PersonsModel : public QAbstractItemModel
34{
35 Q_OBJECT
37 Q_PROPERTY(bool isInitialized READ isInitialized NOTIFY modelInitialized)
38public:
39 enum Role {
40 FormattedNameRole = Qt::DisplayRole, // QString best name for this person
41 PhotoRole = Qt::DecorationRole, // QPixmap best photo for this person
42 PersonUriRole = Qt::UserRole, // QString ID of this person
43 PersonVCardRole, // AbstractContact::Ptr
44 ContactsVCardRole, // AbstractContact::List (FIXME or map?)
45
46 GroupsRole,
49
50 UserRole = Qt::UserRole + 0x1000,
51 };
52 Q_ENUM(Role)
53
54 explicit PersonsModel(QObject *parent = nullptr);
55
56 ~PersonsModel() override;
57
58 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
59 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
60 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
61 QModelIndex parent(const QModelIndex &index) const override;
62 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
63 QHash<int, QByteArray> roleNames() const override;
64
66 QModelIndex indexForPersonUri(const QString &personUri) const;
67
69 bool isInitialized() const;
70
72 Q_SCRIPTABLE QVariant get(int row, int role);
73
79 QVariant contactCustomProperty(const QModelIndex &index, const QString &key) const;
80
81Q_SIGNALS:
83 void modelInitialized(bool success);
84
85private:
86 Q_DISABLE_COPY(PersonsModel)
87
88 QScopedPointer<PersonsModelPrivate> const d_ptr;
89 Q_DECLARE_PRIVATE(PersonsModel)
90};
91}
92
93#endif // PERSONS_MODEL_H
This class creates a model of all known contacts from all sources Contacts are represented as a tree ...
Definition personsmodel.h:34
void modelInitialized(bool success)
Will emit when the model is finally initialized.
QVariant contactCustomProperty(const QModelIndex &index, const QString &key) const
Makes it possible to access custom properties that are not available to the model.
QModelIndex indexForPersonUri(const QString &personUri) const
bool isInitialized() const
Returns if all the backends have been initialized yet.
QVariant get(int row, int role)
Helper class to ease model access through QML.
Role
Definition personsmodel.h:39
@ PhotoImageProviderUri
Provide a URL to use with QtQuick's Image.source, similar to the Photo Role.
Definition personsmodel.h:48
@ PhoneNumberRole
groups QStringList
Definition personsmodel.h:47