Akonadi Contacts

abstractcontactformatter.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 <QVariantMap>
14
15#include <memory>
16
17namespace KContacts
18{
19class Addressee;
20}
21
22namespace Akonadi
23{
24class Item;
25class AbstractContactFormatterPrivate;
26
27/**
28 * @short The interface for all contact formatters.
29 *
30 * This is the interface that can be used to format an Akonadi
31 * item with a contact payload or a contact itself as HTML.
32 *
33 * @see StandardContactFormatter
34 * @author Tobias Koenig <tokoe@kde.org>
35 * @since 4.5
36 */
37class AKONADI_CONTACT_CORE_EXPORT AbstractContactFormatter
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 formatter.
51 */
53
54 /**
55 * Destroys the abstract contact formatter.
56 */
58
59 /**
60 * Sets the @p contact that will be formatted.
61 * @param contact contact to be formatted
62 */
63 void setContact(const KContacts::Addressee &contact);
64
65 /**
66 * Returns the contact that will be formatted.
67 */
68 [[nodiscard]] KContacts::Addressee contact() const;
69
70 /**
71 * Sets the @p item who's payload will be formatted.
72 *
73 * @note The payload must be a valid KContacts::Addressee object.
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 custom field @p descriptions that will be used.
85 *
86 * The description list contains a QVariantMap for each custom 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 * - type (string) The type description of the field
91 * Possible values for type description are
92 * - text
93 * - numeric
94 * - boolean
95 * - date
96 * - time
97 * - datetime
98 *
99 * @param descriptions list with field descriptions
100 */
101 void setCustomFieldDescriptions(const QList<QVariantMap> &descriptions);
102
103 /**
104 * Returns the custom field descriptions that will be used.
105 */
106 [[nodiscard]] QList<QVariantMap> customFieldDescriptions() const;
107
108 /**
109 * This method must be reimplemented to return the contact formatted as HTML
110 * according to the requested @p form.
111 * @param form how to render the contact into HTML
112 */
113 virtual QString toHtml(HtmlForm form = SelfcontainedForm) const = 0;
114
115private:
116 //@cond PRIVATE
117 Q_DISABLE_COPY(AbstractContactFormatter)
118
119 std::unique_ptr<AbstractContactFormatterPrivate> const d;
120 //@endcond
121};
122}
The interface for all contact formatters.
virtual ~AbstractContactFormatter()
Destroys the abstract contact formatter.
virtual QString toHtml(HtmlForm form=SelfcontainedForm) const =0
This method must be reimplemented to return the contact formatted as HTML according to the requested ...
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.
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.