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 <Akonadi/ChangeRecorder>
11 #include <Akonadi/ContactsTreeModel>
12 #include <Akonadi/EntityDisplayAttribute>
13 #include <Akonadi/ItemFetchScope>
14 #include <Akonadi/Session>
15 #include <KContacts/Addressee>
16 #include <KContacts/ContactGroup>
17 
18 using namespace Akonadi;
19 
20 EmailAddressSelectionModel::EmailAddressSelectionModel(QObject *parent)
21  : QObject(parent)
22 {
23  auto session = new Akonadi::Session("InternalEmailAddressSelectionWidgetModel", this);
24 
26  scope.fetchFullPayload(true);
28 
29  auto 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() = default;
41 
42 Akonadi::ContactsTreeModel *EmailAddressSelectionModel::model() const
43 {
44  return mModel;
45 }
void fetchAttribute(bool fetch=true)
void fetchFullPayload(bool fetch=true)
static QString mimeType()
static Collection root()
static QString mimeType()
A model for contacts and contact groups as available in Akonadi.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:09:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.