author | zautrix <zautrix> | 2004-10-12 20:14:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-12 20:14:39 (UTC) |
commit | 77e3a7bc670f4c9b7eb5a5d6652a7986ea196533 (patch) (unidiff) | |
tree | 963c068c7648899a4c3ac26542605f05492019c5 | |
parent | d3759373291c08d2cde93d85a76d190dc8a33830 (diff) | |
download | kdepimpi-77e3a7bc670f4c9b7eb5a5d6652a7986ea196533.zip kdepimpi-77e3a7bc670f4c9b7eb5a5d6652a7986ea196533.tar.gz kdepimpi-77e3a7bc670f4c9b7eb5a5d6652a7986ea196533.tar.bz2 |
Changed phone number sorting in details view
-rw-r--r-- | kabc/addresseeview.cpp | 135 | ||||
-rw-r--r-- | kabc/addresseeview.h | 1 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 4 |
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 | |||
@@ -90,11 +90,7 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
90 | { | 90 | { |
91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
92 | bool kemailAvail = eah->isEmailAppAvailable(); | 92 | bool kemailAvail = eah->isEmailAppAvailable(); |
93 | bool kphoneAvail = eah->isPhoneAppAvailable(); | 93 | |
94 | bool kfaxAvail = eah->isFaxAppAvailable(); | ||
95 | bool ksmsAvail = eah->isSMSAppAvailable(); | ||
96 | bool kpagerAvail = eah->isPagerAppAvailable(); | ||
97 | bool ksipAvail = eah->isSIPAppAvailable(); | ||
98 | 94 | ||
99 | 95 | ||
100 | mAddressee = addr; | 96 | mAddressee = addr; |
@@ -109,6 +105,8 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
109 | 105 | ||
110 | QString dynamicPart; | 106 | QString dynamicPart; |
111 | 107 | ||
108 | dynamicPart += getPhoneNumbers( true ); | ||
109 | qDebug("dynamic preferred %s ",dynamicPart.latin1() ); | ||
112 | QStringList emails = mAddressee.emails(); | 110 | QStringList emails = mAddressee.emails(); |
113 | QStringList::ConstIterator emailIt; | 111 | QStringList::ConstIterator emailIt; |
114 | QString type = i18n( "Email" ); | 112 | QString type = i18n( "Email" ); |
@@ -139,63 +137,7 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
139 | .arg( i18n ("Birthday") ) | 137 | .arg( i18n ("Birthday") ) |
140 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | 138 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); |
141 | } | 139 | } |
142 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); | 140 | dynamicPart += getPhoneNumbers( false ); |
143 | KABC::PhoneNumber::List::ConstIterator phoneIt; | ||
144 | QString extension; | ||
145 | int phonetype; | ||
146 | QString sms; | ||
147 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | ||
148 | phonetype = (*phoneIt).type(); | ||
149 | if (ksmsAvail && | ||
150 | ( | ||
151 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || | ||
152 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) | ||
153 | ) | ||
154 | ) | ||
155 | { | ||
156 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) | ||
157 | .arg( (*phoneIt).number() ); | ||
158 | |||
159 | } | ||
160 | else | ||
161 | sms = ""; | ||
162 | |||
163 | extension = QString::null; | ||
164 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { | ||
165 | if (kfaxAvail) extension = "faxto:"; | ||
166 | } | ||
167 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { | ||
168 | if (kpagerAvail) extension = "pagerto:"; | ||
169 | } | ||
170 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { | ||
171 | if (ksipAvail) extension = "sipto:"; | ||
172 | } | ||
173 | else if (kphoneAvail) { | ||
174 | extension = "phoneto:"; | ||
175 | } | ||
176 | else | ||
177 | extension = QString::null; | ||
178 | |||
179 | if ( !extension.isEmpty() ) { | ||
180 | dynamicPart += QString( | ||
181 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
182 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) | ||
183 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | ||
184 | .arg( extension ) | ||
185 | .arg( (*phoneIt).number() ) | ||
186 | .arg( (*phoneIt).number() ) | ||
187 | .arg( sms ); | ||
188 | |||
189 | } else { | ||
190 | dynamicPart += QString( | ||
191 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
192 | "<td align=\"left\">%2 %3</td></tr>" ) | ||
193 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | ||
194 | .arg( (*phoneIt).number() ) | ||
195 | .arg( sms ); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | 141 | ||
200 | for ( ; emailIt != emails.end(); ++emailIt ) { | 142 | for ( ; emailIt != emails.end(); ++emailIt ) { |
201 | if ( kemailAvail ) { | 143 | if ( kemailAvail ) { |
@@ -370,6 +312,75 @@ mText = "<table width=\"100%\">\n"; | |||
370 | 312 | ||
371 | } | 313 | } |
372 | 314 | ||
315 | QString AddresseeView::getPhoneNumbers( bool preferred ) | ||
316 | { | ||
317 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | ||
318 | bool kphoneAvail = eah->isPhoneAppAvailable(); | ||
319 | bool kfaxAvail = eah->isFaxAppAvailable(); | ||
320 | bool ksmsAvail = eah->isSMSAppAvailable(); | ||
321 | bool kpagerAvail = eah->isPagerAppAvailable(); | ||
322 | bool ksipAvail = eah->isSIPAppAvailable(); | ||
323 | QString dynamicPart; | ||
324 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); | ||
325 | KABC::PhoneNumber::List::ConstIterator phoneIt; | ||
326 | QString extension; | ||
327 | int phonetype; | ||
328 | QString sms; | ||
329 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | ||
330 | phonetype = (*phoneIt).type(); | ||
331 | if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) | ||
332 | continue; | ||
333 | if (ksmsAvail && | ||
334 | ( | ||
335 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || | ||
336 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) | ||
337 | ) | ||
338 | ) | ||
339 | { | ||
340 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) | ||
341 | .arg( (*phoneIt).number() ); | ||
342 | |||
343 | } | ||
344 | else | ||
345 | sms = ""; | ||
346 | |||
347 | extension = QString::null; | ||
348 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { | ||
349 | if (kfaxAvail) extension = "faxto:"; | ||
350 | } | ||
351 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { | ||
352 | if (kpagerAvail) extension = "pagerto:"; | ||
353 | } | ||
354 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { | ||
355 | if (ksipAvail) extension = "sipto:"; | ||
356 | } | ||
357 | else if (kphoneAvail) { | ||
358 | extension = "phoneto:"; | ||
359 | } | ||
360 | else | ||
361 | extension = QString::null; | ||
362 | |||
363 | if ( !extension.isEmpty() ) { | ||
364 | dynamicPart += QString( | ||
365 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
366 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) | ||
367 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | ||
368 | .arg( extension ) | ||
369 | .arg( (*phoneIt).number() ) | ||
370 | .arg( (*phoneIt).number() ) | ||
371 | .arg( sms ); | ||
372 | |||
373 | } else { | ||
374 | dynamicPart += QString( | ||
375 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
376 | "<td align=\"left\">%2 %3</td></tr>" ) | ||
377 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | ||
378 | .arg( (*phoneIt).number() ) | ||
379 | .arg( sms ); | ||
380 | } | ||
381 | } | ||
382 | return dynamicPart; | ||
383 | } | ||
373 | KABC::Addressee AddresseeView::addressee() const | 384 | KABC::Addressee AddresseeView::addressee() const |
374 | { | 385 | { |
375 | return mAddressee; | 386 | return mAddressee; |
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 689d997..d8a13ee 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -51,6 +51,7 @@ class AddresseeView : public QTextBrowser | |||
51 | private: | 51 | private: |
52 | KABC::Addressee mAddressee; | 52 | KABC::Addressee mAddressee; |
53 | QString mText; | 53 | QString mText; |
54 | QString getPhoneNumbers( bool preferred ); | ||
54 | void addTag(const QString & tag,const QString & text); | 55 | void addTag(const QString & tag,const QString & text); |
55 | class AddresseeViewPrivate; | 56 | class AddresseeViewPrivate; |
56 | AddresseeViewPrivate *d; | 57 | AddresseeViewPrivate *d; |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 6e94c7e..d7e3925 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -198,10 +198,10 @@ QString PhoneNumber::typeLabel( int type ) | |||
198 | // add the prefered flag | 198 | // add the prefered flag |
199 | if (!typeString.isEmpty()) | 199 | if (!typeString.isEmpty()) |
200 | typeString += " "; | 200 | typeString += " "; |
201 | 201 | /* | |
202 | if ((type & Pref) == Pref) | 202 | if ((type & Pref) == Pref) |
203 | typeString += i18n("(p)"); | 203 | typeString += i18n("(p)"); |
204 | 204 | */ | |
205 | //if we still have no match, return "other" | 205 | //if we still have no match, return "other" |
206 | if (typeString.isEmpty()) | 206 | if (typeString.isEmpty()) |
207 | return i18n("Other"); | 207 | return i18n("Other"); |
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 78b9941..19bb676 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -215,6 +215,7 @@ void PhoneEditWidget::edit() | |||
215 | if ( dlg.changed() ) { | 215 | if ( dlg.changed() ) { |
216 | mPhoneList = dlg.phoneNumbers(); | 216 | mPhoneList = dlg.phoneNumbers(); |
217 | updateCombos(); | 217 | updateCombos(); |
218 | updateLineEdits(); | ||
218 | emit modified(); | 219 | emit modified(); |
219 | } | 220 | } |
220 | } | 221 | } |
@@ -289,9 +290,6 @@ void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | |||
289 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 290 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
290 | if ( it != mPhoneList.end() ) { | 291 | if ( it != mPhoneList.end() ) { |
291 | (*it).setNumber( edit->text() ); | 292 | (*it).setNumber( edit->text() ); |
292 | } else { | ||
293 | kdDebug(5720) << "PhoneEditWidget::updatePhoneNumber(): no selected element" | ||
294 | << endl; | ||
295 | } | 293 | } |
296 | 294 | ||
297 | updateOtherEdit( combo, mPrefCombo ); | 295 | updateOtherEdit( combo, mPrefCombo ); |