Akonadi Contacts

contactgroupviewer.h
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2009 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 <Akonadi/ItemMonitor>
14 
15 #include <QWidget>
16 
17 #include <memory>
18 
19 namespace Akonadi
20 {
21 class AbstractContactGroupFormatter;
22 class ContactGroupViewerPrivate;
23 
24 /**
25  * @short A viewer component for contact groups in Akonadi.
26  *
27  * This widgets provides a way to show a contact group from the
28  * Akonadi storage.
29  *
30  * Example:
31  *
32  * @code
33  *
34  * using namespace Akonadi;
35  *
36  * const Item group = ...
37  *
38  * ContactGroupViewer *viewer = new ContactGroupViewer( this );
39  * viewer->setContactGroup( group );
40  *
41  * @endcode
42  *
43  * @author Tobias Koenig <[email protected]>
44  * @since 4.4
45  */
46 class AKONADI_CONTACT_EXPORT ContactGroupViewer : public QWidget, public Akonadi::ItemMonitor
47 {
48  Q_OBJECT
49 
50 public:
51  /**
52  * Creates a new contact group viewer.
53  *
54  * @param parent The parent widget.
55  */
56  explicit ContactGroupViewer(QWidget *parent = nullptr);
57 
58  /**
59  * Destroys the contact group viewer.
60  */
61  ~ContactGroupViewer() override;
62 
63  /**
64  * Returns the contact group that is currently displayed.
65  */
66  Akonadi::Item contactGroup() const;
67 
68  /**
69  * Sets the contact group @p formatter that should be used for formatting the
70  * contact group. If formatter is @c 0, the standard formatter will be used.
71  * @param formatter the formatter to use
72  * @note The contact viewer won't take ownership of the formatter.
73  * @since 4.6
74  */
75  void setContactGroupFormatter(AbstractContactGroupFormatter *formatter);
76 
77  /**
78  * @since 5.20.41
79  */
80  void updateView();
81 
82 public Q_SLOTS:
83  /**
84  * Sets the contact @p group that shall be displayed in the viewer.
85  */
86  void setContactGroup(const Akonadi::Item &group);
87 
88 Q_SIGNALS:
89  /**
90  * This signal is emitted whenever the user has clicked on
91  * an email address in the viewer.
92  *
93  * @param name The name of the contact.
94  * @param email The plain email address of the contact.
95  */
96  void emailClicked(const QString &name, const QString &email);
97 
98 private:
99  /**
100  * This method is called whenever the displayed contact @p group has been changed.
101  */
102  AKONADI_CONTACT_NO_EXPORT void itemChanged(const Item &group) override;
103 
104  /**
105  * This method is called whenever the displayed contact group has been
106  * removed from Akonadi.
107  */
108  AKONADI_CONTACT_NO_EXPORT void itemRemoved() override;
109 
110 private:
111  //@cond PRIVATE
112  std::unique_ptr<ContactGroupViewerPrivate> const d;
113  //@endcond
114 };
115 }
The interface for all contact group formatters.
A viewer component for contact groups in Akonadi.
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.