author | zautrix <zautrix> | 2004-10-22 02:21:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-22 02:21:29 (UTC) |
commit | c17118a0b2da49ec633e21cdcd51798c0c38644a (patch) (side-by-side diff) | |
tree | 581fbcaa64a5566991ffe0bd3b1b2d428589d87f | |
parent | d6f9bd535e8cabe653bdff329500f9153e5e11fb (diff) | |
download | kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.zip kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.gz kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.bz2 |
made addressbook much faster
-rw-r--r-- | kabc/addresseeview.cpp | 28 | ||||
-rw-r--r-- | kabc/addresseeview.h | 10 | ||||
-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 45 |
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 @@ -88,16 +88,13 @@ void AddresseeView::setSource(const QString& n) } -void AddresseeView::setAddressee( const KABC::Addressee& addr ) +void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) { - ExternalAppHandler* eah = ExternalAppHandler::instance(); - bool kemailAvail = eah->isEmailAppAvailable(); - - - - mAddressee = addr; + bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); + // mAddressee = addr; // clear view - setText( QString::null ); - - if ( mAddressee.isEmpty() ) - return; + //setText( QString::null ); + if ( mAddressee.isEmpty() ) { + setText( QString::null); + return; + } QString name = ( mAddressee.assembledName().isEmpty() ? @@ -107,3 +104,3 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) - dynamicPart += getPhoneNumbers( true ); + dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); QStringList emails = mAddressee.emails(); @@ -138,3 +135,3 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) } - dynamicPart += getPhoneNumbers( false ); + dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); @@ -310,3 +307,3 @@ mText = "<table width=\"100%\">\n"; -QString AddresseeView::getPhoneNumbers( bool preferred ) +QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) { @@ -319,3 +316,2 @@ QString AddresseeView::getPhoneNumbers( bool preferred ) QString dynamicPart; - KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); KABC::PhoneNumber::List::ConstIterator phoneIt; @@ -379,2 +375,3 @@ QString AddresseeView::getPhoneNumbers( bool preferred ) } +/* KABC::Addressee AddresseeView::addressee() const @@ -383,2 +380,3 @@ KABC::Addressee AddresseeView::addressee() const } +*/ void AddresseeView::addTag(const QString & tag,const QString & text) diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index d8a13ee..3800512 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h @@ -48,11 +48,11 @@ class AddresseeView : public QTextBrowser */ - KABC::Addressee addressee() const; + //KABC::Addressee addressee() const; private: - KABC::Addressee mAddressee; + //KABC::Addressee mAddressee; QString mText; - QString getPhoneNumbers( bool preferred ); + QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); void addTag(const QString & tag,const QString & text); - class AddresseeViewPrivate; - AddresseeViewPrivate *d; + //class AddresseeViewPrivate; + //AddresseeViewPrivate *d; }; 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 @@ -75,2 +75,3 @@ VCardEntity::~VCardEntity() +#include <qdatetime.h>; void @@ -78,2 +79,7 @@ VCardEntity::_parse() { +#if 0 + QTime tim; + tim.start(); + int num = 0; + // old code vDebug("parse"); @@ -97,2 +103,41 @@ VCardEntity::_parse() } + +#else + // this code is up to 17 (!) times faster + int start = 0; + QTime tim; + tim.start(); + int i = 11; + int len = strRep_.length(); + int num = 0; + while (i < len ) { + while( i < len ) { + int add = 1; + if ( strRep_.at(i) == 'B' ) { + if ( i+add < len && strRep_.at(i+add++) == 'E') + if ( i+add < len && strRep_.at(i+add++) == 'G') + if ( i+add < len && strRep_.at(i+add++) == 'I') + if ( i+add < len && strRep_.at(i+add++) == 'N') + if ( i+add < len && strRep_.at(i+add++) == ':') + if ( i+add < len && strRep_.at(i+add++) == 'V') + if ( i+add < len && strRep_.at(i+add++) == 'C') + if ( i+add < len && strRep_.at(i+add++) == 'A') + if ( i+add < len && strRep_.at(i+add++) == 'R') + if ( i+add < len && strRep_.at(i+add++) == 'D') + break; + } + ++i; + } + if ( i <= len ) { + ++num; + char* dat = strRep_.data()+start; + VCard * v = new VCard( QCString ( dat,i-start ) ); + start = i; + cardList_.append(v); + v->parse(); + } + i+= 11; + } +#endif + //qDebug("***time %d found %d", tim.elapsed(), num); } |