• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
  • contact
contactdefaultactions.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "contactdefaultactions.h"
23 
24 #include "actions/dialphonenumberaction.h"
25 #include "actions/sendsmsaction.h"
26 #include "actions/showaddressaction.h"
27 
28 #include <kabc/address.h>
29 #include <kabc/addressee.h>
30 #include <kabc/phonenumber.h>
31 #include <kpimutils/email.h>
32 #include <ktoolinvocation.h>
33 
34 #include <QtCore/QUrl>
35 
36 using namespace Akonadi;
37 
38 ContactDefaultActions::ContactDefaultActions( QObject *parent )
39  : QObject( parent ), d( 0 )
40 {
41 }
42 
43 ContactDefaultActions::~ContactDefaultActions()
44 {
45 }
46 
47 void ContactDefaultActions::connectToView( QObject *view )
48 {
49  const QMetaObject *metaObject = view->metaObject();
50 
51  if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "urlClicked( const KUrl& )" ) ) != -1 ) {
52  connect( view, SIGNAL(urlClicked(KUrl)), SLOT(showUrl(KUrl)) );
53  }
54 
55  if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "emailClicked( const QString&, const QString& )" ) ) != -1 ) {
56  connect( view, SIGNAL(emailClicked(QString,QString)),
57  this, SLOT(sendEmail(QString,QString)) );
58  }
59 
60  if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "phoneNumberClicked( const KABC::PhoneNumber& )" ) ) != -1 ) {
61  connect( view, SIGNAL(phoneNumberClicked(KABC::PhoneNumber)),
62  this, SLOT(dialPhoneNumber(KABC::PhoneNumber)) );
63  }
64 
65  if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "smsClicked( const KABC::PhoneNumber& )" ) ) != -1 ) {
66  connect( view, SIGNAL(smsClicked(KABC::PhoneNumber)),
67  this, SLOT(sendSms(KABC::PhoneNumber)) );
68  }
69 
70  if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "addressClicked( const KABC::Address& )" ) ) != -1 ) {
71  connect( view, SIGNAL(addressClicked(KABC::Address)),
72  this, SLOT(showAddress(KABC::Address)) );
73  }
74 }
75 
76 void ContactDefaultActions::showUrl( const KUrl &url )
77 {
78  KToolInvocation::invokeBrowser( url.url() );
79 }
80 
81 void ContactDefaultActions::sendEmail( const QString &name, const QString &address )
82 {
83  KABC::Addressee contact;
84  contact.setNameFromString( name );
85 
86  KUrl url;
87  url.setProtocol( QLatin1String( "mailto" ) );
88  url.setPath( contact.fullEmail( address ) );
89  KToolInvocation::invokeMailer( url );
90 }
91 
92 void ContactDefaultActions::dialPhoneNumber( const KABC::PhoneNumber &number )
93 {
94  DialPhoneNumberAction action;
95  action.dialNumber( number );
96 }
97 
98 void ContactDefaultActions::sendSms( const KABC::PhoneNumber &number )
99 {
100  SendSmsAction action;
101  action.sendSms( number );
102 }
103 
104 void ContactDefaultActions::showAddress( const KABC::Address &address )
105 {
106  ShowAddressAction action;
107  action.showAddress( address );
108 }
109 
Akonadi::ContactDefaultActions::ContactDefaultActions
ContactDefaultActions(QObject *parent=0)
Creates a new contact default actions object.
Definition: contactdefaultactions.cpp:38
Akonadi::DialPhoneNumberAction
An action to dial the phone number of a contact.
Definition: dialphonenumberaction.h:36
Akonadi::ContactDefaultActions::showAddress
void showAddress(const KABC::Address &address)
Shows the address of a contact in a webbrowser or application as configured by the user in the genera...
Definition: contactdefaultactions.cpp:104
Akonadi::ContactDefaultActions::dialPhoneNumber
void dialPhoneNumber(const KABC::PhoneNumber &number)
Dials the given phone number with the application as configured by the user in the general settings d...
Definition: contactdefaultactions.cpp:92
Akonadi::ContactDefaultActions::connectToView
void connectToView(QObject *view)
Tries to connect the well known signals of the view to the well known slots of this object...
Definition: contactdefaultactions.cpp:47
Akonadi::ContactDefaultActions::showUrl
void showUrl(const KUrl &url)
Shows the given url in the users preferred webbrowser.
Definition: contactdefaultactions.cpp:76
Akonadi::ContactDefaultActions::sendSms
void sendSms(const KABC::PhoneNumber &number)
Sends a sms to number with the application as configured by the user in the general settings dialog...
Definition: contactdefaultactions.cpp:98
Akonadi::ShowAddressAction
A contact action to show the address of a contact on a map.
Definition: showaddressaction.h:53
Akonadi::ContactDefaultActions::sendEmail
void sendEmail(const QString &name, const QString &address)
Opens the users preferred mail composer and does the setup to send a mail to the contact with the giv...
Definition: contactdefaultactions.cpp:81
Akonadi::ContactDefaultActions::~ContactDefaultActions
virtual ~ContactDefaultActions()
Destroys the contact default actions object.
Definition: contactdefaultactions.cpp:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal