summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-22 02:21:29 (UTC)
committer zautrix <zautrix>2004-10-22 02:21:29 (UTC)
commitc17118a0b2da49ec633e21cdcd51798c0c38644a (patch) (unidiff)
tree581fbcaa64a5566991ffe0bd3b1b2d428589d87f
parentd6f9bd535e8cabe653bdff329500f9153e5e11fb (diff)
downloadkdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.zip
kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.gz
kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.bz2
made addressbook much faster
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp28
-rw-r--r--kabc/addresseeview.h10
-rw-r--r--kabc/vcard/VCardEntity.cpp45
3 files changed, 63 insertions, 20 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 90be928..7a4336b 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -41,147 +41,144 @@
41#include "externalapphandler.h" 41#include "externalapphandler.h"
42#include "addresseeview.h" 42#include "addresseeview.h"
43 43
44 44
45//US #ifndef DESKTOP_VERSION 45//US #ifndef DESKTOP_VERSION
46//US #include <qtopia/qcopenvelope_qws.h> 46//US #include <qtopia/qcopenvelope_qws.h>
47//US #include <qpe/qpeapplication.h> 47//US #include <qpe/qpeapplication.h>
48//US #endif 48//US #endif
49 49
50//US static int kphoneInstalled = 0; 50//US static int kphoneInstalled = 0;
51 51
52using namespace KPIM; 52using namespace KPIM;
53 53
54AddresseeView::AddresseeView( QWidget *parent, const char *name ) 54AddresseeView::AddresseeView( QWidget *parent, const char *name )
55//US : KTextBrowser( parent, name ) 55//US : KTextBrowser( parent, name )
56 : QTextBrowser( parent, name ) 56 : QTextBrowser( parent, name )
57 57
58 58
59{ 59{
60//US setWrapPolicy( QTextEdit::AtWordBoundary ); 60//US setWrapPolicy( QTextEdit::AtWordBoundary );
61 setLinkUnderline( false ); 61 setLinkUnderline( false );
62 // setVScrollBarMode( QScrollView::AlwaysOff ); 62 // setVScrollBarMode( QScrollView::AlwaysOff );
63 //setHScrollBarMode( QScrollView::AlwaysOff ); 63 //setHScrollBarMode( QScrollView::AlwaysOff );
64 64
65//US QStyleSheet *sheet = styleSheet(); 65//US QStyleSheet *sheet = styleSheet();
66//US QStyleSheetItem *link = sheet->item( "a" ); 66//US QStyleSheetItem *link = sheet->item( "a" );
67//US link->setColor( KGlobalSettings::linkColor() ); 67//US link->setColor( KGlobalSettings::linkColor() );
68 68
69} 69}
70 70
71void AddresseeView::setSource(const QString& n) 71void 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}
89void AddresseeView::setAddressee( const KABC::Addressee& addr ) 89void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
90{ 90{
91 ExternalAppHandler* eah = ExternalAppHandler::instance(); 91 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
92 bool kemailAvail = eah->isEmailAppAvailable(); 92 // mAddressee = addr;
93
94
95
96 mAddressee = addr;
97 // clear view 93 // clear view
98 setText( QString::null ); 94 //setText( QString::null );
99
100 if ( mAddressee.isEmpty() )
101 return;
102 95
96 if ( mAddressee.isEmpty() ) {
97 setText( QString::null);
98 return;
99 }
103 QString name = ( mAddressee.assembledName().isEmpty() ? 100 QString name = ( mAddressee.assembledName().isEmpty() ?
104 mAddressee.formattedName() : mAddressee.assembledName() ); 101 mAddressee.formattedName() : mAddressee.assembledName() );
105 102
106 QString dynamicPart; 103 QString dynamicPart;
107 104
108 dynamicPart += getPhoneNumbers( true ); 105 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true );
109 QStringList emails = mAddressee.emails(); 106 QStringList emails = mAddressee.emails();
110 QStringList::ConstIterator emailIt; 107 QStringList::ConstIterator emailIt;
111 QString type = i18n( "Email" ); 108 QString type = i18n( "Email" );
112 emailIt = emails.begin(); 109 emailIt = emails.begin();
113 if ( emailIt != emails.end() ) { 110 if ( emailIt != emails.end() ) {
114 if ( kemailAvail ) { 111 if ( kemailAvail ) {
115 dynamicPart += QString( 112 dynamicPart += QString(
116 "<tr><td align=\"right\"><b>%1</b></td>" 113 "<tr><td align=\"right\"><b>%1</b></td>"
117 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 114 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
118 .arg( type ) 115 .arg( type )
119 .arg( name ) 116 .arg( name )
120 .arg( *emailIt ) 117 .arg( *emailIt )
121 .arg( *emailIt ); 118 .arg( *emailIt );
122 ++emailIt; 119 ++emailIt;
123 } else { 120 } else {
124 dynamicPart += QString( 121 dynamicPart += QString(
125 "<tr><td align=\"right\"><b>%1</b></td>" 122 "<tr><td align=\"right\"><b>%1</b></td>"
126 "<td align=\"left\">%2</td></tr>" ) 123 "<td align=\"left\">%2</td></tr>" )
127 .arg( type ) 124 .arg( type )
128 .arg( *emailIt ); 125 .arg( *emailIt );
129 ++emailIt; 126 ++emailIt;
130 } 127 }
131 } 128 }
132 if ( mAddressee.birthday().date().isValid() ) { 129 if ( mAddressee.birthday().date().isValid() ) {
133 dynamicPart += QString( 130 dynamicPart += QString(
134 "<tr><td align=\"right\"><b>%1</b></td>" 131 "<tr><td align=\"right\"><b>%1</b></td>"
135 "<td align=\"left\">%2</td></tr>" ) 132 "<td align=\"left\">%2</td></tr>" )
136 .arg( i18n ("Birthday") ) 133 .arg( i18n ("Birthday") )
137 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 134 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
138 } 135 }
139 dynamicPart += getPhoneNumbers( false ); 136 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
140 137
141 for ( ; emailIt != emails.end(); ++emailIt ) { 138 for ( ; emailIt != emails.end(); ++emailIt ) {
142 if ( kemailAvail ) { 139 if ( kemailAvail ) {
143 dynamicPart += QString( 140 dynamicPart += QString(
144 "<tr><td align=\"right\"><b>%1</b></td>" 141 "<tr><td align=\"right\"><b>%1</b></td>"
145 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 142 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
146 .arg( type ) 143 .arg( type )
147 .arg( name ) 144 .arg( name )
148 .arg( *emailIt ) 145 .arg( *emailIt )
149 .arg( *emailIt ); 146 .arg( *emailIt );
150 } else { 147 } else {
151 dynamicPart += QString( 148 dynamicPart += QString(
152 "<tr><td align=\"right\"><b>%1</b></td>" 149 "<tr><td align=\"right\"><b>%1</b></td>"
153 "<td align=\"left\">%2</td></tr>" ) 150 "<td align=\"left\">%2</td></tr>" )
154 .arg( type ) 151 .arg( type )
155 .arg( *emailIt ); 152 .arg( *emailIt );
156 } 153 }
157 } 154 }
158 155
159 if ( !mAddressee.url().url().isEmpty() ) { 156 if ( !mAddressee.url().url().isEmpty() ) {
160 dynamicPart += QString( 157 dynamicPart += QString(
161 "<tr><td align=\"right\"><b>%1</b></td>" 158 "<tr><td align=\"right\"><b>%1</b></td>"
162 "<td align=\"left\">%2</td></tr>" ) 159 "<td align=\"left\">%2</td></tr>" )
163 .arg( i18n( "Homepage" ) ) 160 .arg( i18n( "Homepage" ) )
164//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 161//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
165 .arg( mAddressee.url().url() ); 162 .arg( mAddressee.url().url() );
166 //qDebug("AddresseeView::setAddressee has to be verified."); 163 //qDebug("AddresseeView::setAddressee has to be verified.");
167 } 164 }
168 165
169 KABC::Address::List addresses = mAddressee.addresses(); 166 KABC::Address::List addresses = mAddressee.addresses();
170 KABC::Address::List::ConstIterator addrIt; 167 KABC::Address::List::ConstIterator addrIt;
171 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 168 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
172 if ( true /*(*addrIt).label().isEmpty()*/ ) { 169 if ( true /*(*addrIt).label().isEmpty()*/ ) {
173 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 170 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
174//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 171//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
175 //qDebug("adresss %s ",formattedAddress.latin1() ); 172 //qDebug("adresss %s ",formattedAddress.latin1() );
176 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 173 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
177 //qDebug("AddresseeView::setAddressee has to be verified."); 174 //qDebug("AddresseeView::setAddressee has to be verified.");
178 175
179 dynamicPart += QString( 176 dynamicPart += QString(
180 "<tr><td align=\"right\"><b>%1</b></td>" 177 "<tr><td align=\"right\"><b>%1</b></td>"
181 "<td align=\"left\">%2</td></tr>" ) 178 "<td align=\"left\">%2</td></tr>" )
182 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 179 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
183 .arg( formattedAddress ); 180 .arg( formattedAddress );
184 } else { 181 } else {
185 182
186 dynamicPart += QString( 183 dynamicPart += QString(
187 "<tr><td align=\"right\"><b>%1</b></td>" 184 "<tr><td align=\"right\"><b>%1</b></td>"
@@ -263,169 +260,170 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
263 .arg( name ) 260 .arg( name )
264 .arg( aRole ) 261 .arg( aRole )
265 .arg( aOrga ) 262 .arg( aOrga )
266 .arg( dynamicPart ) 263 .arg( dynamicPart )
267 .arg( notes ); 264 .arg( notes );
268 265
269 } else { // no picture! 266 } else { // no picture!
270 267
271mText = "<table width=\"100%\">\n"; 268mText = "<table width=\"100%\">\n";
272 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 269 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
273#ifdef DESKTOP_VERSION 270#ifdef DESKTOP_VERSION
274 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 271 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
275 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; 272 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>";
276#else 273#else
277 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; 274 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>";
278 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; 275 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>";
279#endif 276#endif
280 277
281 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 278 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
282 279
283 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 280 mText += "<table><td colspan=\"2\">&nbsp;</td>";
284 /* 281 /*
285 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 282 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
286 "<td align=\"left\"><b>%2</b></td></tr>" ) 283 "<td align=\"left\"><b>%2</b></td></tr>" )
287 .arg( i18n(" ") ) 284 .arg( i18n(" ") )
288 .arg( name ); 285 .arg( name );
289 */ 286 */
290 if ( ! mAddressee.role().isEmpty() ) 287 if ( ! mAddressee.role().isEmpty() )
291 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 288 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
292 "<td align=\"left\">%2</td></tr>" ) 289 "<td align=\"left\">%2</td></tr>" )
293 .arg( i18n(" ") ) 290 .arg( i18n(" ") )
294 .arg( mAddressee.role()); 291 .arg( mAddressee.role());
295 if ( ! mAddressee.organization().isEmpty() ) 292 if ( ! mAddressee.organization().isEmpty() )
296 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 293 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
297 "<td align=\"left\">%2</td></tr>" ) 294 "<td align=\"left\">%2</td></tr>" )
298 .arg( i18n(" ") ) 295 .arg( i18n(" ") )
299 .arg( mAddressee.organization()); 296 .arg( mAddressee.organization());
300 mText += dynamicPart; 297 mText += dynamicPart;
301 mText += notes; 298 mText += notes;
302 mText += "</table>"; 299 mText += "</table>";
303 300
304 } 301 }
305 302
306 // at last display it... 303 // at last display it...
307 setText( mText ); 304 setText( mText );
308 305
309} 306}
310 307
311QString AddresseeView::getPhoneNumbers( bool preferred ) 308QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred )
312{ 309{
313 ExternalAppHandler* eah = ExternalAppHandler::instance(); 310 ExternalAppHandler* eah = ExternalAppHandler::instance();
314 bool kphoneAvail = eah->isPhoneAppAvailable(); 311 bool kphoneAvail = eah->isPhoneAppAvailable();
315 bool kfaxAvail = eah->isFaxAppAvailable(); 312 bool kfaxAvail = eah->isFaxAppAvailable();
316 bool ksmsAvail = eah->isSMSAppAvailable(); 313 bool ksmsAvail = eah->isSMSAppAvailable();
317 bool kpagerAvail = eah->isPagerAppAvailable(); 314 bool kpagerAvail = eah->isPagerAppAvailable();
318 bool ksipAvail = eah->isSIPAppAvailable(); 315 bool ksipAvail = eah->isSIPAppAvailable();
319 QString dynamicPart; 316 QString dynamicPart;
320 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
321 KABC::PhoneNumber::List::ConstIterator phoneIt; 317 KABC::PhoneNumber::List::ConstIterator phoneIt;
322 QString extension; 318 QString extension;
323 int phonetype; 319 int phonetype;
324 QString sms; 320 QString sms;
325 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 321 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
326 phonetype = (*phoneIt).type(); 322 phonetype = (*phoneIt).type();
327 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 323 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred )
328 continue; 324 continue;
329 if (ksmsAvail && 325 if (ksmsAvail &&
330 ( 326 (
331 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 327 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
332 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 328 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
333 ) 329 )
334 ) 330 )
335 { 331 {
336 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 332 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
337 .arg( (*phoneIt).number() ); 333 .arg( (*phoneIt).number() );
338 334
339 } 335 }
340 else 336 else
341 sms = ""; 337 sms = "";
342 338
343 extension = QString::null; 339 extension = QString::null;
344 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 340 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
345 if (kfaxAvail) extension = "faxto:"; 341 if (kfaxAvail) extension = "faxto:";
346 } 342 }
347 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 343 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
348 if (kpagerAvail) extension = "pagerto:"; 344 if (kpagerAvail) extension = "pagerto:";
349 } 345 }
350 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 346 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
351 if (ksipAvail) extension = "sipto:"; 347 if (ksipAvail) extension = "sipto:";
352 } 348 }
353 else if (kphoneAvail) { 349 else if (kphoneAvail) {
354 extension = "phoneto:"; 350 extension = "phoneto:";
355 } 351 }
356 else 352 else
357 extension = QString::null; 353 extension = QString::null;
358 354
359 if ( !extension.isEmpty() ) { 355 if ( !extension.isEmpty() ) {
360 dynamicPart += QString( 356 dynamicPart += QString(
361 "<tr><td align=\"right\"><b>%1</b></td>" 357 "<tr><td align=\"right\"><b>%1</b></td>"
362 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 358 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
363 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 359 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
364 .arg( extension ) 360 .arg( extension )
365 .arg( (*phoneIt).number() ) 361 .arg( (*phoneIt).number() )
366 .arg( (*phoneIt).number() ) 362 .arg( (*phoneIt).number() )
367 .arg( sms ); 363 .arg( sms );
368 364
369 } else { 365 } else {
370 dynamicPart += QString( 366 dynamicPart += QString(
371 "<tr><td align=\"right\"><b>%1</b></td>" 367 "<tr><td align=\"right\"><b>%1</b></td>"
372 "<td align=\"left\">%2 %3</td></tr>" ) 368 "<td align=\"left\">%2 %3</td></tr>" )
373 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 369 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
374 .arg( (*phoneIt).number() ) 370 .arg( (*phoneIt).number() )
375 .arg( sms ); 371 .arg( sms );
376 } 372 }
377 } 373 }
378 return dynamicPart; 374 return dynamicPart;
379} 375}
376/*
380KABC::Addressee AddresseeView::addressee() const 377KABC::Addressee AddresseeView::addressee() const
381{ 378{
382 return mAddressee; 379 return mAddressee;
383} 380}
381*/
384void AddresseeView::addTag(const QString & tag,const QString & text) 382void AddresseeView::addTag(const QString & tag,const QString & text)
385{ 383{
386 if ( text.isEmpty() ) 384 if ( text.isEmpty() )
387 return; 385 return;
388 int number=text.contains("\n"); 386 int number=text.contains("\n");
389 QString str = "<" + tag + ">"; 387 QString str = "<" + tag + ">";
390 QString tmpText=text; 388 QString tmpText=text;
391 QString tmpStr=str; 389 QString tmpStr=str;
392 if(number !=-1) 390 if(number !=-1)
393 { 391 {
394 if (number > 0) { 392 if (number > 0) {
395 int pos=0; 393 int pos=0;
396 QString tmp; 394 QString tmp;
397 for(int i=0;i<=number;i++) { 395 for(int i=0;i<=number;i++) {
398 pos=tmpText.find("\n"); 396 pos=tmpText.find("\n");
399 tmp=tmpText.left(pos); 397 tmp=tmpText.left(pos);
400 tmpText=tmpText.right(tmpText.length()-pos-1); 398 tmpText=tmpText.right(tmpText.length()-pos-1);
401 tmpStr+=tmp+"<br>"; 399 tmpStr+=tmp+"<br>";
402 } 400 }
403 } 401 }
404 else tmpStr += tmpText; 402 else tmpStr += tmpText;
405 tmpStr+="</" + tag + ">"; 403 tmpStr+="</" + tag + ">";
406 mText.append(tmpStr); 404 mText.append(tmpStr);
407 } 405 }
408 else 406 else
409 { 407 {
410 str += text + "</" + tag + ">"; 408 str += text + "</" + tag + ">";
411 mText.append(str); 409 mText.append(str);
412 } 410 }
413} 411}
414 412
415AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 413AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
416 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 414 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
417{ 415{
418 findButton( Close )->setText( i18n("Cancel Sync")); 416 findButton( Close )->setText( i18n("Cancel Sync"));
419 findButton( Ok )->setText( i18n("Remote")); 417 findButton( Ok )->setText( i18n("Remote"));
420 findButton( User1 )->setText( i18n("Local")); 418 findButton( User1 )->setText( i18n("Local"));
421 QWidget* topframe = new QWidget( this ); 419 QWidget* topframe = new QWidget( this );
422 setMainWidget( topframe ); 420 setMainWidget( topframe );
423 QBoxLayout* bl; 421 QBoxLayout* bl;
424 if ( QApplication::desktop()->width() < 640 ) { 422 if ( QApplication::desktop()->width() < 640 ) {
425 bl = new QVBoxLayout( topframe ); 423 bl = new QVBoxLayout( topframe );
426 } else { 424 } else {
427 bl = new QHBoxLayout( topframe ); 425 bl = new QHBoxLayout( topframe );
428 } 426 }
429 QVBox* subframe = new QVBox( topframe ); 427 QVBox* subframe = new QVBox( topframe );
430 bl->addWidget(subframe ); 428 bl->addWidget(subframe );
431 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 429 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h
index d8a13ee..3800512 100644
--- a/kabc/addresseeview.h
+++ b/kabc/addresseeview.h
@@ -1,79 +1,79 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef KPIM_ADDRESSEEVIEW_H 22#ifndef KPIM_ADDRESSEEVIEW_H
23#define KPIM_ADDRESSEEVIEW_H 23#define KPIM_ADDRESSEEVIEW_H
24 24
25#include <kabc/addressee.h> 25#include <kabc/addressee.h>
26#include <kdialogbase.h> 26#include <kdialogbase.h>
27 27
28//US #include <ktextbrowser.h> 28//US #include <ktextbrowser.h>
29#include <qtextbrowser.h> 29#include <qtextbrowser.h>
30 30
31namespace KPIM { 31namespace KPIM {
32 32
33//US class AddresseeView : public KTextBrowser 33//US class AddresseeView : public KTextBrowser
34class AddresseeView : public QTextBrowser 34class 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 QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred );
55 void addTag(const QString & tag,const QString & text); 55 void addTag(const QString & tag,const QString & text);
56 class AddresseeViewPrivate; 56 //class AddresseeViewPrivate;
57 AddresseeViewPrivate *d; 57 //AddresseeViewPrivate *d;
58}; 58};
59class AddresseeChooser : public KDialogBase 59class AddresseeChooser : public KDialogBase
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 62
63 public: 63 public:
64 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 );
65 65
66 int executeD( bool local ); 66 int executeD( bool local );
67 67
68 private: 68 private:
69 int mSyncResult; 69 int mSyncResult;
70 70
71 private slots: 71 private slots:
72 void slot_remote(); 72 void slot_remote();
73 void slot_local(); 73 void slot_local();
74 74
75}; 75};
76 76
77} 77}
78 78
79#endif 79#endif
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp
index 5fca3bc..b676cc7 100644
--- a/kabc/vcard/VCardEntity.cpp
+++ b/kabc/vcard/VCardEntity.cpp
@@ -28,102 +28,147 @@
28 28
29using namespace VCARD; 29using namespace VCARD;
30 30
31VCardEntity::VCardEntity() 31VCardEntity::VCardEntity()
32 :Entity() 32 :Entity()
33{ 33{
34 cardList_.setAutoDelete( TRUE ); 34 cardList_.setAutoDelete( TRUE );
35} 35}
36 36
37VCardEntity::VCardEntity(const VCardEntity & x) 37VCardEntity::VCardEntity(const VCardEntity & x)
38 :Entity(x) 38 :Entity(x)
39{ 39{
40 cardList_.setAutoDelete( TRUE ); 40 cardList_.setAutoDelete( TRUE );
41} 41}
42 42
43VCardEntity::VCardEntity(const QCString & s) 43VCardEntity::VCardEntity(const QCString & s)
44 :Entity(s) 44 :Entity(s)
45{ 45{
46 cardList_.setAutoDelete( TRUE ); 46 cardList_.setAutoDelete( TRUE );
47} 47}
48 48
49 VCardEntity & 49 VCardEntity &
50VCardEntity::operator = (VCardEntity & x) 50VCardEntity::operator = (VCardEntity & x)
51{ 51{
52 if (*this == x) return *this; 52 if (*this == x) return *this;
53 53
54 Entity::operator = (x); 54 Entity::operator = (x);
55 return *this; 55 return *this;
56} 56}
57 57
58 VCardEntity & 58 VCardEntity &
59VCardEntity::operator = (const QCString & s) 59VCardEntity::operator = (const QCString & s)
60{ 60{
61 Entity::operator = (s); 61 Entity::operator = (s);
62 return *this; 62 return *this;
63} 63}
64 64
65 bool 65 bool
66VCardEntity::operator == (VCardEntity & x) 66VCardEntity::operator == (VCardEntity & x)
67{ 67{
68 x.parse(); 68 x.parse();
69 return false; 69 return false;
70} 70}
71 71
72VCardEntity::~VCardEntity() 72VCardEntity::~VCardEntity()
73{ 73{
74} 74}
75 75
76#include <qdatetime.h>;
76 void 77 void
77VCardEntity::_parse() 78VCardEntity::_parse()
78{ 79{
80#if 0
81 QTime tim;
82 tim.start();
83 int num = 0;
84 // old code
79 vDebug("parse"); 85 vDebug("parse");
80 QCString s(strRep_); 86 QCString s(strRep_);
81 87
82 int i = s.find(QRegExp("BEGIN:VCARD", false)); 88 int i = s.find(QRegExp("BEGIN:VCARD", false));
83 89
84 while (i != -1) { 90 while (i != -1) {
85 91
86 i = s.find(QRegExp("BEGIN:VCARD", false), 11); 92 i = s.find(QRegExp("BEGIN:VCARD", false), 11);
87 93
88 QCString cardStr(s.left(i)); 94 QCString cardStr(s.left(i));
89 95
90 VCard * v = new VCard(cardStr); 96 VCard * v = new VCard(cardStr);
91 97
92 cardList_.append(v); 98 cardList_.append(v);
93 99
94 v->parse(); 100 v->parse();
95 101
96 s.remove(0, i); 102 s.remove(0, i);
97 } 103 }
104
105#else
106 // this code is up to 17 (!) times faster
107 int start = 0;
108 QTime tim;
109 tim.start();
110 int i = 11;
111 int len = strRep_.length();
112 int num = 0;
113 while (i < len ) {
114 while( i < len ) {
115 int add = 1;
116 if ( strRep_.at(i) == 'B' ) {
117 if ( i+add < len && strRep_.at(i+add++) == 'E')
118 if ( i+add < len && strRep_.at(i+add++) == 'G')
119 if ( i+add < len && strRep_.at(i+add++) == 'I')
120 if ( i+add < len && strRep_.at(i+add++) == 'N')
121 if ( i+add < len && strRep_.at(i+add++) == ':')
122 if ( i+add < len && strRep_.at(i+add++) == 'V')
123 if ( i+add < len && strRep_.at(i+add++) == 'C')
124 if ( i+add < len && strRep_.at(i+add++) == 'A')
125 if ( i+add < len && strRep_.at(i+add++) == 'R')
126 if ( i+add < len && strRep_.at(i+add++) == 'D')
127 break;
128 }
129 ++i;
130 }
131 if ( i <= len ) {
132 ++num;
133 char* dat = strRep_.data()+start;
134 VCard * v = new VCard( QCString ( dat,i-start ) );
135 start = i;
136 cardList_.append(v);
137 v->parse();
138 }
139 i+= 11;
140 }
141#endif
142 //qDebug("***time %d found %d", tim.elapsed(), num);
98} 143}
99 144
100 void 145 void
101VCardEntity::_assemble() 146VCardEntity::_assemble()
102{ 147{
103 VCardListIterator it(cardList_); 148 VCardListIterator it(cardList_);
104 149
105 for (; it.current(); ++it) 150 for (; it.current(); ++it)
106 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. 151 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck.
107} 152}
108 153
109 VCardList & 154 VCardList &
110VCardEntity::cardList() 155VCardEntity::cardList()
111{ 156{
112 parse(); 157 parse();
113 return cardList_; 158 return cardList_;
114} 159}
115 160
116 void 161 void
117VCardEntity::setCardList(const VCardList & l) 162VCardEntity::setCardList(const VCardList & l)
118{ 163{
119 parse(); 164 parse();
120 //UScardList_ = l; 165 //UScardList_ = l;
121 VCardListIterator it(l); 166 VCardListIterator it(l);
122 167
123 for (; it.current(); ++it) { 168 for (; it.current(); ++it) {
124 VCard* v = new VCard(*it.current()); 169 VCard* v = new VCard(*it.current());
125 cardList_.append(v); 170 cardList_.append(v);
126 } 171 }
127 172
128} 173}
129 174