author | zautrix <zautrix> | 2004-10-22 02:21:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-22 02:21:29 (UTC) |
commit | c17118a0b2da49ec633e21cdcd51798c0c38644a (patch) (unidiff) | |
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) | |||
88 | } | 88 | } |
89 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 89 | void 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() ? |
@@ -107,3 +104,3 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
107 | 104 | ||
108 | dynamicPart += getPhoneNumbers( true ); | 105 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); |
109 | QStringList emails = mAddressee.emails(); | 106 | QStringList emails = mAddressee.emails(); |
@@ -138,3 +135,3 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
138 | } | 135 | } |
139 | dynamicPart += getPhoneNumbers( false ); | 136 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); |
140 | 137 | ||
@@ -310,3 +307,3 @@ mText = "<table width=\"100%\">\n"; | |||
310 | 307 | ||
311 | QString AddresseeView::getPhoneNumbers( bool preferred ) | 308 | QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) |
312 | { | 309 | { |
@@ -319,3 +316,2 @@ QString AddresseeView::getPhoneNumbers( bool preferred ) | |||
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; |
@@ -379,2 +375,3 @@ QString AddresseeView::getPhoneNumbers( bool preferred ) | |||
379 | } | 375 | } |
376 | /* | ||
380 | KABC::Addressee AddresseeView::addressee() const | 377 | KABC::Addressee AddresseeView::addressee() const |
@@ -383,2 +380,3 @@ KABC::Addressee AddresseeView::addressee() const | |||
383 | } | 380 | } |
381 | */ | ||
384 | void AddresseeView::addTag(const QString & tag,const QString & text) | 382 | 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 | |||
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 | }; |
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() | |||
75 | 75 | ||
76 | #include <qdatetime.h>; | ||
76 | void | 77 | void |
@@ -78,2 +79,7 @@ VCardEntity::_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"); |
@@ -97,2 +103,41 @@ VCardEntity::_parse() | |||
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 | } |