Akonadi Contacts

contactdefaultactions.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 <QObject>
14 
15 class QUrl;
16 
17 namespace KContacts
18 {
19 class Address;
20 class PhoneNumber;
21 }
22 
23 namespace Akonadi
24 {
25 /**
26  * @short A convenience class that handles different contact related actions.
27  *
28  * This class handles contact related actions like opening an email address,
29  * showing the address of a contact on a map etc.
30  *
31  * Example:
32  *
33  * @code
34  *
35  * using namespace Akonadi;
36  *
37  * const Item contact = ...
38  *
39  * ContactViewer *viewer = new ContactViewer( this );
40  * viewer->setContact( contact );
41  *
42  * ContactDefaultActions *actions = new ContactDefaultActions( this );
43  * actions->connectToView( viewer );
44  * @endcode
45  *
46  * If you want to use the full functionality of ContactDefaultActions
47  * but customize a single action (e.g. handling sending mail differently)
48  * the following can be done:
49  *
50  * @code
51  *
52  * using namespace Akonadi;
53  *
54  * ContactViewer *viewer = new ContactViewer( this );
55  * ContactDefaultActions *actions = new ContactDefaultActions( this );
56  *
57  * // first connect all actions
58  * actions->connectToView( viewer );
59  *
60  * // then remove the signle/slot connection you want to overwrite
61  * disconnect( viewer, SIGNAL(emailClicked(QString,QString)),
62  * actions, SLOT(sendEmail(QString,QString)) );
63  *
64  * // connect to your custom implementation
65  * connect( viewer, SIGNAL(emailClicked(QString,QString)),
66  * this, SLOT(handleSpecial(QString,QString)) );
67  *
68  * @endcode
69  *
70  * @author Tobias Koenig <[email protected]>
71  * @since 4.4
72  */
73 class AKONADI_CONTACT_EXPORT ContactDefaultActions : public QObject
74 {
75  Q_OBJECT
76 
77 public:
78  /**
79  * Creates a new contact default actions object.
80  *
81  * @param parent The parent object.
82  */
83  explicit ContactDefaultActions(QObject *parent = nullptr);
84 
85  /**
86  * Destroys the contact default actions object.
87  */
88  ~ContactDefaultActions() override;
89 
90  /**
91  * Tries to connect the well known signals of the @p view
92  * to the well known slots of this object.
93  */
94  void connectToView(QObject *view);
95 
96 public Q_SLOTS:
97  /**
98  * Shows the given @p url in the users preferred webbrowser.
99  */
100  void showUrl(const QUrl &url);
101 
102  /**
103  * Opens the users preferred mail composer and does the setup
104  * to send a mail to the contact with the given @p name and
105  * email @p address.
106  */
107  void sendEmail(const QString &name, const QString &address);
108 
109  /**
110  * Dials the given phone @p number with the application as
111  * configured by the user in the general settings dialog.
112  */
113  void dialPhoneNumber(const KContacts::PhoneNumber &number);
114 
115  /**
116  * Sends a sms to @p number with the application as
117  * configured by the user in the general settings dialog.
118  */
119  void sendSms(const KContacts::PhoneNumber &number);
120 
121  /**
122  * Shows the @p address of a contact in a webbrowser or application
123  * as configured by the user in the general settings dialog.
124  */
125  void showAddress(const KContacts::Address &address);
126 
127 private:
128  //@cond PRIVATE
129  class Private;
130  Private *const d;
131  //@endcond PRIVATE
132 };
133 }
134 
A convenience class that handles different contact related actions.
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.