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 namespace KContacts
16 {
17 class Addressee;
18 }
19 
20 namespace Akonadi
21 {
22 class Item;
23 
24 /**
25  * @short The interface for all contact formatters.
26  *
27  * This is the interface that can be used to format an Akonadi
28  * item with a contact payload or a contact itself as HTML.
29  *
30  * @see StandardContactFormatter
31  * @author Tobias Koenig <[email protected]>
32  * @since 4.5
33  */
34 class AKONADI_CONTACT_EXPORT AbstractContactFormatter
35 {
36 public:
37  /**
38  * Describes the form of the HTML that is created.
39  */
40  enum HtmlForm {
41  SelfcontainedForm, ///< Creates a complete HTML document
42  EmbeddableForm, ///< Creates a div HTML element that can be embedded.
43  UserForm = SelfcontainedForm + 42 ///< Point for extension
44  };
45 
46  /**
47  * Creates a new abstract contact formatter.
48  */
50 
51  /**
52  * Destroys the abstract contact formatter.
53  */
54  virtual ~AbstractContactFormatter();
55 
56  /**
57  * Sets the @p contact that will be formatted.
58  * @param contact contact to be formatted
59  */
60  void setContact(const KContacts::Addressee &contact);
61 
62  /**
63  * Returns the contact that will be formatted.
64  */
65  Q_REQUIRED_RESULT KContacts::Addressee contact() const;
66 
67  /**
68  * Sets the @p item who's payload will be formatted.
69  *
70  * @note The payload must be a valid KContacts::Addressee object.
71  * @param item item, who's payload will be formatted.
72  */
73  void setItem(const Akonadi::Item &item);
74 
75  /**
76  * Returns the item who's payload will be formatted.
77  */
78  Q_REQUIRED_RESULT Akonadi::Item item() const;
79 
80  /**
81  * Sets the custom field @p descriptions that will be used.
82  *
83  * The description list contains a QVariantMap for each custom field
84  * with the following keys:
85  * - key (string) The identifier of the field
86  * - title (string) The i18n'ed title of the field
87  * - type (string) The type description of the field
88  * Possible values for type description are
89  * - text
90  * - numeric
91  * - boolean
92  * - date
93  * - time
94  * - datetime
95  *
96  * @param descriptions list with field descriptions
97  */
98  void setCustomFieldDescriptions(const QVector<QVariantMap> &descriptions);
99 
100  /**
101  * Returns the custom field descriptions that will be used.
102  */
103  Q_REQUIRED_RESULT QVector<QVariantMap> customFieldDescriptions() const;
104 
105  /**
106  * This method must be reimplemented to return the contact formatted as HTML
107  * according to the requested @p form.
108  * @param form how to render the contact into HTML
109  */
110  virtual QString toHtml(HtmlForm form = SelfcontainedForm) const = 0;
111 
112 private:
113  //@cond PRIVATE
114  Q_DISABLE_COPY(AbstractContactFormatter)
115 
116  class Private;
117  Private *const d;
118  //@endcond
119 };
120 }
121 
HtmlForm
Describes the form of the HTML that is created.
Creates a div HTML element that can be embedded.
The interface for all contact formatters.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jun 23 2021 23:09:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.