24 #include <tqpopupmenu.h>
27 #include <tdeabc/address.h>
28 #include <tdeabc/addressee.h>
29 #include <tdeabc/phonenumber.h>
30 #include <tdeabc/resource.h>
31 #include <tdeactionclasses.h>
32 #include <tdeapplication.h>
33 #include <tdeconfig.h>
34 #include <tdeglobal.h>
35 #include <tdeglobalsettings.h>
36 #include <kiconloader.h>
37 #include <tdeio/job.h>
38 #include <tdelocale.h>
40 #include <tdemessagebox.h>
42 #include <kstringhandler.h>
43 #include <tdetempfile.h>
47 #include "addresseeview.h"
48 #include "sendsmsdialog.h"
49 #include "resourceabc.h"
53 AddresseeView::AddresseeView( TQWidget *parent,
const char *name,
55 : KTextBrowser( parent, name ), mDefaultConfig( false ), mImageJob( 0 ),
56 mLinkMask( AddressLinks | EmailLinks | PhoneLinks | URLLinks | IMLinks | CustomFields )
58 setWrapPolicy( TQTextEdit::AtWordBoundary );
59 setLinkUnderline(
false );
60 setVScrollBarMode( TQScrollView::AlwaysOff );
61 setHScrollBarMode( TQScrollView::AlwaysOff );
63 TQStyleSheet *sheet = styleSheet();
64 TQStyleSheetItem *link = sheet->item(
"a" );
65 link->setColor( TDEGlobalSettings::linkColor() );
67 connect(
this, TQ_SIGNAL( mailClick(
const TQString&,
const TQString& ) ),
68 this, TQ_SLOT( slotMailClicked(
const TQString&,
const TQString& ) ) );
69 connect(
this, TQ_SIGNAL( urlClick(
const TQString& ) ),
70 this, TQ_SLOT( slotUrlClicked(
const TQString& ) ) );
71 connect(
this, TQ_SIGNAL( highlighted(
const TQString& ) ),
72 this, TQ_SLOT( slotHighlighted(
const TQString& ) ) );
74 setNotifyClick(
true );
76 mActionShowBirthday =
new TDEToggleAction( i18n(
"Show Birthday" ) );
77 mActionShowBirthday->setCheckedState( i18n(
"Hide Birthday" ) );
78 mActionShowAddresses =
new TDEToggleAction( i18n(
"Show Postal Addresses" ) );
79 mActionShowAddresses->setCheckedState( i18n(
"Hide Postal Addresses" ) );
80 mActionShowEmails =
new TDEToggleAction( i18n(
"Show Email Addresses" ) );
81 mActionShowEmails->setCheckedState( i18n(
"Hide Email Addresses" ) );
82 mActionShowPhones =
new TDEToggleAction( i18n(
"Show Telephone Numbers" ) );
83 mActionShowPhones->setCheckedState( i18n(
"Hide Telephone Numbers" ) );
84 mActionShowURLs =
new TDEToggleAction( i18n(
"Show Web Pages (URLs)" ) );
85 mActionShowURLs->setCheckedState( i18n(
"Hide Web Pages (URLs)" ) );
86 mActionShowIMAddresses =
new TDEToggleAction( i18n(
"Show Instant Messaging Addresses" ) );
87 mActionShowIMAddresses->setCheckedState( i18n(
"Hide Instant Messaging Addresses" ) );
88 mActionShowCustomFields =
new TDEToggleAction( i18n(
"Show Custom Fields" ) );
89 mActionShowCustomFields->setCheckedState( i18n(
"Hide Custom Fields" ) );
91 connect( mActionShowBirthday, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
92 connect( mActionShowAddresses, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
93 connect( mActionShowEmails, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
94 connect( mActionShowPhones, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
95 connect( mActionShowURLs, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
96 connect( mActionShowIMAddresses, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
97 connect( mActionShowCustomFields, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( configChanged() ) );
100 mConfig =
new TDEConfig(
"kaddressbookrc" );
101 mDefaultConfig =
true;
108 mKIMProxy = ::KIMProxy::instance( kapp->dcopClient() );
109 connect( mKIMProxy, TQ_SIGNAL( sigContactPresenceChanged(
const TQString& ) ),
110 this, TQ_SLOT( slotPresenceChanged(
const TQString& ) ) );
111 connect( mKIMProxy, TQ_SIGNAL( sigPresenceInfoExpired() ),
112 this, TQ_SLOT( slotPresenceInfoExpired() ) );
115 AddresseeView::~AddresseeView()
117 if ( mDefaultConfig )
121 delete mActionShowBirthday;
122 delete mActionShowAddresses;
123 delete mActionShowEmails;
124 delete mActionShowPhones;
125 delete mActionShowURLs;
126 delete mActionShowIMAddresses;
127 delete mActionShowCustomFields;
132 void AddresseeView::setAddressee(
const TDEABC::Addressee& addr )
141 mImageData.truncate( 0 );
146 void AddresseeView::enableLinks(
int linkMask )
148 mLinkMask = linkMask;
151 TQString AddresseeView::vCardAsHTML(
const TDEABC::Addressee& addr, ::KIMProxy *proxy, LinkMask linkMask,
152 bool internalLoading, FieldMask fieldMask )
154 TQString image = TQString(
"contact_%1_image" ).arg( addr.uid() );
163 TQString backgroundColor = TDEGlobalSettings::alternateBackgroundColor().name();
164 TQString cellStyle = TQString::fromLatin1(
166 "padding-right: 2px; "
167 "border-right: #000 dashed 1px; "
168 "background: %1;\"").arg(backgroundColor);
169 TQString backgroundColor2 = TDEGlobalSettings::baseColor().name();
170 TQString cellStyle2 = TQString::fromLatin1(
172 "padding-left: 2px; "
173 "background: %1;\"").arg(backgroundColor2);
174 TQString tableStyle = TQString::fromLatin1(
176 "border: solid 1px; "
182 TQString rowFmtStr = TQString::fromLatin1(
184 "<td align=\"right\" valign=\"top\" width=\"30%\" ");
185 rowFmtStr.append( cellStyle );
186 rowFmtStr.append( TQString::fromLatin1(
190 "<td align=\"left\" valign=\"top\" width=\"70%\" ") );
191 rowFmtStr.append( cellStyle2 );
192 rowFmtStr.append( TQString::fromLatin1(
200 TQString dynamicPart;
203 if ( !internalLoading ) {
204 TDEABC::Picture pic = addr.photo();
205 if ( pic.isIntern() && !pic.data().isNull() ) {
206 image = pixmapAsDataUrl( pic.data() );
207 }
else if ( !pic.url().isEmpty() ) {
208 image = (pic.url().startsWith(
"http://" ) || pic.url().startsWith(
"https://" ) ? pic.url() :
"http://" + pic.url());
210 image =
"file:" + TDEGlobal::iconLoader()->iconPath(
"preferences-desktop-personal", TDEIcon::Desktop );
214 if ( fieldMask & BirthdayFields ) {
215 TQDate date = addr.birthday().date();
217 if ( date.isValid() )
218 dynamicPart += rowFmtStr
219 .arg( TDEABC::Addressee::birthdayLabel() )
220 .arg( TDEGlobal::locale()->formatDate( date,
true ) );
223 if ( fieldMask & PhoneFields ) {
224 TDEABC::PhoneNumber::List phones = addr.phoneNumbers();
225 TDEABC::PhoneNumber::List::ConstIterator phoneIt;
226 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
227 TQString number = TQStyleSheet::escape( (*phoneIt).number() );
230 if ( (*phoneIt).type() & TDEABC::PhoneNumber::Fax )
231 url = TQString::fromLatin1(
"fax:" ) + number;
233 url = TQString::fromLatin1(
"phone:" ) + number;
235 if ( linkMask & PhoneLinks ) {
237 if ( (*phoneIt).type() & TDEABC::PhoneNumber::Cell )
238 smsURL = TQString(
" (<a href=\"sms:%1\">%2</a>)" ).arg( number ).arg( i18n(
"SMS") );
240 dynamicPart += rowFmtStr
241 .arg( (*phoneIt).typeLabel().replace(
" ",
" " ) )
242 .arg( TQString::fromLatin1(
"<a href=\"%1\">%2</a>%3" ).arg( url ).arg( number ).arg( smsURL ) );
244 dynamicPart += rowFmtStr
245 .arg( (*phoneIt).typeLabel().replace(
" ",
" " ) )
251 if ( fieldMask & EmailFields ) {
252 TQStringList emails = addr.emails();
253 TQStringList::ConstIterator emailIt;
254 TQString type = i18n(
"Email" );
255 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) {
256 TQString fullEmail = addr.fullEmail( *emailIt );
257 TQUrl::encode( fullEmail );
259 if ( linkMask & EmailLinks ) {
260 dynamicPart += rowFmtStr.arg( type )
261 .arg( TQString::fromLatin1(
"<a href=\"mailto:%1\">%2</a>" )
262 .arg( fullEmail, TQStyleSheet::escape( *emailIt ) ) );
264 dynamicPart += rowFmtStr.arg( type ).arg( *emailIt );
269 if ( fieldMask & URLFields ) {
270 if ( !addr.url().url().isEmpty() ) {
272 if ( linkMask & URLLinks ) {
273 url = (addr.url().url().startsWith(
"http://" ) || addr.url().url().startsWith(
"https://" ) ? addr.url().prettyURL() :
274 "http://" + addr.url().prettyURL());
275 url = KStringHandler::tagURLs( url );
277 url = addr.url().prettyURL();
279 dynamicPart += rowFmtStr.arg( i18n(
"Homepage") ).arg( url );
282 TQString blog = addr.custom(
"KADDRESSBOOK",
"BlogFeed" );
283 if ( !blog.isEmpty() ) {
284 if ( linkMask & URLLinks ) {
285 blog = KStringHandler::tagURLs( blog );
287 dynamicPart += rowFmtStr.arg( i18n(
"Blog Feed") ).arg( blog );
291 if ( fieldMask & AddressFields ) {
292 TDEABC::Address::List addresses = addr.addresses();
293 TDEABC::Address::List::ConstIterator addrIt;
294 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
295 if ( (*addrIt).label().isEmpty() ) {
296 TQString formattedAddress;
298 formattedAddress = TQStyleSheet::escape( (*addrIt).formattedAddress().stripWhiteSpace() );
299 formattedAddress = formattedAddress.replace(
'\n',
"<br>" );
301 TQString link =
"<a href=\"addr:" + (*addrIt).id() +
"\">" +
302 formattedAddress +
"</a>";
304 if ( linkMask & AddressLinks ) {
305 dynamicPart += rowFmtStr
306 .arg( TDEABC::Address::typeLabel( (*addrIt).type() ) )
309 dynamicPart += rowFmtStr
310 .arg( TDEABC::Address::typeLabel( (*addrIt).type() ) )
311 .arg( formattedAddress );
314 TQString link =
"<a href=\"addr:" + (*addrIt).id() +
"\">" +
315 (*addrIt).label().replace(
'\n',
"<br>" ) +
"</a>";
317 if ( linkMask & AddressLinks ) {
318 dynamicPart += rowFmtStr
319 .arg( TDEABC::Address::typeLabel( (*addrIt).type() ) )
322 dynamicPart += rowFmtStr
323 .arg( TDEABC::Address::typeLabel( (*addrIt).type() ) )
324 .arg( (*addrIt).label().replace(
'\n',
"<br>" ) );
331 if ( !addr.note().isEmpty() ) {
335 notes = TQStyleSheet::escape( addr.note() );
336 notes = rowFmtStr.arg( i18n(
"Notes" ) ).arg( notes.replace(
'\n',
"<br>" ) ) ;
340 if ( fieldMask & CustomFields ) {
341 static TQMap<TQString, TQString> titleMap;
342 if ( titleMap.isEmpty() ) {
343 titleMap.insert(
"Department", i18n(
"Department" ) );
344 titleMap.insert(
"Profession", i18n(
"Profession" ) );
345 titleMap.insert(
"AssistantsName", i18n(
"Assistant's Name" ) );
346 titleMap.insert(
"ManagersName", i18n(
"Manager's Name" ) );
347 titleMap.insert(
"SpousesName", i18n(
"Partner's Name" ) );
348 titleMap.insert(
"Office", i18n(
"Office" ) );
349 titleMap.insert(
"Anniversary", i18n(
"Anniversary" ) );
352 if ( !addr.customs().empty() ) {
353 TQStringList customs = addr.customs();
354 TQStringList::Iterator it( customs.begin() );
355 const TQStringList::Iterator endIt( customs.end() );
356 for ( ; it != endIt; ++it ) {
357 TQString customEntry = *it;
358 if ( customEntry.startsWith (
"KADDRESSBOOK-" ) ) {
359 customEntry.remove(
"KADDRESSBOOK-X-" );
360 customEntry.remove(
"KADDRESSBOOK-" );
362 int pos = customEntry.find(
':' );
363 TQString key = customEntry.left( pos );
364 const TQString value = customEntry.mid( pos + 1 );
367 if ( key ==
"BlogFeed" || key ==
"IMAddress" )
370 const TQMap<TQString, TQString>::ConstIterator keyIt = titleMap.find( key );
371 if ( keyIt != titleMap.end() )
374 customData += rowFmtStr.arg( key ).arg( TQStyleSheet::escape( value ) ) ;
380 TQString name( TQStyleSheet::escape( addr.realName() ) );
381 TQString role( TQStyleSheet::escape( addr.role() ) );
382 TQString organization( TQStyleSheet::escape( addr.organization() ) );
384 if ( fieldMask & IMFields ) {
386 const TQString imAddress = addr.custom(
"KADDRESSBOOK",
"X-IMAddress" );
387 if ( !imAddress.isEmpty() ) {
388 customData += rowFmtStr.arg( i18n(
"IM Address" ) ).arg( TQStyleSheet::escape( imAddress ) ) ;
392 if ( proxy->isPresent( addr.uid() ) && proxy->presenceNumeric( addr.uid() ) > 0 ) {
395 if ( internalLoading ) {
396 imgSrc = TQString::fromLatin1(
"im_status_%1_image").arg( addr.uid() );
397 TQMimeSourceFactory::defaultFactory()->setPixmap( imgSrc, proxy->presenceIcon( addr.uid() ) );
399 imgSrc = pixmapAsDataUrl( proxy->presenceIcon( addr.uid() ) );
403 if ( linkMask & IMLinks )
404 imStatus = TQString::fromLatin1(
"<a href=\"im:\"><img src=\"%1\"> (%2)</a>" );
406 imStatus = TQString::fromLatin1(
"<img src=\"%1\"> (%2)" );
409 dynamicPart += rowFmtStr
410 .arg( i18n(
"Presence" ) )
413 .arg( proxy->presenceString( addr.uid() ) )
424 TQString strAddr = TQString::fromLatin1(
425 "<div align=\"center\">"
426 "<table cellpadding=\"1\" cellspacing=\"0\" %1>"
427 "<tr>").arg(tableStyle);
429 strAddr.append( TQString::fromLatin1(
430 "<td align=\"right\" valign=\"top\" width=\"30%\" rowspan=\"3\" %2>")
432 strAddr.append( TQString::fromLatin1(
433 "<img src=\"%1\" width=\"50\" vspace=\"1\">"
436 strAddr.append( TQString::fromLatin1(
437 "<td align=\"left\" width=\"70%\" %2>")
438 .arg( cellStyle2 ) );
439 strAddr.append( TQString::fromLatin1(
440 "<font size=\"+2\"><b>%2</b></font></td>"
443 strAddr.append( TQString::fromLatin1(
445 "<td align=\"left\" width=\"70%\" %2>")
446 .arg( cellStyle2 ) );
447 strAddr.append( TQString::fromLatin1(
451 strAddr.append( TQString::fromLatin1(
453 "<td align=\"left\" width=\"70%\" %2>")
454 .arg( cellStyle2 ) );
455 strAddr.append( TQString::fromLatin1(
458 .arg( organization ) );
459 strAddr.append( TQString::fromLatin1(
462 strAddr.append( TQString::fromLatin1(
463 " </td><td %2> </td></tr>")
464 .arg( cellStyle2 ) );
465 strAddr.append( dynamicPart );
466 strAddr.append( notes );
467 strAddr.append( customData );
468 strAddr.append( TQString::fromLatin1(
"</table></div>\n" ) );
470 if ( addr.resource() ) {
471 TQString addrBookName = addr.resource()->resourceName();
476 if ( !label.isEmpty() )
477 addrBookName = label;
479 strAddr.append( i18n(
"<p><b>Address book</b>: %1</p>" ).arg( addrBookName ) );
484 TQString AddresseeView::pixmapAsDataUrl(
const TQPixmap& pixmap )
487 TQBuffer buffer( ba );
488 buffer.open( IO_WriteOnly );
489 pixmap.save( &buffer,
"PNG" );
490 TQString encoded(
"data:image/png;base64," );
491 encoded.append( KCodecs::base64Encode( ba ) );
495 void AddresseeView::updateView()
498 setText( TQString() );
500 if ( mAddressee.isEmpty() )
507 mImageData.truncate( 0 );
510 int fieldMask = NoFields;
511 if ( mActionShowBirthday->isChecked() )
512 fieldMask |= ( FieldMask )BirthdayFields;
513 if ( mActionShowAddresses->isChecked() )
514 fieldMask |= AddressFields;
515 if ( mActionShowEmails->isChecked() )
516 fieldMask |= EmailFields;
517 if ( mActionShowPhones->isChecked() )
518 fieldMask |= PhoneFields;
519 if ( mActionShowURLs->isChecked() )
520 fieldMask |= URLFields;
521 if ( mActionShowIMAddresses->isChecked() )
522 fieldMask |= IMFields;
523 if ( mActionShowCustomFields->isChecked() )
524 fieldMask |= CustomFields;
526 TQString strAddr = vCardAsHTML( mAddressee, mKIMProxy, (LinkMask)mLinkMask,
527 true, (FieldMask)fieldMask );
529 strAddr = TQString::fromLatin1(
531 "<body text=\"%1\" bgcolor=\"%2\">"
535 .arg( TDEGlobalSettings::textColor().name() )
536 .arg( TDEGlobalSettings::baseColor().name() )
539 TQString imageURL = TQString(
"contact_%1_image" ).arg( mAddressee.uid() );
541 TDEABC::Picture picture = mAddressee.photo();
542 if ( picture.isIntern() && !picture.data().isNull() )
543 TQMimeSourceFactory::defaultFactory()->setImage( imageURL, picture.data() );
545 if ( !picture.url().isEmpty() ) {
546 if ( mImageData.count() > 0 )
547 TQMimeSourceFactory::defaultFactory()->setImage( imageURL, TQImage(mImageData) );
549 mImageJob = TDEIO::get( KURL( picture.url() ),
false,
false );
550 connect( mImageJob, TQ_SIGNAL( data( TDEIO::Job*,
const TQByteArray& ) ),
551 this, TQ_SLOT( data( TDEIO::Job*,
const TQByteArray& ) ) );
552 connect( mImageJob, TQ_SIGNAL( result( TDEIO::Job* ) ),
553 this, TQ_SLOT( result( TDEIO::Job* ) ) );
556 TQMimeSourceFactory::defaultFactory()->setPixmap( imageURL,
557 TDEGlobal::iconLoader()->loadIcon(
"preferences-desktop-personal", TDEIcon::Desktop, 128 ) );
565 TDEABC::Addressee AddresseeView::addressee()
const
570 void AddresseeView::urlClicked(
const TQString &url )
572 kapp->invokeBrowser( url );
575 void AddresseeView::emailClicked(
const TQString &email )
577 if ( email.startsWith(
"mailto:" ) )
578 kapp->invokeMailer( email.mid( 7 ), TQString() );
580 kapp->invokeMailer( email, TQString() );
583 void AddresseeView::phoneNumberClicked(
const TQString &number )
585 TDEConfig config(
"kaddressbookrc" );
586 config.setGroup(
"General" );
587 TQString commandLine = config.readEntry(
"PhoneHookApplication" );
589 if ( commandLine.isEmpty() ) {
590 KMessageBox::sorry(
this, i18n(
"There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
594 commandLine.replace(
"%N", number );
595 KRun::runCommand( commandLine );
598 void AddresseeView::smsTextClicked(
const TQString &number )
600 TDEConfig config(
"kaddressbookrc" );
601 config.setGroup(
"General" );
602 TQString commandLine = config.readEntry(
"SMSHookApplication" );
604 if ( commandLine.isEmpty() ) {
605 KMessageBox::sorry(
this, i18n(
"There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
609 SendSMSDialog dlg( mAddressee.realName(),
this );
612 sendSMS ( number, dlg.text() );
615 void AddresseeView::sendSMS(
const TQString &number,
const TQString &text )
617 TDEConfig config(
"kaddressbookrc" );
618 config.setGroup(
"General" );
619 TQString commandLine = config.readEntry(
"SMSHookApplication" );
622 TQTextStream* stream = file.textStream();
626 commandLine.replace(
"%N", number );
627 commandLine.replace(
"%F", file.name() );
629 KRun::runCommand( commandLine );
632 void AddresseeView::faxNumberClicked(
const TQString &number )
634 TDEConfig config(
"kaddressbookrc" );
635 config.setGroup(
"General" );
636 TQString commandLine = config.readEntry(
"FaxHookApplication",
"tdeprintfax --phone %N" );
638 if ( commandLine.isEmpty() ) {
639 KMessageBox::sorry(
this, i18n(
"There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
643 commandLine.replace(
"%N", number );
644 KRun::runCommand( commandLine );
647 void AddresseeView::imAddressClicked()
649 mKIMProxy->chatWithContact( mAddressee.uid() );
652 TQPopupMenu *AddresseeView::createPopupMenu(
const TQPoint& )
654 TQPopupMenu *menu =
new TQPopupMenu(
this );
655 mActionShowBirthday->plug( menu );
656 mActionShowAddresses->plug( menu );
657 mActionShowEmails->plug( menu );
658 mActionShowPhones->plug( menu );
659 mActionShowURLs->plug( menu );
660 mActionShowIMAddresses->plug( menu );
661 mActionShowCustomFields->plug( menu );
666 void AddresseeView::slotMailClicked(
const TQString&,
const TQString &email )
668 emailClicked( email );
671 void AddresseeView::slotUrlClicked(
const TQString &url )
673 if ( url.startsWith(
"phone:" ) )
674 phoneNumberClicked( strippedNumber( url.mid( 8 ) ) );
675 else if ( url.startsWith(
"sms:" ) )
676 smsTextClicked( strippedNumber( url.mid( 6 ) ) );
677 else if ( url.startsWith(
"fax:" ) )
678 faxNumberClicked( strippedNumber( url.mid( 6 ) ) );
679 else if ( url.startsWith(
"addr:" ) )
680 emit addressClicked( url.mid( 7 ) );
681 else if ( url.startsWith(
"im:" ) )
687 void AddresseeView::slotHighlighted(
const TQString &link )
689 if ( link.startsWith(
"mailto:" ) ) {
690 TQString email = link.mid( 7 );
692 emit emailHighlighted( email );
693 emit highlightedMessage( i18n(
"Send mail to '%1'" ).arg( email ) );
694 }
else if ( link.startsWith(
"phone:" ) ) {
695 TQString number = link.mid( 8 );
697 emit phoneNumberHighlighted( strippedNumber( number ) );
698 emit highlightedMessage( i18n(
"Call number %1" ).arg( number ) );
699 }
else if ( link.startsWith(
"fax:" ) ) {
700 TQString number = link.mid( 6 );
702 emit faxNumberHighlighted( strippedNumber( number ) );
703 emit highlightedMessage( i18n(
"Send fax to %1" ).arg( number ) );
704 }
else if ( link.startsWith(
"addr:" ) ) {
705 emit highlightedMessage( i18n(
"Show address on map" ) );
706 }
else if ( link.startsWith(
"sms:" ) ) {
707 TQString number = link.mid( 6 );
708 emit highlightedMessage( i18n(
"Send SMS to %1" ).arg( number ) );
709 }
else if ( link.startsWith(
"http:" ) || link.startsWith(
"https:" ) ) {
710 emit urlHighlighted( link );
711 emit highlightedMessage( i18n(
"Open URL %1" ).arg( link ) );
712 }
else if ( link.startsWith(
"im:" ) ) {
713 emit highlightedMessage( i18n(
"Chat with %1" ).arg( mAddressee.realName() ) );
715 emit highlightedMessage(
"" );
718 void AddresseeView::slotPresenceChanged(
const TQString &uid )
720 kdDebug() << k_funcinfo <<
" uid is: " << uid <<
" mAddressee is: " << mAddressee.uid() << endl;
721 if ( uid == mAddressee.uid() )
726 void AddresseeView::slotPresenceInfoExpired()
731 void AddresseeView::configChanged()
737 void AddresseeView::data( TDEIO::Job*,
const TQByteArray &d )
739 unsigned int oldSize = mImageData.size();
740 mImageData.resize( oldSize + d.size() );
741 memcpy( mImageData.data() + oldSize, d.data(), d.size() );
744 void AddresseeView::result( TDEIO::Job *job )
749 mImageData.truncate( 0 );
754 void AddresseeView::load()
756 mConfig->setGroup(
"AddresseeViewSettings" );
757 mActionShowBirthday->setChecked( mConfig->readBoolEntry(
"ShowBirthday",
false ) );
758 mActionShowAddresses->setChecked( mConfig->readBoolEntry(
"ShowAddresses",
true ) );
759 mActionShowEmails->setChecked( mConfig->readBoolEntry(
"ShowEmails",
true ) );
760 mActionShowPhones->setChecked( mConfig->readBoolEntry(
"ShowPhones",
true ) );
761 mActionShowURLs->setChecked( mConfig->readBoolEntry(
"ShowURLs",
true ) );
762 mActionShowIMAddresses->setChecked( mConfig->readBoolEntry(
"ShowIMAddresses",
false ) );
763 mActionShowCustomFields->setChecked( mConfig->readBoolEntry(
"ShowCustomFields",
false ) );
766 void AddresseeView::save()
768 mConfig->setGroup(
"AddresseeViewSettings" );
769 mConfig->writeEntry(
"ShowBirthday", mActionShowBirthday->isChecked() );
770 mConfig->writeEntry(
"ShowAddresses", mActionShowAddresses->isChecked() );
771 mConfig->writeEntry(
"ShowEmails", mActionShowEmails->isChecked() );
772 mConfig->writeEntry(
"ShowPhones", mActionShowPhones->isChecked() );
773 mConfig->writeEntry(
"ShowURLs", mActionShowURLs->isChecked() );
774 mConfig->writeEntry(
"ShowIMAddresses", mActionShowIMAddresses->isChecked() );
775 mConfig->writeEntry(
"ShowCustomFields", mActionShowCustomFields->isChecked() );
779 TQString AddresseeView::strippedNumber(
const TQString &number )
783 for ( uint i = 0; i < number.length(); ++i ) {
784 TQChar c = number[ i ];
785 if ( c.isDigit() || (((c ==
'*') || (c ==
'#') || (c ==
'+')) && (i == 0)) )
792 #include "addresseeview.moc"
This class is the implementation of subfolder resources for KABC.
virtual TQStringList subresources() const
If this resource has subresources, return a TQStringList of them.
virtual TQString subresourceLabel(const TQString &) const =0
Label for a given subresource.
virtual TQMap< TQString, TQString > uidToResourceMap() const =0
Get the UID to subresource map.
TDEPIM classes for drag and drop of mails.