summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-12 20:14:39 (UTC)
committer zautrix <zautrix>2004-10-12 20:14:39 (UTC)
commit77e3a7bc670f4c9b7eb5a5d6652a7986ea196533 (patch) (side-by-side diff)
tree963c068c7648899a4c3ac26542605f05492019c5
parentd3759373291c08d2cde93d85a76d190dc8a33830 (diff)
downloadkdepimpi-77e3a7bc670f4c9b7eb5a5d6652a7986ea196533.zip
kdepimpi-77e3a7bc670f4c9b7eb5a5d6652a7986ea196533.tar.gz
kdepimpi-77e3a7bc670f4c9b7eb5a5d6652a7986ea196533.tar.bz2
Changed phone number sorting in details view
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addresseeview.cpp135
-rw-r--r--kabc/addresseeview.h1
-rw-r--r--kabc/phonenumber.cpp4
-rw-r--r--kaddressbook/phoneeditwidget.cpp4
4 files changed, 77 insertions, 67 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 2dda968..af149a0 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -91,9 +91,5 @@ 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();
+
@@ -110,4 +106,6 @@ 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;
@@ -140,61 +138,5 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
.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 ) {
@@ -371,4 +313,73 @@ 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
{
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h
index 689d997..d8a13ee 100644
--- a/kabc/addresseeview.h
+++ b/kabc/addresseeview.h
@@ -52,4 +52,5 @@ class AddresseeView : public QTextBrowser
KABC::Addressee mAddressee;
QString mText;
+ QString getPhoneNumbers( bool preferred );
void addTag(const QString & tag,const QString & text);
class AddresseeViewPrivate;
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 6e94c7e..d7e3925 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -199,8 +199,8 @@ QString PhoneNumber::typeLabel( int type )
if (!typeString.isEmpty())
typeString += " ";
-
+ /*
if ((type & Pref) == Pref)
typeString += i18n("(p)");
-
+ */
//if we still have no match, return "other"
if (typeString.isEmpty())
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 78b9941..19bb676 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -216,4 +216,5 @@ void PhoneEditWidget::edit()
mPhoneList = dlg.phoneNumbers();
updateCombos();
+ updateLineEdits();
emit modified();
}
@@ -290,7 +291,4 @@ void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo )
if ( it != mPhoneList.end() ) {
(*it).setNumber( edit->text() );
- } else {
- kdDebug(5720) << "PhoneEditWidget::updatePhoneNumber(): no selected element"
- << endl;
}