Akonadi Contacts

abstractcontactgroupformatter.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 <QVariant>
14 
15 namespace KContacts
16 {
17 class ContactGroup;
18 }
19 
20 namespace Akonadi
21 {
22 class Item;
23 
24 /**
25  * @short The interface for all contact group formatters.
26  *
27  * This is the interface that can be used to format an Akonadi
28  * item with a contact group payload or a contact group itself as HTML.
29  *
30  * @see StandardContactGroupFormatter
31  * @author Tobias Koenig <[email protected]>
32  * @since 4.6
33  */
34 class AKONADI_CONTACT_EXPORT AbstractContactGroupFormatter
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 group formatter.
48  */
50 
51  /**
52  * Destroys the abstract contact group formatter.
53  */
55 
56  /**
57  * Sets the contact @p group that will be formatted.
58  */
59  void setContactGroup(const KContacts::ContactGroup &group);
60 
61  /**
62  * Returns the contact group that will be formatted.
63  */
64  Q_REQUIRED_RESULT KContacts::ContactGroup contactGroup() const;
65 
66  /**
67  * Sets the @p item who's payload will be formatted.
68  *
69  * @note The payload must be a valid KContacts::ContactGroup object.
70  *
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 additional @p fields that will be shown.
82  *
83  * The fields list contains a QVariantMap for each additional 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  * - value (string) The value of the field
88  *
89  * @param fields additional fields that will be shown
90  */
91  void setAdditionalFields(const QVector<QVariantMap> &fields);
92 
93  /**
94  * Returns the additional fields that will be shown.
95  */
96  Q_REQUIRED_RESULT QVector<QVariantMap> additionalFields() const;
97 
98  /**
99  * This method must be reimplemented to return the contact group formatted as HTML
100  * according to the requested @p form.
101  */
102  virtual QString toHtml(HtmlForm form = SelfcontainedForm) const = 0;
103 
104 private:
105  //@cond PRIVATE
106  Q_DISABLE_COPY(AbstractContactGroupFormatter)
107 
108  class Private;
109  Private *const d;
110  //@endcond
111 };
112 }
113 
The interface for all contact group formatters.
Creates a div HTML element that can be embedded.
HtmlForm
Describes the form of the HTML that is created.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Jun 18 2021 23:08:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.