00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <qbuffer.h>
00023 #include <qimage.h>
00024 #include <qpopupmenu.h>
00025 #include <qurl.h>
00026
00027 #include <kabc/address.h>
00028 #include <kabc/addressee.h>
00029 #include <kabc/phonenumber.h>
00030 #include <kactionclasses.h>
00031 #include <kapplication.h>
00032 #include <kconfig.h>
00033 #include <kglobal.h>
00034 #include <kglobalsettings.h>
00035 #include <kiconloader.h>
00036 #include <kio/job.h>
00037 #include <klocale.h>
00038 #include <kmdcodec.h>
00039 #include <kmessagebox.h>
00040 #include <krun.h>
00041 #include <kstringhandler.h>
00042 #include <ktempfile.h>
00043
00044 #include <kdebug.h>
00045
00046 #include "addresseeview.h"
00047
00048 using namespace KPIM;
00049
00050 AddresseeView::AddresseeView( QWidget *parent, const char *name,
00051 KConfig *config )
00052 : KTextBrowser( parent, name ), mDefaultConfig( false ), mImageJob( 0 ),
00053 mLinkMask( AddressLinks | EmailLinks | PhoneLinks | URLLinks | IMLinks )
00054 {
00055 setWrapPolicy( QTextEdit::AtWordBoundary );
00056 setLinkUnderline( false );
00057 setVScrollBarMode( QScrollView::AlwaysOff );
00058 setHScrollBarMode( QScrollView::AlwaysOff );
00059
00060 QStyleSheet *sheet = styleSheet();
00061 QStyleSheetItem *link = sheet->item( "a" );
00062 link->setColor( KGlobalSettings::linkColor() );
00063
00064 connect( this, SIGNAL( mailClick( const QString&, const QString& ) ),
00065 this, SLOT( slotMailClicked( const QString&, const QString& ) ) );
00066 connect( this, SIGNAL( urlClick( const QString& ) ),
00067 this, SLOT( slotUrlClicked( const QString& ) ) );
00068 connect( this, SIGNAL( highlighted( const QString& ) ),
00069 this, SLOT( slotHighlighted( const QString& ) ) );
00070
00071 setNotifyClick( true );
00072
00073 mActionShowBirthday = new KToggleAction( i18n( "Show Birthday" ) );
00074 mActionShowAddresses = new KToggleAction( i18n( "Show Postal Addresses" ) );
00075 mActionShowEmails = new KToggleAction( i18n( "Show Email Addresses" ) );
00076 mActionShowPhones = new KToggleAction( i18n( "Show Telephone Numbers" ) );
00077 mActionShowURLs = new KToggleAction( i18n( "Show Web Pages (URLs)" ) );
00078 #if KDE_IS_VERSION(3,2,90)
00079 mActionShowBirthday->setCheckedState(i18n("Hide Birthday"));
00080 mActionShowAddresses->setCheckedState(i18n("Hide Postal Addresses"));
00081 mActionShowEmails->setCheckedState(i18n("Hide Email Addresses"));
00082 mActionShowPhones->setCheckedState(i18n("Hide Telephone Numbers"));
00083 mActionShowURLs->setCheckedState(i18n("Hide Web Pages (URLs)"));
00084 #endif
00085
00086 connect( mActionShowBirthday, SIGNAL( toggled( bool ) ), SLOT( configChanged() ) );
00087 connect( mActionShowAddresses, SIGNAL( toggled( bool ) ), SLOT( configChanged() ) );
00088 connect( mActionShowEmails, SIGNAL( toggled( bool ) ), SLOT( configChanged() ) );
00089 connect( mActionShowPhones, SIGNAL( toggled( bool ) ), SLOT( configChanged() ) );
00090 connect( mActionShowURLs, SIGNAL( toggled( bool ) ), SLOT( configChanged() ) );
00091
00092 if ( !config ) {
00093 mConfig = new KConfig( "kaddressbookrc" );
00094 mDefaultConfig = true;
00095 } else
00096 mConfig = config;
00097
00098 load();
00099
00100
00101 mKIMProxy = ::KIMProxy::instance( kapp->dcopClient() );
00102 connect( mKIMProxy, SIGNAL( sigContactPresenceChanged( const QString & ) ), this, SLOT( slotPresenceChanged( const QString & ) ) );
00103 connect( mKIMProxy, SIGNAL( sigPresenceInfoExpired() ), this, SLOT( slotPresenceInfoExpired() ) );
00104 }
00105
00106 AddresseeView::~AddresseeView()
00107 {
00108 if ( mDefaultConfig )
00109 delete mConfig;
00110 mConfig = 0;
00111
00112 delete mActionShowBirthday;
00113 delete mActionShowAddresses;
00114 delete mActionShowEmails;
00115 delete mActionShowPhones;
00116 delete mActionShowURLs;
00117
00118 mKIMProxy = 0;
00119 }
00120
00121 void AddresseeView::setAddressee( const KABC::Addressee& addr )
00122 {
00123 mAddressee = addr;
00124
00125 if ( mImageJob ) {
00126 mImageJob->kill();
00127 mImageJob = 0;
00128 }
00129
00130 mImageData.truncate( 0 );
00131
00132 updateView();
00133 }
00134
00135 void AddresseeView::enableLinks( int linkMask )
00136 {
00137 mLinkMask = linkMask;
00138 }
00139
00140 QString AddresseeView::vCardAsHTML( const KABC::Addressee& addr, ::KIMProxy *proxy, int linkMask,
00141 bool internalLoading,
00142 bool showBirthday, bool showAddresses,
00143 bool showEmails, bool showPhones, bool showURLs,
00144 bool showIMAddresses )
00145 {
00146 QString image = QString( "contact_%1_image" ).arg( addr.uid() );
00147
00148
00149
00150
00151
00152
00153
00154
00155 QString backgroundColor = KGlobalSettings::alternateBackgroundColor().name();
00156 QString cellStyle = QString::fromLatin1(
00157 "style=\""
00158 "padding-right: 2px; "
00159 "border-right: #000 dashed 1px; "
00160 "background: %1;\"").arg(backgroundColor);
00161 QString backgroundColor2 = KGlobalSettings::baseColor().name();
00162 QString cellStyle2 = QString::fromLatin1(
00163 "style=\""
00164 "padding-left: 2px; "
00165 "background: %1;\"").arg(backgroundColor2);
00166 QString tableStyle = QString::fromLatin1(
00167 "style=\""
00168 "border: solid 1px; "
00169 "margin: 0em;\"");
00170
00171
00172
00173
00174 QString rowFmtStr = QString::fromLatin1(
00175 "<tr>"
00176 "<td align=\"right\" valign=\"top\" width=\"30%\" ");
00177 rowFmtStr.append( cellStyle );
00178 rowFmtStr.append( QString::fromLatin1(
00179 ">"
00180 "<b>%1</b>"
00181 "</td>"
00182 "<td align=\"left\" valign=\"top\" width=\"70%\" ") );
00183 rowFmtStr.append( cellStyle2 );
00184 rowFmtStr.append( QString::fromLatin1(
00185 ">"
00186 "%2"
00187 "</td>"
00188 "</tr>\n"
00189 ) );
00190
00191
00192 QString dynamicPart;
00193
00194
00195 if ( !internalLoading ) {
00196 KABC::Picture pic = addr.photo();
00197 if ( pic.isIntern() && !pic.data().isNull() ) {
00198 image = pixmapAsDataUrl( pic.data() );
00199 } else if ( !pic.url().isEmpty() ) {
00200 image = (pic.url().startsWith( "http://" ) || pic.url().startsWith( "https://" ) ? pic.url() : "http://" + pic.url());
00201 } else {
00202 image = "file:" + KGlobal::iconLoader()->iconPath( "personal", KIcon::Desktop );
00203 }
00204 }
00205
00206 if ( showBirthday ) {
00207 QDate date = addr.birthday().date();
00208
00209 if ( date.isValid() )
00210 dynamicPart += rowFmtStr
00211 .arg( KABC::Addressee::birthdayLabel() )
00212 .arg( KGlobal::locale()->formatDate( date, true ) );
00213 }
00214
00215 if ( showPhones ) {
00216 KABC::PhoneNumber::List phones = addr.phoneNumbers();
00217 KABC::PhoneNumber::List::ConstIterator phoneIt;
00218 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
00219 QString number = (*phoneIt).number();
00220
00221 QString url;
00222 if ( (*phoneIt).type() & KABC::PhoneNumber::Fax )
00223 url = QString::fromLatin1( "fax:" ) + number;
00224 else
00225 url = QString::fromLatin1( "phone:" ) + number;
00226
00227 if ( linkMask & PhoneLinks ) {
00228 dynamicPart += rowFmtStr
00229 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ).replace( " ", " " ) )
00230 .arg( QString::fromLatin1( "<a href=\"%1\">%2</a>" ).arg(url).arg(number) );
00231 } else {
00232 dynamicPart += rowFmtStr
00233 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ).replace( " ", " " ) )
00234 .arg( number );
00235 }
00236 }
00237 }
00238
00239 if ( showEmails ) {
00240 QStringList emails = addr.emails();
00241 QStringList::ConstIterator emailIt;
00242 QString type = i18n( "Email" );
00243 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) {
00244 QString fullEmail = addr.fullEmail( *emailIt );
00245 QUrl::encode( fullEmail );
00246
00247 if ( linkMask & EmailLinks ) {
00248 dynamicPart += rowFmtStr.arg( type )
00249 .arg( QString::fromLatin1( "<a href=\"mailto:%1\">%2</a>" )
00250 .arg( fullEmail, *emailIt ) );
00251 } else {
00252 dynamicPart += rowFmtStr.arg( type ).arg( *emailIt );
00253 }
00254
00255 type = i18n( "Other" );
00256 }
00257 }
00258
00259 if ( showURLs ) {
00260 if ( !addr.url().url().isEmpty() ) {
00261 if ( linkMask & URLLinks ) {
00262 QString url = (addr.url().url().startsWith( "http://" ) || addr.url().url().startsWith( "https://" ) ? addr.url().url() :
00263 "http://" + addr.url().url());
00264 dynamicPart += rowFmtStr
00265 .arg( i18n( "Homepage" ) )
00266 .arg( KStringHandler::tagURLs( url ) );
00267 } else {
00268 dynamicPart += rowFmtStr
00269 .arg( i18n( "Homepage" ) )
00270 .arg( addr.url().url() );
00271 }
00272 }
00273 }
00274
00275 if ( showAddresses ) {
00276 KABC::Address::List addresses = addr.addresses();
00277 KABC::Address::List::ConstIterator addrIt;
00278 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
00279 if ( (*addrIt).label().isEmpty() ) {
00280 QString formattedAddress;
00281
00282 #if KDE_IS_VERSION(3,1,90)
00283 formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
00284 #else
00285 if ( !(*addrIt).street().isEmpty() )
00286 formattedAddress += (*addrIt).street() + "\n";
00287
00288 if ( !(*addrIt).postOfficeBox().isEmpty() )
00289 formattedAddress += (*addrIt).postOfficeBox() + "\n";
00290
00291 formattedAddress += (*addrIt).locality() + QString::fromLatin1(" ") + (*addrIt).region();
00292
00293 if ( !(*addrIt).postalCode().isEmpty() )
00294 formattedAddress += QString::fromLatin1(", ") + (*addrIt).postalCode();
00295
00296 formattedAddress += "\n";
00297
00298 if ( !(*addrIt).country().isEmpty() )
00299 formattedAddress += (*addrIt).country() + "\n";
00300
00301 formattedAddress += (*addrIt).extended();
00302 #endif
00303
00304 formattedAddress = formattedAddress.replace( '\n', "<br>" );
00305
00306 QString link = "<a href=\"addr:" + (*addrIt).id() + "\">" +
00307 formattedAddress + "</a>";
00308
00309 if ( linkMask & AddressLinks ) {
00310 dynamicPart += rowFmtStr
00311 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
00312 .arg( link );
00313 } else {
00314 dynamicPart += rowFmtStr
00315 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
00316 .arg( formattedAddress );
00317 }
00318 } else {
00319 QString link = "<a href=\"addr:" + (*addrIt).id() + "\">" +
00320 (*addrIt).label().replace( '\n', "<br>" ) + "</a>";
00321
00322 if ( linkMask & AddressLinks ) {
00323 dynamicPart += rowFmtStr
00324 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
00325 .arg( link );
00326 } else {
00327 dynamicPart += rowFmtStr
00328 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
00329 .arg( (*addrIt).label().replace( '\n', "<br>" ) );
00330 }
00331 }
00332 }
00333 }
00334
00335 QString notes;
00336 if ( !addr.note().isEmpty() ) {
00337
00338
00339
00340 notes = rowFmtStr.arg( i18n( "Notes" ) ).arg( addr.note().replace( '\n', "<br>" ) ) ;
00341 }
00342
00343 QString name( addr.realName() );
00344 QString role( addr.role() );
00345 QString organization( addr.organization() );
00346
00347 if ( proxy && showIMAddresses )
00348 {
00349 if ( proxy->isPresent( addr.uid() ) )
00350 {
00351
00352 QString imgSrc;
00353 if ( internalLoading )
00354 {
00355 imgSrc = QString::fromLatin1( "im_status_%1_image").arg( addr.uid() );
00356 QMimeSourceFactory::defaultFactory()->setPixmap( imgSrc, proxy->presenceIcon( addr.uid() ) );
00357 }
00358 else
00359 imgSrc = pixmapAsDataUrl( proxy->presenceIcon( addr.uid() ) );
00360
00361
00362 QString imStatus;
00363 if ( linkMask & IMLinks )
00364 imStatus = QString::fromLatin1( "<a href=\"im:\"><img src=\"%1\"> (%2)</a>" );
00365 else
00366 imStatus = QString::fromLatin1( "<img src=\"%1\"> (%2)" );
00367
00368
00369 dynamicPart += rowFmtStr
00370 .arg( i18n( "Presence" ) )
00371 .arg( imStatus
00372 .arg( imgSrc )
00373 .arg( proxy->presenceString( addr.uid() ) )
00374 );
00375 }
00376 }
00377
00378
00379
00380
00381
00382
00383 QString strAddr = QString::fromLatin1(
00384 "<div align=\"center\">"
00385 "<table cellpadding=\"1\" cellspacing=\"0\" %1>"
00386 "<tr>").arg(tableStyle);
00387
00388 strAddr.append( QString::fromLatin1(
00389 "<td align=\"right\" valign=\"top\" width=\"30%\" rowspan=\"3\" %2>")
00390 .arg( cellStyle ) );
00391 strAddr.append( QString::fromLatin1(
00392 "<img src=\"%1\" width=\"50\" vspace=\"1\">"
00393 "</td>")
00394 .arg( image ) );
00395 strAddr.append( QString::fromLatin1(
00396 "<td align=\"left\" width=\"70%\" %2>")
00397 .arg( cellStyle2 ) );
00398 strAddr.append( QString::fromLatin1(
00399 "<font size=\"+2\"><b>%2</b></font></td>"
00400 "</tr>")
00401 .arg( name ) );
00402 strAddr.append( QString::fromLatin1(
00403 "<tr>"
00404 "<td align=\"left\" width=\"70%\" %2>")
00405 .arg( cellStyle2 ) );
00406 strAddr.append( QString::fromLatin1(
00407 "%3</td>"
00408 "</tr>")
00409 .arg( role ) );
00410 strAddr.append( QString::fromLatin1(
00411 "<tr>"
00412 "<td align=\"left\" width=\"70%\" %2>")
00413 .arg( cellStyle2 ) );
00414 strAddr.append( QString::fromLatin1(
00415 "%4</td>"
00416 "</tr>")
00417 .arg( organization ) );
00418 strAddr.append( QString::fromLatin1(
00419 "<tr><td %2>")
00420 .arg( cellStyle ) );
00421 strAddr.append( QString::fromLatin1(
00422 " </td><td %2> </td></tr>")
00423 .arg( cellStyle2 ) );
00424 strAddr.append(dynamicPart);
00425 strAddr.append(notes);
00426 strAddr.append( QString::fromLatin1("</table></div>\n") );
00427
00428 return strAddr;
00429 }
00430
00431 QString AddresseeView::pixmapAsDataUrl( const QPixmap& pixmap )
00432 {
00433 QByteArray ba;
00434 QBuffer buffer( ba );
00435 buffer.open( IO_WriteOnly );
00436 pixmap.save( &buffer, "PNG" );
00437 QString encoded( "data:image/png;base64," );
00438 encoded.append( KCodecs::base64Encode( ba ) );
00439 return encoded;
00440 }
00441
00442 void AddresseeView::updateView()
00443 {
00444
00445 setText( QString::null );
00446
00447 if ( mAddressee.isEmpty() )
00448 return;
00449
00450 if ( mImageJob ) {
00451 mImageJob->kill();
00452 mImageJob = 0;
00453
00454 mImageData.truncate( 0 );
00455 }
00456
00457 QString strAddr = vCardAsHTML( mAddressee, mKIMProxy, mLinkMask, true,
00458 mActionShowBirthday->isChecked(),
00459 mActionShowAddresses->isChecked(),
00460 mActionShowEmails->isChecked(),
00461 mActionShowPhones->isChecked(),
00462 mActionShowURLs->isChecked() );
00463
00464 strAddr = QString::fromLatin1(
00465 "<html>"
00466 "<body text=\"%1\" bgcolor=\"%2\">"
00467 "%3"
00468 "</body>"
00469 "</html>" )
00470 .arg( KGlobalSettings::textColor().name() )
00471 .arg( KGlobalSettings::baseColor().name() )
00472 .arg( strAddr );
00473
00474 QString imageURL = QString( "contact_%1_image" ).arg( mAddressee.uid() );
00475
00476 KABC::Picture picture = mAddressee.photo();
00477 if ( picture.isIntern() && !picture.data().isNull() )
00478 QMimeSourceFactory::defaultFactory()->setImage( imageURL, picture.data() );
00479 else {
00480 if ( !picture.url().isEmpty() ) {
00481 if ( mImageData.count() > 0 )
00482 QMimeSourceFactory::defaultFactory()->setImage( imageURL, mImageData );
00483 else {
00484 mImageJob = KIO::get( KURL( picture.url() ), false, false );
00485 connect( mImageJob, SIGNAL( data( KIO::Job*, const QByteArray& ) ),
00486 this, SLOT( data( KIO::Job*, const QByteArray& ) ) );
00487 connect( mImageJob, SIGNAL( result( KIO::Job* ) ),
00488 this, SLOT( result( KIO::Job* ) ) );
00489 }
00490 } else {
00491 QMimeSourceFactory::defaultFactory()->setPixmap( imageURL,
00492 KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 128 ) );
00493 }
00494 }
00495
00496
00497 setText( strAddr );
00498 }
00499
00500 KABC::Addressee AddresseeView::addressee() const
00501 {
00502 return mAddressee;
00503 }
00504
00505 void AddresseeView::urlClicked( const QString &url )
00506 {
00507 kapp->invokeBrowser( url );
00508 }
00509
00510 void AddresseeView::emailClicked( const QString &email )
00511 {
00512 kapp->invokeMailer( email, QString::null );
00513 }
00514
00515 void AddresseeView::phoneNumberClicked( const QString &number )
00516 {
00517 KConfig config( "kaddressbookrc" );
00518 config.setGroup( "General" );
00519 QString commandLine = config.readEntry( "PhoneHookApplication" );
00520
00521 if ( commandLine.isEmpty() ) {
00522 KMessageBox::sorry( this, i18n( "There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
00523 return;
00524 }
00525
00526 commandLine.replace( "%N", number );
00527 KRun::runCommand( commandLine );
00528 }
00529
00530 void AddresseeView::faxNumberClicked( const QString &number )
00531 {
00532 KConfig config( "kaddressbookrc" );
00533 config.setGroup( "General" );
00534 QString commandLine = config.readEntry( "FaxHookApplication", "kdeprintfax --phone %N" );
00535
00536 if ( commandLine.isEmpty() ) {
00537 KMessageBox::sorry( this, i18n( "There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
00538 return;
00539 }
00540
00541 commandLine.replace( "%N", number );
00542 KRun::runCommand( commandLine );
00543 }
00544
00545 void AddresseeView::imAddressClicked()
00546 {
00547 mKIMProxy->chatWithContact( mAddressee.uid() );
00548 }
00549
00550 QPopupMenu *AddresseeView::createPopupMenu( const QPoint& )
00551 {
00552 QPopupMenu *menu = new QPopupMenu( this );
00553 mActionShowBirthday->plug( menu );
00554 mActionShowAddresses->plug( menu );
00555 mActionShowEmails->plug( menu );
00556 mActionShowPhones->plug( menu );
00557 mActionShowURLs->plug( menu );
00558
00559 return menu;
00560 }
00561
00562 void AddresseeView::slotMailClicked( const QString&, const QString &email )
00563 {
00564 emailClicked( email );
00565 }
00566
00567 void AddresseeView::slotUrlClicked( const QString &url )
00568 {
00569 if ( url.startsWith( "phone:" ) )
00570 phoneNumberClicked( strippedNumber( url.mid( 8 ) ) );
00571 else if ( url.startsWith( "fax:" ) )
00572 faxNumberClicked( strippedNumber( url.mid( 6 ) ) );
00573 else if ( url.startsWith( "addr:" ) )
00574 emit addressClicked( url.mid( 7 ) );
00575 else if ( url.startsWith( "im:" ) )
00576 imAddressClicked();
00577 else
00578 urlClicked( url );
00579 }
00580
00581 void AddresseeView::slotHighlighted( const QString &link )
00582 {
00583 if ( link.startsWith( "mailto:" ) ) {
00584 QString email = link.mid( 7 );
00585
00586 emit emailHighlighted( email );
00587 emit highlightedMessage( i18n( "Send mail to '%1'" ).arg( email ) );
00588 } else if ( link.startsWith( "phone:" ) ) {
00589 QString number = link.mid( 8 );
00590
00591 emit phoneNumberHighlighted( strippedNumber( number ) );
00592 emit highlightedMessage( i18n( "Call number %1" ).arg( number ) );
00593 } else if ( link.startsWith( "fax:" ) ) {
00594 QString number = link.mid( 6 );
00595
00596 emit faxNumberHighlighted( strippedNumber( number ) );
00597 emit highlightedMessage( i18n( "Send fax to %1" ).arg( number ) );
00598 } else if ( link.startsWith( "addr:" ) ) {
00599 emit highlightedMessage( i18n( "Show address on map" ) );
00600 } else if ( link.startsWith( "http:" ) || link.startsWith( "https:" ) ) {
00601 emit urlHighlighted( link );
00602 emit highlightedMessage( i18n( "Open URL %1" ).arg( link ) );
00603 } else if ( link.startsWith( "im:" ) ) {
00604 emit highlightedMessage( i18n( "Chat with %1" ).arg( mAddressee.realName() ) );
00605 } else
00606 emit highlightedMessage( "" );
00607 }
00608
00609 void AddresseeView::slotPresenceChanged( const QString &uid )
00610 {
00611 kdDebug() << k_funcinfo << " uid is: " << uid << " mAddressee is: " << mAddressee.uid() << endl;
00612 if ( uid == mAddressee.uid() )
00613 updateView();
00614 }
00615
00616
00617 void AddresseeView::slotPresenceInfoExpired()
00618 {
00619 updateView();
00620 }
00621
00622 void AddresseeView::configChanged()
00623 {
00624 save();
00625 updateView();
00626 }
00627
00628 void AddresseeView::data( KIO::Job*, const QByteArray &d )
00629 {
00630 unsigned int oldSize = mImageData.size();
00631 mImageData.resize( oldSize + d.size() );
00632 memcpy( mImageData.data() + oldSize, d.data(), d.size() );
00633 }
00634
00635 void AddresseeView::result( KIO::Job *job )
00636 {
00637 mImageJob = 0;
00638
00639 if ( job->error() )
00640 mImageData.truncate( 0 );
00641 else
00642 updateView();
00643 }
00644
00645 void AddresseeView::load()
00646 {
00647 mConfig->setGroup( "AddresseeViewSettings" );
00648 mActionShowBirthday->setChecked( mConfig->readBoolEntry( "ShowBirthday", false ) );
00649 mActionShowAddresses->setChecked( mConfig->readBoolEntry( "ShowAddresses", true ) );
00650 mActionShowEmails->setChecked( mConfig->readBoolEntry( "ShowEmails", true ) );
00651 mActionShowPhones->setChecked( mConfig->readBoolEntry( "ShowPhones", true ) );
00652 mActionShowURLs->setChecked( mConfig->readBoolEntry( "ShowURLs", true ) );
00653 }
00654
00655 void AddresseeView::save()
00656 {
00657 mConfig->setGroup( "AddresseeViewSettings" );
00658 mConfig->writeEntry( "ShowBirthday", mActionShowBirthday->isChecked() );
00659 mConfig->writeEntry( "ShowAddresses", mActionShowAddresses->isChecked() );
00660 mConfig->writeEntry( "ShowEmails", mActionShowEmails->isChecked() );
00661 mConfig->writeEntry( "ShowPhones", mActionShowPhones->isChecked() );
00662 mConfig->writeEntry( "ShowURLs", mActionShowURLs->isChecked() );
00663 mConfig->sync();
00664 }
00665
00666 QString AddresseeView::strippedNumber( const QString &number )
00667 {
00668 QString retval;
00669
00670 for ( uint i = 0; i < number.length(); ++i ) {
00671 QChar c = number[ i ];
00672 if ( c.isDigit() || c == '*' || c == '#' || c == '+' && i == 0 )
00673 retval.append( c );
00674 }
00675
00676 return retval;
00677 }
00678
00679 #include "addresseeview.moc"