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 #include <memory>
16 
17 namespace KContacts
18 {
19 class ContactGroup;
20 }
21 
22 namespace Akonadi
23 {
24 class Item;
25 class 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 <[email protected]>
35  * @since 4.6
36  */
37 class AKONADI_CONTACT_EXPORT AbstractContactGroupFormatter
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 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  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT 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 QVector<QVariantMap> &fields);
95 
96  /**
97  * Returns the additional fields that will be shown.
98  */
99  Q_REQUIRED_RESULT QVector<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 
107 private:
108  //@cond PRIVATE
109  Q_DISABLE_COPY(AbstractContactGroupFormatter)
110 
111  std::unique_ptr<AbstractContactGroupFormatterPrivate> const d;
112  //@endcond
113 };
114 }
HtmlForm
Describes the form of the HTML that is created.
The interface for all contact group formatters.
@ EmbeddableForm
Creates a div HTML element that can be embedded.
@ SelfcontainedForm
Creates a complete HTML document.
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.