Akonadi Contacts

abstractcontactformatter.h
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2010 Tobias Koenig <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include "akonadi-contact_export.h"
12 
13 #include <QVariantMap>
14 
15 #include <memory>
16 
17 namespace KContacts
18 {
19 class Addressee;
20 }
21 
22 namespace Akonadi
23 {
24 class Item;
25 class 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 <[email protected]>
35  * @since 4.5
36  */
37 class AKONADI_CONTACT_EXPORT AbstractContactFormatter
38 {
39 public:
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  */
57  virtual ~AbstractContactFormatter();
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  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT 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 QVector<QVariantMap> &descriptions);
102 
103  /**
104  * Returns the custom field descriptions that will be used.
105  */
106  Q_REQUIRED_RESULT QVector<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 
115 private:
116  //@cond PRIVATE
117  Q_DISABLE_COPY(AbstractContactFormatter)
118 
119  std::unique_ptr<AbstractContactFormatterPrivate> const d;
120  //@endcond
121 };
122 }
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.
The interface for all contact formatters.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:09:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.