• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmobiletools

addressdetails.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    Copyright (C) 2007
00003    by Marco Gulino <marco@kmobiletools.org>
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the
00017    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019  ***************************************************************************/
00020  
00021 #include "addressdetails.h"
00022 
00023 #include <kabc/phonenumber.h>
00024 #include <kiconloader.h>
00025 #include <klocale.h>
00026 #include <kglobalsettings.h>
00027 #include <kdebug.h>
00028 #include <QTextDocument>
00029 
00030 #include <libkmobiletools/kmobiletoolshelper.h>
00031 #include <libkmobiletools/engine.h>
00032 #include <libkmobiletools/devicesconfig.h>
00033 #include <popupnumber.h>
00034 #include <popupaddressee.h>
00035 
00036 using namespace KMobileTools;
00037 
00038 addressDetails::addressDetails(QWidget *parentWidget, const QString &objectname,QObject *parent)
00039  : KHTMLPart(parentWidget, parent)
00040 {
00041     setObjectName(objectname);
00042     kDebug() <<"addressDetails:: device name:" << objectName();
00043     connect(this, SIGNAL(popupMenu(const QString &,const QPoint &)), SLOT(popupMenu ( const QString &, const QPoint &) ) );
00044     connect( browserExtension(), SIGNAL( openUrlRequest(const KUrl &, const KParts::OpenUrlArguments &, const KParts::BrowserArguments &) ), this, SLOT( openUrlRequest(const KUrl &) ) );
00045     showHP();
00046 }
00047 
00048 
00049 addressDetails::~addressDetails()
00050 {
00051 }
00052 
00053 
00054 #include "addressdetails.moc"
00055 
00056 const QString addressDetails::getTemplate()
00057 {
00058     return  KMobiletoolsHelper::getTemplate()
00059             .arg( KMobiletoolsHelper::getFooterLink( i18nc("Add new contact", "Add new"), "contact-add", "contact:add" ) )
00060             .arg( KMobiletoolsHelper::getFooterLink( i18nc("Fetch phonebook from the mobile", "Reload"), "view-refresh", "contact:refresh" ) )
00061             .arg( KMobiletoolsHelper::getFooterLink( i18nc("Import phonebook", "Import"), "document-import", "contact:import" ) )
00062             .arg( KMobiletoolsHelper::getFooterLink( i18nc("Export phonebook", "Export"), "document-export", "contact:export" ) );
00063 }
00067 void addressDetails::showAddressee(const KABC::Addressee &addressee, bool readOnly)
00068 {
00069     if(addressee.isEmpty()) return;
00070     ro=readOnly;
00071     QString htmlData; // ="<img src=\"%1\" align=\"middle\"> <b><i>%2</b>";
00072 //     htmlData=htmlData.arg( KIconLoader::global()->iconPath("x-office-contact", KIcon::Desktop, false) ).arg( addressee.formattedName() );
00073     /*="<div style=\"border-bottom-style : hidden; border-bottom-width : 10; border-left-style : hidden;\
00074         border-left-width : 5; border-right-style : hidden; border-right-width : 5; border-spacing : 5; border-top-style :\
00075         hidden; border-top-width : 10;background-color: %1; color: %2\">\
00076     <img src=\"%3\" align=\"middle\"> <b><i>%4</b></i></div>\n\n";*/
00077     QString renderData=getTemplate().arg( KIconLoader::global()->iconPath("x-office-contact", -KIconLoader::SizeHuge, false) )
00078             .arg( addressee.formattedName() );
00079     if(readOnly) renderData=renderData.arg(QString() ).arg(QString() );
00080     else renderData=renderData
00081             .arg( KMobiletoolsHelper::getFooterLink( i18nc("Edit Contact", "Edit") , "document-properties", "contact:edit" ) )
00082             .arg( KMobiletoolsHelper::getFooterLink( i18nc("Delete Contact", "Delete") , "edit-delete", "contact:del" ) );
00083     /*
00084     htmlData = htmlData
00085                 .arg( KGlobalSettings::activeTitleColor().name() )
00086                 .arg( KGlobalSettings::activeTextColor().name() )
00087                 .arg( KIconLoader::global()->iconPath("x-office-contact", KIconLoader::Desktop, false) ).arg( addressee.formattedName() );
00088     */
00089     KABC::PhoneNumber::List numberList = addressee.phoneNumbers();
00090     for ( KABC::PhoneNumber::List::Iterator it = numberList.begin(); it != numberList.end(); it++ )
00091     {
00092         htmlData += QString("<p><b>%1:</b> <a href=\"number:").arg( (*it).typeLabel() );
00093         htmlData+=QString::fromLatin1( KUrl::toPercentEncoding( (*it).number(), "/" ) )
00094                 + "\">" +Qt::escape( (*it).number() ) + "</a></p>\n";
00095     }
00096 
00097     QString storedOn;
00098     switch( addressee.custom("KMobileTools","memslot").toInt() ){
00099         case KMobileTools::Engine::PB_SIM:
00100             storedOn=PB_SIM_TEXT;
00101             break;
00102         case KMobileTools::Engine::PB_Phone:
00103             storedOn=PB_PHONE_TEXT;
00104             break;
00105         case KMobileTools::Engine::PB_DataCard:
00106             storedOn=PB_DATACARD_TEXT;
00107             break;
00108         default:
00109             storedOn=i18n("not available");
00110     }
00111     
00112     htmlData+=i18n("<p>Stored on: <b>%1</b></p>", storedOn);
00113 /*    htmlData+=QString("<div style=\"border-bottom-style : hidden; border-bottom-width : 10; border-left-style : hidden;\
00114             border-left-width : 5; border-right-style : hidden; border-right-width : 5; border-spacing : 5; border-top-style :\
00115             hidden; border-top-width : 10; position: absolute; bottom: 10px; left: 10px; right: 10px; background-color: %3; color: %4\" align=\"right\"><a href=\"contact:edit\">%1</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"contact:refresh\">%2</a></div>")
00116             .arg( i18n("Edit contact") ).arg(i18n ("Reload list") )
00117             .arg( KGlobalSettings::activeTitleColor().name() )
00118             .arg( KGlobalSettings::activeTextColor().name() );*/
00119     renderData=renderData.arg(htmlData );
00120     begin();
00121     write( renderData );
00122     end();
00123     p_addressee=addressee;
00124 }
00125 
00126 
00130 void addressDetails::popupMenu ( const QString &url, const QPoint &point)
00131 {
00132     KUrl kurl(url);
00133     KMenu *popup=0;
00134     if(kurl.protocol()=="number")
00135         popup=new popupNumber(objectName(), kurl.path(), 0);
00136     if( url.isNull() )
00137     {
00138         if(p_addressee.isEmpty()) return;
00139         popup=new popupAddressee(objectName(), p_addressee, 0, ro );
00140         connect(popup, SIGNAL( editClicked(KABC::Addressee) ), this, SIGNAL(editClicked(KABC::Addressee) ) );
00141         connect(popup, SIGNAL( delContact() ), this, SIGNAL(delContact() ) );
00142     }
00143     if(!popup) return;
00144     popup->exec(point);
00145 }
00146 
00147 
00148 void addressDetails::openUrlRequest(const KUrl &url)
00149 {
00150     if(url.path() == "refresh") emit refreshClicked();
00151     if(url.path() == "edit") emit editClicked(p_addressee);
00152     if(url.path() == "add" ) emit addContact();
00153     if(url.path() == "del" ) emit delContact();
00154     if(url.path() == "import") emit importPB();
00155     if(url.path() == "export") emit exportPB();
00156     if(url.protocol() == "number") emit dial(url.path() );
00157 }
00158 
00159 
00163 void addressDetails::showHP()
00164 {
00165     begin();
00166     write( getTemplate().arg(KIconLoader::global()->iconPath("view-pim-contacts", -KIconLoader::SizeHuge, false) )
00167             .arg( i18n("%1 AddressBook", DEVCFG(objectName() )->devicename() ) )
00168             .arg("")            .arg("")
00169             .arg( i18n("<p><i>Click a contact on the left list to see details, or \"Reload\" to update the contacts list.</i></p>") )
00170          );
00171     end();
00172     p_addressee=KABC::Addressee();
00173 }

kmobiletools

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal