Akonadi Contacts

emailaddressselectionmodel.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2017-2020 Laurent Montel <montel.org>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "emailaddressselectionmodel.h"
10 #include <AkonadiCore/Session>
11 #include <AkonadiCore/ItemFetchScope>
12 #include <AkonadiCore/EntityDisplayAttribute>
13 #include <AkonadiCore/ChangeRecorder>
14 #include <Akonadi/Contact/ContactsTreeModel>
15 #include <KContacts/Addressee>
16 #include <KContacts/ContactGroup>
17 
18 using namespace Akonadi;
19 
20 EmailAddressSelectionModel::EmailAddressSelectionModel(QObject *parent)
21  : QObject(parent)
22 {
23  Akonadi::Session *session = new Akonadi::Session("InternalEmailAddressSelectionWidgetModel", this);
24 
26  scope.fetchFullPayload(true);
28 
29  Akonadi::ChangeRecorder *changeRecorder = new Akonadi::ChangeRecorder(this);
30  changeRecorder->setSession(session);
31  changeRecorder->fetchCollection(true);
32  changeRecorder->setItemFetchScope(scope);
33  changeRecorder->setCollectionMonitored(Akonadi::Collection::root());
34  changeRecorder->setMimeTypeMonitored(KContacts::Addressee::mimeType(), true);
35  changeRecorder->setMimeTypeMonitored(KContacts::ContactGroup::mimeType(), true);
36 
37  mModel = new Akonadi::ContactsTreeModel(changeRecorder, this);
38 }
39 
40 EmailAddressSelectionModel::~EmailAddressSelectionModel()
41 {
42 }
43 
44 Akonadi::ContactsTreeModel *EmailAddressSelectionModel::model() const
45 {
46  return mModel;
47 }
static QString mimeType()
void fetchAttribute(const QByteArray &type, bool fetch=true)
void fetchFullPayload(bool fetch=true)
static QString mimeType()
static Collection root()
A model for contacts and contact groups as available in Akonadi.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Sep 23 2020 23:08:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.