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