akonadi/contact
contactdefaultactions.cpp
00001 /* 00002 This file is part of Akonadi Contact. 00003 00004 Copyright (c) 2009 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU Library General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or (at your 00009 option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to the 00018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 02110-1301, USA. 00020 */ 00021 00022 #include "contactdefaultactions.h" 00023 00024 #include "actions/dialphonenumberaction.h" 00025 #include "actions/sendsmsaction.h" 00026 #include "actions/showaddressaction.h" 00027 00028 #include <kabc/address.h> 00029 #include <kabc/addressee.h> 00030 #include <kabc/phonenumber.h> 00031 #include <kpimutils/email.h> 00032 #include <ktoolinvocation.h> 00033 00034 #include <QtCore/QUrl> 00035 00036 using namespace Akonadi; 00037 00038 ContactDefaultActions::ContactDefaultActions( QObject *parent ) 00039 : QObject( parent ), d( 0 ) 00040 { 00041 } 00042 00043 ContactDefaultActions::~ContactDefaultActions() 00044 { 00045 } 00046 00047 void ContactDefaultActions::connectToView( QObject *view ) 00048 { 00049 const QMetaObject *metaObject = view->metaObject(); 00050 00051 if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "urlClicked( const KUrl& )" ) ) != -1 ) 00052 connect( view, SIGNAL(urlClicked(KUrl)), SLOT(showUrl(KUrl)) ); 00053 00054 if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "emailClicked( const QString&, const QString& )" ) ) != -1 ) 00055 connect( view, SIGNAL(emailClicked(QString,QString)), 00056 this, SLOT(sendEmail(QString,QString)) ); 00057 00058 if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "phoneNumberClicked( const KABC::PhoneNumber& )" ) ) != -1 ) 00059 connect( view, SIGNAL(phoneNumberClicked(KABC::PhoneNumber)), 00060 this, SLOT(dialPhoneNumber(KABC::PhoneNumber)) ); 00061 00062 if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "smsClicked( const KABC::PhoneNumber& )" ) ) != -1 ) 00063 connect( view, SIGNAL(smsClicked(KABC::PhoneNumber)), 00064 this, SLOT(sendSms(KABC::PhoneNumber)) ); 00065 00066 if ( metaObject->indexOfSignal( QMetaObject::normalizedSignature( "addressClicked( const KABC::Address& )" ) ) != -1 ) 00067 connect( view, SIGNAL(addressClicked(KABC::Address)), 00068 this, SLOT(showAddress(KABC::Address)) ); 00069 } 00070 00071 void ContactDefaultActions::showUrl( const KUrl &url ) 00072 { 00073 KToolInvocation::invokeBrowser( url.url() ); 00074 } 00075 00076 void ContactDefaultActions::sendEmail( const QString &name, const QString &address ) 00077 { 00078 KABC::Addressee contact; 00079 contact.setNameFromString( name ); 00080 00081 KUrl url; 00082 url.setProtocol( QLatin1String( "mailto" ) ); 00083 url.setPath( contact.fullEmail( address ) ); 00084 KToolInvocation::invokeMailer( url ); 00085 } 00086 00087 void ContactDefaultActions::dialPhoneNumber( const KABC::PhoneNumber &number ) 00088 { 00089 DialPhoneNumberAction action; 00090 action.dialNumber( number ); 00091 } 00092 00093 void ContactDefaultActions::sendSms( const KABC::PhoneNumber &number ) 00094 { 00095 SendSmsAction action; 00096 action.sendSms( number ); 00097 } 00098 00099 void ContactDefaultActions::showAddress( const KABC::Address &address ) 00100 { 00101 ShowAddressAction action; 00102 action.showAddress( address ); 00103 } 00104 00105 #include "contactdefaultactions.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:42 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:42 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.