-rw-r--r-- | kabc/addresseeview.cpp | 200 | ||||
-rw-r--r-- | kabc/addresseeview.h | 5 |
2 files changed, 169 insertions, 36 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 667a5e2..202a718 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -53,12 +53,13 @@ | |||
53 | //US #include <qpe/qpeapplication.h> | 53 | //US #include <qpe/qpeapplication.h> |
54 | //US #endif | 54 | //US #endif |
55 | 55 | ||
56 | //US static int kphoneInstalled = 0; | 56 | //US static int kphoneInstalled = 0; |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | bool AddresseeView::sFullDetailsMode = false; | ||
59 | 60 | ||
60 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 61 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
61 | : QTextBrowser( parent, name ) | 62 | : QTextBrowser( parent, name ) |
62 | 63 | ||
63 | 64 | ||
64 | { | 65 | { |
@@ -97,35 +98,41 @@ void AddresseeView::printMe() | |||
97 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 98 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
98 | p.end(); | 99 | p.end(); |
99 | #endif | 100 | #endif |
100 | } | 101 | } |
101 | void AddresseeView::setSource(const QString& n) | 102 | void AddresseeView::setSource(const QString& n) |
102 | { | 103 | { |
103 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 104 | qDebug("********AddresseeView::setSource %s", n.latin1()); |
104 | 105 | ||
105 | if ( n.left( 6 ) == "mailto" ) | 106 | if ( n == "allDetails" ) { |
106 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 107 | sFullDetailsMode = true; |
107 | else if ( n.left( 7 ) == "phoneto" ) | 108 | setAddressee( mCurrentContact ); |
108 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 109 | } else if ( n == "notAllDetails" ) { |
109 | else if ( n.left( 5 ) == "faxto" ) | 110 | sFullDetailsMode = false; |
110 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 111 | setAddressee( mCurrentContact ); |
111 | else if ( n.left( 5 ) == "smsto" ) | 112 | } else if ( n.left( 6 ) == "mailto" ) |
112 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 113 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
113 | else if ( n.left( 7 ) == "pagerto" ) | 114 | else if ( n.left( 7 ) == "phoneto" ) |
114 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 115 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
115 | else if ( n.left( 5 ) == "sipto" ) | 116 | else if ( n.left( 5 ) == "faxto" ) |
116 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 117 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
118 | else if ( n.left( 5 ) == "smsto" ) | ||
119 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | ||
120 | else if ( n.left( 7 ) == "pagerto" ) | ||
121 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | ||
122 | else if ( n.left( 5 ) == "sipto" ) | ||
123 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | ||
117 | 124 | ||
118 | } | 125 | } |
119 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | 126 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) |
120 | { | 127 | { |
121 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); | 128 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); |
122 | // mAddressee = addr; | 129 | // mAddressee = addr; |
123 | // clear view | 130 | // clear view |
124 | //setText( QString::null ); | 131 | //setText( QString::null ); |
125 | 132 | mCurrentContact = mAddressee; | |
126 | if ( mAddressee.isEmpty() ) { | 133 | if ( mAddressee.isEmpty() ) { |
127 | setText( QString::null); | 134 | setText( QString::null); |
128 | return; | 135 | return; |
129 | } | 136 | } |
130 | #if 0 | 137 | #if 0 |
131 | QString name = ( mAddressee.assembledName().isEmpty() ? | 138 | QString name = ( mAddressee.assembledName().isEmpty() ? |
@@ -184,21 +191,13 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
184 | "<td align=\"left\">%2</td></tr>" ) | 191 | "<td align=\"left\">%2</td></tr>" ) |
185 | .arg( type ) | 192 | .arg( type ) |
186 | .arg( *emailIt ); | 193 | .arg( *emailIt ); |
187 | } | 194 | } |
188 | } | 195 | } |
189 | 196 | ||
190 | if ( !mAddressee.url().url().isEmpty() ) { | 197 | |
191 | dynamicPart += QString( | ||
192 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
193 | "<td align=\"left\">%2</td></tr>" ) | ||
194 | .arg( i18n( "Homepage" ) ) | ||
195 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | ||
196 | .arg( mAddressee.url().url() ); | ||
197 | //qDebug("AddresseeView::setAddressee has to be verified."); | ||
198 | } | ||
199 | 198 | ||
200 | KABC::Address::List addresses = mAddressee.addresses(); | 199 | KABC::Address::List addresses = mAddressee.addresses(); |
201 | KABC::Address::List::ConstIterator addrIt; | 200 | KABC::Address::List::ConstIterator addrIt; |
202 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 201 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
203 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 202 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
204 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 203 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
@@ -220,23 +219,156 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
220 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 219 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
221 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 220 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
222 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 221 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
223 | 222 | ||
224 | } | 223 | } |
225 | } | 224 | } |
225 | |||
226 | |||
227 | QString notes; | ||
228 | if ( sFullDetailsMode ) { | ||
229 | notes = QString( | ||
230 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
231 | "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) | ||
232 | .arg( i18n("Details:") ) | ||
233 | .arg( i18n("Click here to hide!") ); | ||
234 | |||
235 | QString tempX = mAddressee.secrecy().asString(); | ||
236 | |||
237 | notes += QString( | ||
238 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
239 | "<td align=\"left\">%2</td></tr>" ) | ||
240 | .arg( "" ) | ||
241 | .arg( tempX ); | ||
242 | |||
243 | |||
244 | tempX = mAddressee.categories().join(" - "); | ||
245 | if ( !tempX.isEmpty() ) { | ||
246 | notes += QString( | ||
247 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
248 | "<td align=\"left\">%2</td></tr>" ) | ||
249 | .arg( i18n( "Category" ) ) | ||
250 | .arg( tempX ); | ||
251 | } | ||
252 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" ); | ||
253 | if ( !tempX.isEmpty() ) { | ||
254 | notes += QString( | ||
255 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
256 | "<td align=\"left\">%2</td></tr>" ) | ||
257 | .arg( i18n( "Profession" ) ) | ||
258 | .arg( tempX ); | ||
259 | } | ||
260 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" ); | ||
261 | if ( !tempX.isEmpty() ) { | ||
262 | notes += QString( | ||
263 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
264 | "<td align=\"left\">%2</td></tr>" ) | ||
265 | .arg( i18n( "Office" ) ) | ||
266 | .arg( tempX ); | ||
267 | } | ||
268 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" ); | ||
269 | if ( !tempX.isEmpty() ) { | ||
270 | notes += QString( | ||
271 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
272 | "<td align=\"left\">%2</td></tr>" ) | ||
273 | .arg( i18n( "Department" ) ) | ||
274 | .arg( tempX ); | ||
275 | } | ||
276 | |||
277 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ); | ||
278 | if ( !tempX.isEmpty() ) { | ||
279 | notes += QString( | ||
280 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
281 | "<td align=\"left\">%2</td></tr>" ) | ||
282 | .arg( i18n( "Manager" ) ) | ||
283 | .arg( tempX ); | ||
284 | } | ||
285 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); | ||
286 | if ( !tempX.isEmpty() ) { | ||
287 | notes += QString( | ||
288 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
289 | "<td align=\"left\">%2</td></tr>" ) | ||
290 | .arg( i18n( "Assistant" ) ) | ||
291 | .arg( tempX ); | ||
292 | } | ||
293 | if ( !mAddressee.url().url().isEmpty() ) { | ||
294 | notes += QString( | ||
295 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
296 | "<td align=\"left\">%2</td></tr>" ) | ||
297 | .arg( i18n( "Homepage" ) ) | ||
298 | .arg( mAddressee.url().url() ); | ||
299 | } | ||
300 | tempX = mAddressee.nickName(); | ||
301 | if ( !tempX.isEmpty() ) { | ||
302 | notes += QString( | ||
303 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
304 | "<td align=\"left\">%2</td></tr>" ) | ||
305 | .arg( i18n( "Nickname" ) ) | ||
306 | .arg( tempX ); | ||
307 | } | ||
308 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); | ||
309 | if ( !tempX.isEmpty() ) { | ||
310 | notes += QString( | ||
311 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
312 | "<td align=\"left\">%2</td></tr>" ) | ||
313 | .arg( i18n( "Messanger" ) ) | ||
314 | .arg( tempX ); | ||
315 | } | ||
316 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); | ||
317 | if ( !tempX.isEmpty() ) { | ||
318 | notes += QString( | ||
319 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
320 | "<td align=\"left\">%2</td></tr>" ) | ||
321 | .arg( i18n( "Gender" ) ) | ||
322 | .arg( i18n(tempX) ); | ||
323 | } | ||
324 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); | ||
325 | if ( !tempX.isEmpty() ) { | ||
326 | QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); | ||
327 | tempX = KGlobal::locale()->formatDate(dt, true); | ||
328 | notes += QString( | ||
329 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
330 | "<td align=\"left\">%2</td></tr>" ) | ||
331 | .arg( i18n( "Anniversary" ) ) | ||
332 | .arg( tempX ); | ||
333 | } | ||
334 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); | ||
335 | if ( !tempX.isEmpty() ) { | ||
336 | notes += QString( | ||
337 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
338 | "<td align=\"left\">%2</td></tr>" ) | ||
339 | .arg( i18n( "Spouse" ) ) | ||
340 | .arg( tempX ); | ||
341 | } | ||
342 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); | ||
343 | if ( !tempX.isEmpty() ) { | ||
344 | notes += QString( | ||
345 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
346 | "<td align=\"left\">%2</td></tr>" ) | ||
347 | .arg( i18n( "Children" ) ) | ||
348 | .arg( tempX ); | ||
349 | } | ||
350 | |||
351 | if ( !mAddressee.note().isEmpty() ) { | ||
352 | notes += QString( | ||
353 | "<tr>" | ||
354 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | ||
355 | "<td align=\"left\">%2</td>" // note | ||
356 | "</tr>" ).arg( i18n( "Notes" ) ) | ||
357 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | ||
358 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | ||
359 | //qDebug("AddresseeView::setAddressee has to be verified."); | ||
360 | } | ||
361 | } else { | ||
362 | notes = QString( | ||
363 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
364 | "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) | ||
365 | .arg( i18n("Details:") ) | ||
366 | .arg( i18n("Click here to show!") ); | ||
367 | |||
226 | 368 | ||
227 | QString notes; | ||
228 | if ( !mAddressee.note().isEmpty() ) { | ||
229 | notes = QString( | ||
230 | "<tr>" | ||
231 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | ||
232 | "<td align=\"left\">%2</td>" // note | ||
233 | "</tr>" ).arg( i18n( "Notes" ) ) | ||
234 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | ||
235 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | ||
236 | //qDebug("AddresseeView::setAddressee has to be verified."); | ||
237 | } | 369 | } |
238 | 370 | ||
239 | QString aRole = ""; | 371 | QString aRole = ""; |
240 | QString aOrga = ""; | 372 | QString aOrga = ""; |
241 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 373 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
242 | aRole = "<tr>" | 374 | aRole = "<tr>" |
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index e977d8f..a4de085 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -46,14 +46,15 @@ class AddresseeView : public QTextBrowser | |||
46 | void setSource(const QString& n); | 46 | void setSource(const QString& n); |
47 | /** | 47 | /** |
48 | Returns the current addressee object. | 48 | Returns the current addressee object. |
49 | */ | 49 | */ |
50 | //KABC::Addressee addressee() const; | 50 | //KABC::Addressee addressee() const; |
51 | void printMe(); | 51 | void printMe(); |
52 | 52 | static bool sFullDetailsMode; | |
53 | private: | 53 | private: |
54 | Addressee mCurrentContact; | ||
54 | //KABC::Addressee mAddressee; | 55 | //KABC::Addressee mAddressee; |
55 | QString mText; | 56 | QString mText; |
56 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); | 57 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); |
57 | void addTag(const QString & tag,const QString & text); | 58 | void addTag(const QString & tag,const QString & text); |
58 | //class AddresseeViewPrivate; | 59 | //class AddresseeViewPrivate; |
59 | //AddresseeViewPrivate *d; | 60 | //AddresseeViewPrivate *d; |