-rw-r--r-- | kabc/addresseeview.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 5c24acf..cde19a1 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -539,41 +539,66 @@ mText = "<table width=\"100%\">\n"; .arg( mAddressee.organization()); mText += dynamicPart; mText += notes; mText += "</table>"; } // at last display it... setText( mText ); } -QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) +QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones_unsorted ,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::ConstIterator phoneIt; QString extension; int phonetype; QString sms; + + KABC::PhoneNumber::List::Iterator it; + KABC::PhoneNumber::List phones ; + + PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); + int i = 0; + int max = tList.count(); + while ( i < max-1 ) { + for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) { + if ( (*it).type() == tList[i] ) { + phones.append( (*it ) ); + break; + } + } + ++i; + } + for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) { + if ( (*it).type() == tList[ max-1 ] ) + phones.append( (*it ) ); + } + for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { phonetype = (*phoneIt).type(); - if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) + bool con = false; + if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) con = true; + if ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell ) con = !preferred;; + if ( con ) 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 |