-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp index b676cc7..2a9e275 100644 --- a/kabc/vcard/VCardEntity.cpp +++ b/kabc/vcard/VCardEntity.cpp | |||
@@ -79,96 +79,97 @@ VCardEntity::_parse() | |||
79 | { | 79 | { |
80 | #if 0 | 80 | #if 0 |
81 | QTime tim; | 81 | QTime tim; |
82 | tim.start(); | 82 | tim.start(); |
83 | int num = 0; | 83 | int num = 0; |
84 | // old code | 84 | // old code |
85 | vDebug("parse"); | 85 | vDebug("parse"); |
86 | QCString s(strRep_); | 86 | QCString s(strRep_); |
87 | 87 | ||
88 | int i = s.find(QRegExp("BEGIN:VCARD", false)); | 88 | int i = s.find(QRegExp("BEGIN:VCARD", false)); |
89 | 89 | ||
90 | while (i != -1) { | 90 | while (i != -1) { |
91 | 91 | ||
92 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); | 92 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); |
93 | 93 | ||
94 | QCString cardStr(s.left(i)); | 94 | QCString cardStr(s.left(i)); |
95 | 95 | ||
96 | VCard * v = new VCard(cardStr); | 96 | VCard * v = new VCard(cardStr); |
97 | 97 | ||
98 | cardList_.append(v); | 98 | cardList_.append(v); |
99 | 99 | ||
100 | v->parse(); | 100 | v->parse(); |
101 | 101 | ||
102 | s.remove(0, i); | 102 | s.remove(0, i); |
103 | } | 103 | } |
104 | 104 | ||
105 | #else | 105 | #else |
106 | // this code is up to 17 (!) times faster | 106 | // this code is up to 17 (!) times faster |
107 | int start = 0; | 107 | int start = 0; |
108 | QTime tim; | 108 | QTime tim; |
109 | tim.start(); | 109 | tim.start(); |
110 | int i = 11; | 110 | int i = 11; |
111 | int len = strRep_.length(); | 111 | int len = strRep_.length(); |
112 | int num = 0; | 112 | int num = 0; |
113 | while (i < len ) { | 113 | while (i < len ) { |
114 | while( i < len ) { | 114 | while( i < len ) { |
115 | int add = 1; | 115 | int add = 1; |
116 | if ( strRep_.at(i) == 'B' ) { | 116 | if ( strRep_.at(i) == 'B' ) { |
117 | if ( i+add < len && strRep_.at(i+add++) == 'E') | 117 | if ( i+add < len && strRep_.at(i+add++) == 'E') |
118 | if ( i+add < len && strRep_.at(i+add++) == 'G') | 118 | if ( i+add < len && strRep_.at(i+add++) == 'G') |
119 | if ( i+add < len && strRep_.at(i+add++) == 'I') | 119 | if ( i+add < len && strRep_.at(i+add++) == 'I') |
120 | if ( i+add < len && strRep_.at(i+add++) == 'N') | 120 | if ( i+add < len && strRep_.at(i+add++) == 'N') |
121 | if ( i+add < len && strRep_.at(i+add++) == ':') | 121 | if ( i+add < len && strRep_.at(i+add++) == ':') |
122 | if ( i+add < len && strRep_.at(i+add++) == 'V') | 122 | if ( i+add < len && strRep_.at(i+add++) == 'V') |
123 | if ( i+add < len && strRep_.at(i+add++) == 'C') | 123 | if ( i+add < len && strRep_.at(i+add++) == 'C') |
124 | if ( i+add < len && strRep_.at(i+add++) == 'A') | 124 | if ( i+add < len && strRep_.at(i+add++) == 'A') |
125 | if ( i+add < len && strRep_.at(i+add++) == 'R') | 125 | if ( i+add < len && strRep_.at(i+add++) == 'R') |
126 | if ( i+add < len && strRep_.at(i+add++) == 'D') | 126 | if ( i+add < len && strRep_.at(i+add++) == 'D') |
127 | if ( i+add < len && (strRep_.at(i+add) == '\r' || strRep_.at(i+add) == '\n' )) | ||
127 | break; | 128 | break; |
128 | } | 129 | } |
129 | ++i; | 130 | ++i; |
130 | } | 131 | } |
131 | if ( i <= len ) { | 132 | if ( i <= len ) { |
132 | ++num; | 133 | ++num; |
133 | char* dat = strRep_.data()+start; | 134 | char* dat = strRep_.data()+start; |
134 | VCard * v = new VCard( QCString ( dat,i-start ) ); | 135 | VCard * v = new VCard( QCString ( dat,i-start ) ); |
135 | start = i; | 136 | start = i; |
136 | cardList_.append(v); | 137 | cardList_.append(v); |
137 | v->parse(); | 138 | v->parse(); |
138 | } | 139 | } |
139 | i+= 11; | 140 | i+= 11; |
140 | } | 141 | } |
141 | #endif | 142 | #endif |
142 | //qDebug("***time %d found %d", tim.elapsed(), num); | 143 | qDebug("***time %d found %d", tim.elapsed(), num); |
143 | } | 144 | } |
144 | 145 | ||
145 | void | 146 | void |
146 | VCardEntity::_assemble() | 147 | VCardEntity::_assemble() |
147 | { | 148 | { |
148 | VCardListIterator it(cardList_); | 149 | VCardListIterator it(cardList_); |
149 | 150 | ||
150 | for (; it.current(); ++it) | 151 | for (; it.current(); ++it) |
151 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. | 152 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. |
152 | } | 153 | } |
153 | 154 | ||
154 | VCardList & | 155 | VCardList & |
155 | VCardEntity::cardList() | 156 | VCardEntity::cardList() |
156 | { | 157 | { |
157 | parse(); | 158 | parse(); |
158 | return cardList_; | 159 | return cardList_; |
159 | } | 160 | } |
160 | 161 | ||
161 | void | 162 | void |
162 | VCardEntity::setCardList(const VCardList & l) | 163 | VCardEntity::setCardList(const VCardList & l) |
163 | { | 164 | { |
164 | parse(); | 165 | parse(); |
165 | //UScardList_ = l; | 166 | //UScardList_ = l; |
166 | VCardListIterator it(l); | 167 | VCardListIterator it(l); |
167 | 168 | ||
168 | for (; it.current(); ++it) { | 169 | for (; it.current(); ++it) { |
169 | VCard* v = new VCard(*it.current()); | 170 | VCard* v = new VCard(*it.current()); |
170 | cardList_.append(v); | 171 | cardList_.append(v); |
171 | } | 172 | } |
172 | 173 | ||
173 | } | 174 | } |
174 | 175 | ||