summaryrefslogtreecommitdiffabout
path: root/kabc/addresseeview.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addresseeview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addresseeview.cpp135
1 files changed, 73 insertions, 62 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 2dda968..af149a0 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -90,11 +90,7 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
{
ExternalAppHandler* eah = ExternalAppHandler::instance();
bool kemailAvail = eah->isEmailAppAvailable();
- bool kphoneAvail = eah->isPhoneAppAvailable();
- bool kfaxAvail = eah->isFaxAppAvailable();
- bool ksmsAvail = eah->isSMSAppAvailable();
- bool kpagerAvail = eah->isPagerAppAvailable();
- bool ksipAvail = eah->isSIPAppAvailable();
+
mAddressee = addr;
@@ -109,6 +105,8 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
QString dynamicPart;
+ dynamicPart += getPhoneNumbers( true );
+ qDebug("dynamic preferred %s ",dynamicPart.latin1() );
QStringList emails = mAddressee.emails();
QStringList::ConstIterator emailIt;
QString type = i18n( "Email" );
@@ -139,63 +137,7 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
.arg( i18n ("Birthday") )
.arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
}
- KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
- KABC::PhoneNumber::List::ConstIterator phoneIt;
- QString extension;
- int phonetype;
- QString sms;
- for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
- phonetype = (*phoneIt).type();
- if (ksmsAvail &&
- (
- ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
- ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
- )
- )
- {
- sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
- .arg( (*phoneIt).number() );
-
- }
- else
- sms = "";
-
- extension = QString::null;
- if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
- if (kfaxAvail) extension = "faxto:";
- }
- else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
- if (kpagerAvail) extension = "pagerto:";
- }
- else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
- if (ksipAvail) extension = "sipto:";
- }
- else if (kphoneAvail) {
- extension = "phoneto:";
- }
- else
- extension = QString::null;
-
- if ( !extension.isEmpty() ) {
- dynamicPart += QString(
- "<tr><td align=\"right\"><b>%1</b></td>"
- "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
- .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
- .arg( extension )
- .arg( (*phoneIt).number() )
- .arg( (*phoneIt).number() )
- .arg( sms );
-
- } else {
- dynamicPart += QString(
- "<tr><td align=\"right\"><b>%1</b></td>"
- "<td align=\"left\">%2 %3</td></tr>" )
- .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
- .arg( (*phoneIt).number() )
- .arg( sms );
- }
- }
-
+ dynamicPart += getPhoneNumbers( false );
for ( ; emailIt != emails.end(); ++emailIt ) {
if ( kemailAvail ) {
@@ -370,6 +312,75 @@ mText = "<table width=\"100%\">\n";
}
+QString AddresseeView::getPhoneNumbers( bool preferred )
+{
+ ExternalAppHandler* eah = ExternalAppHandler::instance();
+ bool kphoneAvail = eah->isPhoneAppAvailable();
+ bool kfaxAvail = eah->isFaxAppAvailable();
+ bool ksmsAvail = eah->isSMSAppAvailable();
+ bool kpagerAvail = eah->isPagerAppAvailable();
+ bool ksipAvail = eah->isSIPAppAvailable();
+ QString dynamicPart;
+ KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
+ KABC::PhoneNumber::List::ConstIterator phoneIt;
+ QString extension;
+ int phonetype;
+ QString sms;
+ for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
+ phonetype = (*phoneIt).type();
+ if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred )
+ continue;
+ if (ksmsAvail &&
+ (
+ ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
+ ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
+ )
+ )
+ {
+ sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
+ .arg( (*phoneIt).number() );
+
+ }
+ else
+ sms = "";
+
+ extension = QString::null;
+ if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
+ if (kfaxAvail) extension = "faxto:";
+ }
+ else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
+ if (kpagerAvail) extension = "pagerto:";
+ }
+ else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
+ if (ksipAvail) extension = "sipto:";
+ }
+ else if (kphoneAvail) {
+ extension = "phoneto:";
+ }
+ else
+ extension = QString::null;
+
+ if ( !extension.isEmpty() ) {
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
+ .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
+ .arg( extension )
+ .arg( (*phoneIt).number() )
+ .arg( (*phoneIt).number() )
+ .arg( sms );
+
+ } else {
+ dynamicPart += QString(
+ "<tr><td align=\"right\"><b>%1</b></td>"
+ "<td align=\"left\">%2 %3</td></tr>" )
+ .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
+ .arg( (*phoneIt).number() )
+ .arg( sms );
+ }
+ }
+ return dynamicPart;
+}
KABC::Addressee AddresseeView::addressee() const
{
return mAddressee;