-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 | 6 |
4 files changed, 78 insertions, 68 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 2dda968..af149a0 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -69,154 +69,96 @@ AddresseeView::AddresseeView( QWidget *parent, const char *name ) | |||
69 | } | 69 | } |
70 | 70 | ||
71 | void AddresseeView::setSource(const QString& n) | 71 | void AddresseeView::setSource(const QString& n) |
72 | { | 72 | { |
73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); |
74 | 74 | ||
75 | if ( n.left( 6 ) == "mailto" ) | 75 | if ( n.left( 6 ) == "mailto" ) |
76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
77 | else if ( n.left( 7 ) == "phoneto" ) | 77 | else if ( n.left( 7 ) == "phoneto" ) |
78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
79 | else if ( n.left( 5 ) == "faxto" ) | 79 | else if ( n.left( 5 ) == "faxto" ) |
80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
81 | else if ( n.left( 5 ) == "smsto" ) | 81 | else if ( n.left( 5 ) == "smsto" ) |
82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); |
83 | else if ( n.left( 7 ) == "pagerto" ) | 83 | else if ( n.left( 7 ) == "pagerto" ) |
84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); |
85 | else if ( n.left( 5 ) == "sipto" ) | 85 | else if ( n.left( 5 ) == "sipto" ) |
86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); |
87 | 87 | ||
88 | } | 88 | } |
89 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 89 | 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; |
101 | // clear view | 97 | // clear view |
102 | setText( QString::null ); | 98 | setText( QString::null ); |
103 | 99 | ||
104 | if ( mAddressee.isEmpty() ) | 100 | if ( mAddressee.isEmpty() ) |
105 | return; | 101 | return; |
106 | 102 | ||
107 | QString name = ( mAddressee.assembledName().isEmpty() ? | 103 | QString name = ( mAddressee.assembledName().isEmpty() ? |
108 | mAddressee.formattedName() : mAddressee.assembledName() ); | 104 | mAddressee.formattedName() : mAddressee.assembledName() ); |
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" ); |
115 | emailIt = emails.begin(); | 113 | emailIt = emails.begin(); |
116 | if ( emailIt != emails.end() ) { | 114 | if ( emailIt != emails.end() ) { |
117 | if ( kemailAvail ) { | 115 | if ( kemailAvail ) { |
118 | dynamicPart += QString( | 116 | dynamicPart += QString( |
119 | "<tr><td align=\"right\"><b>%1</b></td>" | 117 | "<tr><td align=\"right\"><b>%1</b></td>" |
120 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 118 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
121 | .arg( type ) | 119 | .arg( type ) |
122 | .arg( name ) | 120 | .arg( name ) |
123 | .arg( *emailIt ) | 121 | .arg( *emailIt ) |
124 | .arg( *emailIt ); | 122 | .arg( *emailIt ); |
125 | ++emailIt; | 123 | ++emailIt; |
126 | } else { | 124 | } else { |
127 | dynamicPart += QString( | 125 | dynamicPart += QString( |
128 | "<tr><td align=\"right\"><b>%1</b></td>" | 126 | "<tr><td align=\"right\"><b>%1</b></td>" |
129 | "<td align=\"left\">%2</td></tr>" ) | 127 | "<td align=\"left\">%2</td></tr>" ) |
130 | .arg( type ) | 128 | .arg( type ) |
131 | .arg( *emailIt ); | 129 | .arg( *emailIt ); |
132 | ++emailIt; | 130 | ++emailIt; |
133 | } | 131 | } |
134 | } | 132 | } |
135 | if ( mAddressee.birthday().date().isValid() ) { | 133 | if ( mAddressee.birthday().date().isValid() ) { |
136 | dynamicPart += QString( | 134 | dynamicPart += QString( |
137 | "<tr><td align=\"right\"><b>%1</b></td>" | 135 | "<tr><td align=\"right\"><b>%1</b></td>" |
138 | "<td align=\"left\">%2</td></tr>" ) | 136 | "<td align=\"left\">%2</td></tr>" ) |
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 ) { |
202 | dynamicPart += QString( | 144 | dynamicPart += QString( |
203 | "<tr><td align=\"right\"><b>%1</b></td>" | 145 | "<tr><td align=\"right\"><b>%1</b></td>" |
204 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 146 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
205 | .arg( type ) | 147 | .arg( type ) |
206 | .arg( name ) | 148 | .arg( name ) |
207 | .arg( *emailIt ) | 149 | .arg( *emailIt ) |
208 | .arg( *emailIt ); | 150 | .arg( *emailIt ); |
209 | } else { | 151 | } else { |
210 | dynamicPart += QString( | 152 | dynamicPart += QString( |
211 | "<tr><td align=\"right\"><b>%1</b></td>" | 153 | "<tr><td align=\"right\"><b>%1</b></td>" |
212 | "<td align=\"left\">%2</td></tr>" ) | 154 | "<td align=\"left\">%2</td></tr>" ) |
213 | .arg( type ) | 155 | .arg( type ) |
214 | .arg( *emailIt ); | 156 | .arg( *emailIt ); |
215 | } | 157 | } |
216 | } | 158 | } |
217 | 159 | ||
218 | if ( !mAddressee.url().url().isEmpty() ) { | 160 | if ( !mAddressee.url().url().isEmpty() ) { |
219 | dynamicPart += QString( | 161 | dynamicPart += QString( |
220 | "<tr><td align=\"right\"><b>%1</b></td>" | 162 | "<tr><td align=\"right\"><b>%1</b></td>" |
221 | "<td align=\"left\">%2</td></tr>" ) | 163 | "<td align=\"left\">%2</td></tr>" ) |
222 | .arg( i18n( "Homepage" ) ) | 164 | .arg( i18n( "Homepage" ) ) |
@@ -349,48 +291,117 @@ mText = "<table width=\"100%\">\n"; | |||
349 | .arg( i18n(" ") ) | 291 | .arg( i18n(" ") ) |
350 | .arg( name ); | 292 | .arg( name ); |
351 | */ | 293 | */ |
352 | if ( ! mAddressee.role().isEmpty() ) | 294 | if ( ! mAddressee.role().isEmpty() ) |
353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 295 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
354 | "<td align=\"left\">%2</td></tr>" ) | 296 | "<td align=\"left\">%2</td></tr>" ) |
355 | .arg( i18n(" ") ) | 297 | .arg( i18n(" ") ) |
356 | .arg( mAddressee.role()); | 298 | .arg( mAddressee.role()); |
357 | if ( ! mAddressee.organization().isEmpty() ) | 299 | if ( ! mAddressee.organization().isEmpty() ) |
358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 300 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
359 | "<td align=\"left\">%2</td></tr>" ) | 301 | "<td align=\"left\">%2</td></tr>" ) |
360 | .arg( i18n(" ") ) | 302 | .arg( i18n(" ") ) |
361 | .arg( mAddressee.organization()); | 303 | .arg( mAddressee.organization()); |
362 | mText += dynamicPart; | 304 | mText += dynamicPart; |
363 | mText += notes; | 305 | mText += notes; |
364 | mText += "</table>"; | 306 | mText += "</table>"; |
365 | 307 | ||
366 | } | 308 | } |
367 | 309 | ||
368 | // at last display it... | 310 | // at last display it... |
369 | setText( mText ); | 311 | setText( mText ); |
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; |
376 | } | 387 | } |
377 | void AddresseeView::addTag(const QString & tag,const QString & text) | 388 | void AddresseeView::addTag(const QString & tag,const QString & text) |
378 | { | 389 | { |
379 | if ( text.isEmpty() ) | 390 | if ( text.isEmpty() ) |
380 | return; | 391 | return; |
381 | int number=text.contains("\n"); | 392 | int number=text.contains("\n"); |
382 | QString str = "<" + tag + ">"; | 393 | QString str = "<" + tag + ">"; |
383 | QString tmpText=text; | 394 | QString tmpText=text; |
384 | QString tmpStr=str; | 395 | QString tmpStr=str; |
385 | if(number !=-1) | 396 | if(number !=-1) |
386 | { | 397 | { |
387 | if (number > 0) { | 398 | if (number > 0) { |
388 | int pos=0; | 399 | int pos=0; |
389 | QString tmp; | 400 | QString tmp; |
390 | for(int i=0;i<=number;i++) { | 401 | for(int i=0;i<=number;i++) { |
391 | pos=tmpText.find("\n"); | 402 | pos=tmpText.find("\n"); |
392 | tmp=tmpText.left(pos); | 403 | tmp=tmpText.left(pos); |
393 | tmpText=tmpText.right(tmpText.length()-pos-1); | 404 | tmpText=tmpText.right(tmpText.length()-pos-1); |
394 | tmpStr+=tmp+"<br>"; | 405 | tmpStr+=tmp+"<br>"; |
395 | } | 406 | } |
396 | } | 407 | } |
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 689d997..d8a13ee 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -30,48 +30,49 @@ | |||
30 | 30 | ||
31 | namespace KPIM { | 31 | namespace KPIM { |
32 | 32 | ||
33 | //US class AddresseeView : public KTextBrowser | 33 | //US class AddresseeView : public KTextBrowser |
34 | class AddresseeView : public QTextBrowser | 34 | class AddresseeView : public QTextBrowser |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); | 37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | Sets the addressee object. The addressee is displayed immediately. | 40 | Sets the addressee object. The addressee is displayed immediately. |
41 | 41 | ||
42 | @param addr The addressee object. | 42 | @param addr The addressee object. |
43 | */ | 43 | */ |
44 | void setAddressee( const KABC::Addressee& addr ); | 44 | void setAddressee( const KABC::Addressee& addr ); |
45 | void setSource(const QString& n); | 45 | void setSource(const QString& n); |
46 | /** | 46 | /** |
47 | Returns the current addressee object. | 47 | Returns the current addressee object. |
48 | */ | 48 | */ |
49 | KABC::Addressee addressee() const; | 49 | KABC::Addressee addressee() const; |
50 | 50 | ||
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; |
57 | }; | 58 | }; |
58 | class AddresseeChooser : public KDialogBase | 59 | class AddresseeChooser : public KDialogBase |
59 | { | 60 | { |
60 | Q_OBJECT | 61 | Q_OBJECT |
61 | 62 | ||
62 | public: | 63 | public: |
63 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); | 64 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); |
64 | 65 | ||
65 | int executeD( bool local ); | 66 | int executeD( bool local ); |
66 | 67 | ||
67 | private: | 68 | private: |
68 | int mSyncResult; | 69 | int mSyncResult; |
69 | 70 | ||
70 | private slots: | 71 | private slots: |
71 | void slot_remote(); | 72 | void slot_remote(); |
72 | void slot_local(); | 73 | void slot_local(); |
73 | 74 | ||
74 | }; | 75 | }; |
75 | 76 | ||
76 | } | 77 | } |
77 | 78 | ||
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 6e94c7e..d7e3925 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -177,47 +177,47 @@ QString PhoneNumber::typeLabel( int type ) | |||
177 | else if ((type & Voice) == Voice) { | 177 | else if ((type & Voice) == Voice) { |
178 | // add nothing in case of the Voice flag | 178 | // add nothing in case of the Voice flag |
179 | // typeString += i18n("Voice"); | 179 | // typeString += i18n("Voice"); |
180 | } | 180 | } |
181 | else if ((type & Video) == Video) | 181 | else if ((type & Video) == Video) |
182 | typeString += i18n("Video"); | 182 | typeString += i18n("Video"); |
183 | else if ((type & Bbs) == Bbs) | 183 | else if ((type & Bbs) == Bbs) |
184 | typeString += i18n("Mailbox"); | 184 | typeString += i18n("Mailbox"); |
185 | else if ((type & Modem) == Modem) | 185 | else if ((type & Modem) == Modem) |
186 | typeString += i18n("Modem"); | 186 | typeString += i18n("Modem"); |
187 | else if ((type & Car) == Car) | 187 | else if ((type & Car) == Car) |
188 | typeString += i18n("Car"); | 188 | typeString += i18n("Car"); |
189 | else if ((type & Isdn) == Isdn) | 189 | else if ((type & Isdn) == Isdn) |
190 | typeString += i18n("ISDN"); | 190 | typeString += i18n("ISDN"); |
191 | else if ((type & Pcs) == Pcs) | 191 | else if ((type & Pcs) == Pcs) |
192 | typeString += i18n("PCS"); | 192 | typeString += i18n("PCS"); |
193 | else if ((type & Pager) == Pager) | 193 | else if ((type & Pager) == Pager) |
194 | typeString += i18n("Pager"); | 194 | typeString += i18n("Pager"); |
195 | else if ((type & Sip) == Sip) | 195 | else if ((type & Sip) == Sip) |
196 | typeString += i18n("SIP"); | 196 | typeString += i18n("SIP"); |
197 | 197 | ||
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"); |
208 | 208 | ||
209 | 209 | ||
210 | return typeString; | 210 | return typeString; |
211 | } | 211 | } |
212 | 212 | ||
213 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 213 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
214 | { | 214 | { |
215 | return s << phone.mId << phone.mType << phone.mNumber; | 215 | return s << phone.mId << phone.mType << phone.mNumber; |
216 | } | 216 | } |
217 | 217 | ||
218 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 218 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
219 | { | 219 | { |
220 | s >> phone.mId >> phone.mType >> phone.mNumber; | 220 | s >> phone.mId >> phone.mType >> phone.mNumber; |
221 | 221 | ||
222 | return s; | 222 | return s; |
223 | } | 223 | } |
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 78b9941..19bb676 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -194,48 +194,49 @@ void PhoneEditWidget::updateCombos() | |||
194 | mThirdCombo->updateTypes(); | 194 | mThirdCombo->updateTypes(); |
195 | mFourthCombo->updateTypes(); | 195 | mFourthCombo->updateTypes(); |
196 | } | 196 | } |
197 | 197 | ||
198 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 198 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
199 | { | 199 | { |
200 | KABC::PhoneNumber::List retList; | 200 | KABC::PhoneNumber::List retList; |
201 | 201 | ||
202 | KABC::PhoneNumber::List::Iterator it; | 202 | KABC::PhoneNumber::List::Iterator it; |
203 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) | 203 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) |
204 | if ( !(*it).number().isEmpty() ) | 204 | if ( !(*it).number().isEmpty() ) |
205 | retList.append( *it ); | 205 | retList.append( *it ); |
206 | 206 | ||
207 | return retList; | 207 | return retList; |
208 | } | 208 | } |
209 | 209 | ||
210 | void PhoneEditWidget::edit() | 210 | void PhoneEditWidget::edit() |
211 | { | 211 | { |
212 | PhoneEditDialog dlg( mPhoneList, this ); | 212 | PhoneEditDialog dlg( mPhoneList, this ); |
213 | 213 | ||
214 | if ( dlg.exec() ) { | 214 | if ( dlg.exec() ) { |
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 | } |
221 | } | 222 | } |
222 | 223 | ||
223 | void PhoneEditWidget::updatePrefEdit() | 224 | void PhoneEditWidget::updatePrefEdit() |
224 | { | 225 | { |
225 | updateEdit( mPrefCombo ); | 226 | updateEdit( mPrefCombo ); |
226 | } | 227 | } |
227 | 228 | ||
228 | void PhoneEditWidget::updateSecondEdit() | 229 | void PhoneEditWidget::updateSecondEdit() |
229 | { | 230 | { |
230 | updateEdit( mSecondCombo ); | 231 | updateEdit( mSecondCombo ); |
231 | } | 232 | } |
232 | 233 | ||
233 | void PhoneEditWidget::updateThirdEdit() | 234 | void PhoneEditWidget::updateThirdEdit() |
234 | { | 235 | { |
235 | updateEdit( mThirdCombo ); | 236 | updateEdit( mThirdCombo ); |
236 | } | 237 | } |
237 | 238 | ||
238 | void PhoneEditWidget::updateFourthEdit() | 239 | void PhoneEditWidget::updateFourthEdit() |
239 | { | 240 | { |
240 | updateEdit( mFourthCombo ); | 241 | updateEdit( mFourthCombo ); |
241 | } | 242 | } |
@@ -268,52 +269,49 @@ void PhoneEditWidget::slotPrefEditChanged() | |||
268 | 269 | ||
269 | void PhoneEditWidget::slotSecondEditChanged() | 270 | void PhoneEditWidget::slotSecondEditChanged() |
270 | { | 271 | { |
271 | updatePhoneNumber( mSecondCombo ); | 272 | updatePhoneNumber( mSecondCombo ); |
272 | } | 273 | } |
273 | 274 | ||
274 | void PhoneEditWidget::slotThirdEditChanged() | 275 | void PhoneEditWidget::slotThirdEditChanged() |
275 | { | 276 | { |
276 | updatePhoneNumber( mThirdCombo ); | 277 | updatePhoneNumber( mThirdCombo ); |
277 | } | 278 | } |
278 | 279 | ||
279 | void PhoneEditWidget::slotFourthEditChanged() | 280 | void PhoneEditWidget::slotFourthEditChanged() |
280 | { | 281 | { |
281 | updatePhoneNumber( mFourthCombo ); | 282 | updatePhoneNumber( mFourthCombo ); |
282 | } | 283 | } |
283 | 284 | ||
284 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | 285 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) |
285 | { | 286 | { |
286 | QLineEdit *edit = combo->lineEdit(); | 287 | QLineEdit *edit = combo->lineEdit(); |
287 | if ( !edit ) return; | 288 | if ( !edit ) return; |
288 | 289 | ||
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 | } |
293 | kdDebug(5720) << "PhoneEditWidget::updatePhoneNumber(): no selected element" | ||
294 | << endl; | ||
295 | } | ||
296 | 294 | ||
297 | updateOtherEdit( combo, mPrefCombo ); | 295 | updateOtherEdit( combo, mPrefCombo ); |
298 | updateOtherEdit( combo, mSecondCombo ); | 296 | updateOtherEdit( combo, mSecondCombo ); |
299 | updateOtherEdit( combo, mThirdCombo ); | 297 | updateOtherEdit( combo, mThirdCombo ); |
300 | updateOtherEdit( combo, mFourthCombo ); | 298 | updateOtherEdit( combo, mFourthCombo ); |
301 | 299 | ||
302 | emit modified(); | 300 | emit modified(); |
303 | } | 301 | } |
304 | 302 | ||
305 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) | 303 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) |
306 | { | 304 | { |
307 | if ( combo == otherCombo ) return; | 305 | if ( combo == otherCombo ) return; |
308 | 306 | ||
309 | if ( combo->currentItem() == otherCombo->currentItem() ) { | 307 | if ( combo->currentItem() == otherCombo->currentItem() ) { |
310 | updateEdit( otherCombo ); | 308 | updateEdit( otherCombo ); |
311 | } | 309 | } |
312 | } | 310 | } |
313 | 311 | ||
314 | /////////////////////////////////////////// | 312 | /////////////////////////////////////////// |
315 | // PhoneEditDialog | 313 | // PhoneEditDialog |
316 | 314 | ||
317 | class PhoneViewItem : public QListViewItem | 315 | class PhoneViewItem : public QListViewItem |
318 | { | 316 | { |
319 | public: | 317 | public: |