Akonadi Contacts

grantleeprint.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "grantleeprint.h"
8#include "contactgrantleewrapper.h"
9
10#include <KTextTemplate/Context>
11#include <KTextTemplate/Engine>
12#include <KTextTemplate/MetaType>
13#include <KTextTemplate/TemplateLoader>
14
15#include <QMetaProperty>
16#include <QVariant>
17
19if (property == QLatin1StringView("scheme")) {
20 return object.scheme();
21}
23
24using namespace KAddressBookGrantlee;
25
26GrantleePrint::GrantleePrint()
27{
28 init();
29}
30
31GrantleePrint::GrantleePrint(const QString &themePath)
32 : GrantleeTheme::GenericFormatter(QStringLiteral("theme.html"), themePath)
33{
34 init();
35}
36
37GrantleePrint::~GrantleePrint() = default;
38
39void GrantleePrint::init()
40{
42}
43
44QString GrantleePrint::contactsToHtml(const KContacts::Addressee::List &contacts)
45{
46 if (!errorMessage().isEmpty()) {
47 return errorMessage();
48 }
49
50 if (contacts.isEmpty()) {
51 return {};
52 }
53 QVariantList contactsList;
54 contactsList.reserve(contacts.count());
55 for (const KContacts::Addressee &contact : contacts) {
56 contactsList.push_back(QVariant::fromValue(ContactGrantleeWrapper(contact)));
57 }
58 QVariantHash mapping;
59 mapping.insert(QStringLiteral("contacts"), contactsList);
60
61 return render(mapping);
62}
Additional properties for the KContacts::Addressee Grantlee model.
AddresseeList List
#define KTEXTTEMPLATE_END_LOOKUP
#define KTEXTTEMPLATE_BEGIN_LOOKUP(Type)
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
int registerMetaType()
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.