Akonadi Contacts

abstractcontactgroupformatter.h
1/*
2 This file is part of Akonadi Contact.
3
4 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "akonadi-contact-core_export.h"
12
13#include <QVariant>
14
15#include <memory>
16
17namespace KContacts
18{
19class ContactGroup;
20}
21
22namespace Akonadi
23{
24class Item;
25class AbstractContactGroupFormatterPrivate;
26
27/**
28 * @short The interface for all contact group formatters.
29 *
30 * This is the interface that can be used to format an Akonadi
31 * item with a contact group payload or a contact group itself as HTML.
32 *
33 * @see StandardContactGroupFormatter
34 * @author Tobias Koenig <tokoe@kde.org>
35 * @since 4.6
36 */
37class AKONADI_CONTACT_CORE_EXPORT AbstractContactGroupFormatter
38{
39public:
40 /**
41 * Describes the form of the HTML that is created.
42 */
43 enum HtmlForm {
44 SelfcontainedForm, ///< Creates a complete HTML document
45 EmbeddableForm, ///< Creates a div HTML element that can be embedded.
46 UserForm = SelfcontainedForm + 42 ///< Point for extension
47 };
48
49 /**
50 * Creates a new abstract contact group formatter.
51 */
53
54 /**
55 * Destroys the abstract contact group formatter.
56 */
58
59 /**
60 * Sets the contact @p group that will be formatted.
61 */
62 void setContactGroup(const KContacts::ContactGroup &group);
63
64 /**
65 * Returns the contact group that will be formatted.
66 */
67 [[nodiscard]] KContacts::ContactGroup contactGroup() const;
68
69 /**
70 * Sets the @p item who's payload will be formatted.
71 *
72 * @note The payload must be a valid KContacts::ContactGroup object.
73 *
74 * @param item item, who's payload will be formatted.
75 */
76 void setItem(const Akonadi::Item &item);
77
78 /**
79 * Returns the item who's payload will be formatted.
80 */
81 [[nodiscard]] Akonadi::Item item() const;
82
83 /**
84 * Sets the additional @p fields that will be shown.
85 *
86 * The fields list contains a QVariantMap for each additional field
87 * with the following keys:
88 * - key (string) The identifier of the field
89 * - title (string) The i18n'ed title of the field
90 * - value (string) The value of the field
91 *
92 * @param fields additional fields that will be shown
93 */
94 void setAdditionalFields(const QList<QVariantMap> &fields);
95
96 /**
97 * Returns the additional fields that will be shown.
98 */
99 [[nodiscard]] QList<QVariantMap> additionalFields() const;
100
101 /**
102 * This method must be reimplemented to return the contact group formatted as HTML
103 * according to the requested @p form.
104 */
105 virtual QString toHtml(HtmlForm form = SelfcontainedForm) const = 0;
106
107private:
108 //@cond PRIVATE
109 Q_DISABLE_COPY(AbstractContactGroupFormatter)
110
111 std::unique_ptr<AbstractContactGroupFormatterPrivate> const d;
112 //@endcond
113};
114}
The interface for all contact group formatters.
virtual QString toHtml(HtmlForm form=SelfcontainedForm) const =0
This method must be reimplemented to return the contact group formatted as HTML according to the requ...
HtmlForm
Describes the form of the HTML that is created.
@ EmbeddableForm
Creates a div HTML element that can be embedded.
@ SelfcontainedForm
Creates a complete HTML document.
virtual ~AbstractContactGroupFormatter()
Destroys the abstract contact group formatter.
A widget for editing the display name of a contact.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.