summaryrefslogtreecommitdiffstats
path: root/framework/domain/peoplemodel.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-10 21:50:08 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-10 21:50:48 +0100
commite52a02bb77c5292a016d2c14e0730d44d25d4000 (patch)
treebb67d615bd8d699ca0ff2c5996253acf46d5389a /framework/domain/peoplemodel.h
parentca120180460c7eeefaec9b1f31e5ad8aee32df2d (diff)
downloadkube-e52a02bb77c5292a016d2c14e0730d44d25d4000.tar.gz
kube-e52a02bb77c5292a016d2c14e0730d44d25d4000.zip
Simple peoplemodel for addressbook
Currently just queries for a flat list of contacts. Read-only.
Diffstat (limited to 'framework/domain/peoplemodel.h')
-rw-r--r--framework/domain/peoplemodel.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/framework/domain/peoplemodel.h b/framework/domain/peoplemodel.h
new file mode 100644
index 00000000..419d59a6
--- /dev/null
+++ b/framework/domain/peoplemodel.h
@@ -0,0 +1,63 @@
1/*
2 Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net>
3 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19*/
20
21#pragma once
22
23#include <QSortFilterProxyModel>
24#include <QSharedPointer>
25
26namespace Sink {
27 class Query;
28};
29
30/**
31 * A model that mixes addressbooks, contact groups and contacts
32 */
33class PeopleModel : public QSortFilterProxyModel
34{
35 Q_OBJECT
36 Q_PROPERTY (QVariant addressbook READ addressbook WRITE setAddressbook)
37
38public:
39 PeopleModel(QObject *parent = Q_NULLPTR);
40 ~PeopleModel();
41
42 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
43
44 bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
45
46 enum Roles {
47 Name = Qt::UserRole + 1,
48 Type,
49 Emails,
50 Addressbook,
51 DomainObject
52 };
53
54 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
55
56 void runQuery(const Sink::Query &query);
57
58 void setAddressbook(const QVariant &parentFolder);
59 QVariant addressbook() const;
60
61private:
62 QSharedPointer<QAbstractItemModel> mModel;
63};