author | zautrix <zautrix> | 2005-01-14 11:37:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-14 11:37:40 (UTC) |
commit | 61c95ce0295f1397db6499c5b468a9fb3d32a0f4 (patch) (unidiff) | |
tree | 2bceecc46d42a572adfad7d8e5000d1534642cbd /kabc | |
parent | a46ecf5ed81460ec9a4e457798e1bf0fb74c5624 (diff) | |
download | kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.zip kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.tar.gz kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.tar.bz2 |
made kapi saving faster
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kabc/picture.cpp | 38 | ||||
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 30 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 77 |
4 files changed, 99 insertions, 48 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3ce733d..568dfc4 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1678,16 +1678,17 @@ Key Addressee::findKey( const QString &id ) const | |||
1678 | QString Addressee::asString() const | 1678 | QString Addressee::asString() const |
1679 | { | 1679 | { |
1680 | return "Smith, agent Smith..."; | 1680 | return "Smith, agent Smith..."; |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | void Addressee::dump() const | 1683 | void Addressee::dump() const |
1684 | { | 1684 | { |
1685 | return; | 1685 | return; |
1686 | #if 0 | ||
1686 | kdDebug(5700) << "Addressee {" << endl; | 1687 | kdDebug(5700) << "Addressee {" << endl; |
1687 | 1688 | ||
1688 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1689 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1689 | 1690 | ||
1690 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1691 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1691 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1692 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1692 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1693 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1693 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1694 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
@@ -1741,16 +1742,17 @@ void Addressee::dump() const | |||
1741 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1742 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1742 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1743 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1743 | " Key: " << (*it4).textData() << | 1744 | " Key: " << (*it4).textData() << |
1744 | " CustomString: " << (*it4).customTypeString() << endl; | 1745 | " CustomString: " << (*it4).customTypeString() << endl; |
1745 | } | 1746 | } |
1746 | kdDebug(5700) << " }" << endl; | 1747 | kdDebug(5700) << " }" << endl; |
1747 | 1748 | ||
1748 | kdDebug(5700) << "}" << endl; | 1749 | kdDebug(5700) << "}" << endl; |
1750 | #endif | ||
1749 | } | 1751 | } |
1750 | 1752 | ||
1751 | 1753 | ||
1752 | void Addressee::insertAddress( const Address &address ) | 1754 | void Addressee::insertAddress( const Address &address ) |
1753 | { | 1755 | { |
1754 | detach(); | 1756 | detach(); |
1755 | mData->empty = false; | 1757 | mData->empty = false; |
1756 | 1758 | ||
diff --git a/kabc/picture.cpp b/kabc/picture.cpp index 6a34b98..57aa297 100644 --- a/kabc/picture.cpp +++ b/kabc/picture.cpp | |||
@@ -48,26 +48,52 @@ Picture::Picture( const QImage &data ) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | Picture::~Picture() | 50 | Picture::~Picture() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | bool Picture::operator==( const Picture &p ) const | 54 | bool Picture::operator==( const Picture &p ) const |
55 | { | 55 | { |
56 | if ( mIntern != p.mIntern ) return false; | 56 | //qDebug("compare PIC "); |
57 | 57 | if ( mUndefined && p.mUndefined ) { | |
58 | //qDebug("compare PIC true 1 "); | ||
59 | return true; | ||
60 | } | ||
61 | if ( mUndefined || p.mUndefined ) { | ||
62 | //qDebug("compare PIC false 1"); | ||
63 | return false; | ||
64 | } | ||
65 | // now we should deal with two defined pics! | ||
66 | if ( mIntern != p.mIntern ) { | ||
67 | //qDebug("compare PIC false 2"); | ||
68 | return false; | ||
69 | } | ||
58 | if ( mIntern ) { | 70 | if ( mIntern ) { |
59 | if ( mData != p.mData ) | 71 | //qDebug("mIntern "); |
72 | if ( mData.isNull() && p.mData.isNull() ) { | ||
73 | //qDebug("compare PIC true 2 "); | ||
74 | return true; | ||
75 | } | ||
76 | if ( mData.isNull() || p.mData.isNull() ){ | ||
77 | //qDebug("compare PIC false 3-1"); | ||
78 | |||
79 | return false; | ||
80 | } | ||
81 | if ( mData != p.mData ) { | ||
82 | //qDebug("compare PIC false 3"); | ||
60 | return false; | 83 | return false; |
84 | } | ||
61 | } else { | 85 | } else { |
62 | if ( mUrl != p.mUrl ) | 86 | if ( mUrl != p.mUrl ) { |
63 | return false; | 87 | //qDebug("compare PIC false 4"); |
88 | return false; | ||
89 | } | ||
64 | } | 90 | } |
65 | 91 | //qDebug("compare PIC true "); | |
66 | return true; | 92 | return true; |
67 | } | 93 | } |
68 | 94 | ||
69 | bool Picture::operator!=( const Picture &p ) const | 95 | bool Picture::operator!=( const Picture &p ) const |
70 | { | 96 | { |
71 | return !( p == *this ); | 97 | return !( p == *this ); |
72 | } | 98 | } |
73 | 99 | ||
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index c368172..2f88cde 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -268,16 +268,43 @@ ContentLine::_parse() | |||
268 | } | 268 | } |
269 | 269 | ||
270 | *value_ = valuePart; | 270 | *value_ = valuePart; |
271 | } | 271 | } |
272 | 272 | ||
273 | void | 273 | void |
274 | ContentLine::_assemble() | 274 | ContentLine::_assemble() |
275 | { | 275 | { |
276 | //strRep_.truncate(0); | ||
277 | QString line; | ||
278 | if (!group_.isEmpty()) | ||
279 | line = group_ + '.'; | ||
280 | line += name_; | ||
281 | ParamListIterator it(paramList_); | ||
282 | for (; it.current(); ++it) | ||
283 | line += ";" + it.current()->asString(); | ||
284 | |||
285 | if (value_ != 0) | ||
286 | line += ":" + value_->asString(); | ||
287 | |||
288 | line = line.replace( QRegExp( "\n" ), "\\n" ); | ||
289 | |||
290 | // Fold lines longer than 72 chars | ||
291 | const int maxLen = 72; | ||
292 | uint cursor = 0; | ||
293 | QString cut; | ||
294 | while( line.length() > ( cursor + 1 ) * maxLen ) { | ||
295 | cut += line.mid( cursor * maxLen, maxLen ); | ||
296 | cut += "\r\n "; | ||
297 | ++cursor; | ||
298 | } | ||
299 | cut += line.mid( cursor * maxLen ); | ||
300 | strRep_ = cut.latin1(); | ||
301 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | ||
302 | #if 0 | ||
276 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); | 303 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); |
277 | strRep_.truncate(0); | 304 | strRep_.truncate(0); |
278 | 305 | ||
279 | QCString line; | 306 | QCString line; |
280 | 307 | ||
281 | if (!group_.isEmpty()) | 308 | if (!group_.isEmpty()) |
282 | line += group_ + '.'; | 309 | line += group_ + '.'; |
283 | 310 | ||
@@ -302,17 +329,18 @@ ContentLine::_assemble() | |||
302 | const int maxLen = 72; | 329 | const int maxLen = 72; |
303 | uint cursor = 0; | 330 | uint cursor = 0; |
304 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 331 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
305 | strRep_ += line.mid( cursor * maxLen, maxLen ); | 332 | strRep_ += line.mid( cursor * maxLen, maxLen ); |
306 | strRep_ += "\r\n "; | 333 | strRep_ += "\r\n "; |
307 | ++cursor; | 334 | ++cursor; |
308 | } | 335 | } |
309 | strRep_ += line.mid( cursor * maxLen ); | 336 | strRep_ += line.mid( cursor * maxLen ); |
310 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | 337 | qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); |
338 | #endif | ||
311 | } | 339 | } |
312 | 340 | ||
313 | void | 341 | void |
314 | ContentLine::clear() | 342 | ContentLine::clear() |
315 | { | 343 | { |
316 | group_.truncate(0); | 344 | group_.truncate(0); |
317 | name_.truncate(0); | 345 | name_.truncate(0); |
318 | paramList_.clear(); | 346 | paramList_.clear(); |
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index bc80707..49bfe43 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -18,16 +18,19 @@ | |||
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qstringlist.h> | ||
27 | #include <qstring.h> | ||
28 | #include <qvaluelist.h> | ||
26 | 29 | ||
27 | #include <VCardEntity.h> | 30 | #include <VCardEntity.h> |
28 | #include <VCardVCard.h> | 31 | #include <VCardVCard.h> |
29 | #include <VCardContentLine.h> | 32 | #include <VCardContentLine.h> |
30 | #include <VCardRToken.h> | 33 | #include <VCardRToken.h> |
31 | 34 | ||
32 | #include <VCardDefines.h> | 35 | #include <VCardDefines.h> |
33 | 36 | ||
@@ -91,124 +94,115 @@ VCard::operator == (VCard & x) | |||
91 | 94 | ||
92 | VCard::~VCard() | 95 | VCard::~VCard() |
93 | { | 96 | { |
94 | } | 97 | } |
95 | 98 | ||
96 | void | 99 | void |
97 | VCard::_parse() | 100 | VCard::_parse() |
98 | { | 101 | { |
99 | vDebug("parse() called"); | 102 | |
100 | QStrList l; | 103 | QStringList l; |
104 | QStrList sl; | ||
101 | 105 | ||
102 | RTokenise(strRep_, "\r\n", l); | 106 | RTokenise(strRep_, "\r\n", sl); |
103 | 107 | ||
104 | if (l.count() < 3) { // Invalid VCARD ! | 108 | if (sl.count() < 3) { // Invalid VCARD ! |
105 | vDebug("Invalid vcard"); | 109 | //qDebug("invalid vcard "); |
106 | return; | 110 | return; |
107 | } | 111 | } |
108 | 112 | l = QStringList::fromStrList( sl ); | |
109 | // Get the first line | 113 | // Get the first line |
110 | QCString beginLine = QCString(l.at(0)).stripWhiteSpace(); | 114 | QString beginLine = l[0].stripWhiteSpace(); |
111 | |||
112 | vDebug("Begin line == \"" + beginLine + "\""); | ||
113 | 115 | ||
114 | // Remove extra blank lines | 116 | // Remove extra blank lines |
115 | while (QCString(l.last()).isEmpty()) | 117 | while (l.last().isEmpty()) |
116 | l.remove(l.last()); | 118 | l.remove(l.last()); |
117 | 119 | ||
118 | // Now we know this is the last line | 120 | // Now we know this is the last line |
119 | QCString endLine = l.last(); | 121 | QString endLine = l.last(); |
120 | 122 | ||
121 | // Trash the first and last lines as we have seen them. | 123 | // Trash the first and last lines as we have seen them. |
122 | l.remove(0u); | 124 | l.remove(l.first()); |
123 | l.remove(l.last()); | 125 | l.remove(l.last()); |
124 | 126 | ||
125 | /////////////////////////////////////////////////////////////// | 127 | /////////////////////////////////////////////////////////////// |
126 | // FIRST LINE | 128 | // FIRST LINE |
127 | 129 | ||
128 | int split = beginLine.find(':'); | 130 | int split = beginLine.find(':'); |
129 | 131 | ||
130 | if (split == -1) { // invalid, no BEGIN | 132 | if (split == -1) { // invalid, no BEGIN |
131 | vDebug("No split"); | 133 | vDebug("No split"); |
132 | return; | 134 | return; |
133 | } | 135 | } |
134 | 136 | ||
135 | QCString firstPart(beginLine.left(split)); | 137 | QString firstPart(beginLine.left(split)); |
136 | QCString valuePart(beginLine.mid(split + 1)); | 138 | QString valuePart(beginLine.mid(split + 1)); |
137 | 139 | ||
138 | split = firstPart.find('.'); | 140 | split = firstPart.find('.'); |
139 | 141 | ||
140 | if (split != -1) { | 142 | if (split != -1) { |
141 | group_ = firstPart.left(split); | 143 | group_ = firstPart.left(split); |
142 | firstPart= firstPart.right(firstPart.length() - split - 1); | 144 | firstPart= firstPart.right(firstPart.length() - split - 1); |
143 | } | 145 | } |
144 | 146 | ||
145 | if (qstrnicmp(firstPart, "BEGIN", 5) != 0) { // No BEGIN ! | 147 | if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! |
146 | vDebug("No BEGIN"); | 148 | qDebug("no BEGIN in vcard "); |
147 | return; | 149 | return; |
148 | } | 150 | } |
149 | 151 | ||
150 | if (qstrnicmp(valuePart, "VCARD", 5) != 0) { // Not a vcard ! | 152 | if (valuePart.left(5) != "VCARD") { // Not a vcard ! |
151 | vDebug("No VCARD"); | 153 | qDebug("not a VCARD "); |
152 | return; | 154 | return; |
153 | } | 155 | } |
154 | 156 | ||
155 | /////////////////////////////////////////////////////////////// | 157 | /////////////////////////////////////////////////////////////// |
156 | // CONTENT LINES | 158 | // CONTENT LINES |
157 | // | 159 | // |
158 | vDebug("Content lines"); | 160 | vDebug("Content lines"); |
159 | 161 | ||
160 | // Handle folded lines. | 162 | // Handle folded lines. |
161 | 163 | ||
162 | QStrList refolded; | 164 | QStringList refolded; |
163 | |||
164 | QStrListIterator it(l); | ||
165 | 165 | ||
166 | QCString cur; | ||
167 | 166 | ||
168 | for (; it.current(); ++it) { | 167 | QStringList::Iterator it = l.begin(); |
169 | 168 | ||
170 | cur = it.current(); | 169 | QString cur; |
171 | 170 | ||
171 | for (; it != l.end(); ++it) { | ||
172 | cur = (*it); | ||
172 | ++it; | 173 | ++it; |
173 | 174 | while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { | |
174 | while ( | 175 | cur += (*it) ; |
175 | it.current() && | ||
176 | it.current()[0] == ' '&& | ||
177 | strlen(it.current()) != 1) | ||
178 | { | ||
179 | cur += it.current() + 1; | ||
180 | ++it; | 176 | ++it; |
181 | } | 177 | } |
182 | |||
183 | --it; | 178 | --it; |
184 | |||
185 | refolded.append(cur); | 179 | refolded.append(cur); |
186 | } | 180 | } |
187 | 181 | QStringList::Iterator it2 = refolded.begin(); | |
188 | QStrListIterator it2(refolded); | 182 | for (; it2 != refolded.end(); ++it2) { |
189 | 183 | ContentLine * cl = new ContentLine(QCString((*it2).latin1())); | |
190 | for (; it2.current(); ++it2) { | ||
191 | vDebug("New contentline using \"" + QCString(it2.current()) + "\""); | ||
192 | ContentLine * cl = new ContentLine(it2.current()); | ||
193 | |||
194 | cl->parse(); | 184 | cl->parse(); |
195 | if (cl->value() == 0) | 185 | if (cl->value() == 0) |
196 | { | 186 | { |
197 | qDebug("Content line could not be parsed. Discarded: %s", it2.current()); | 187 | qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); |
198 | delete cl; | 188 | delete cl; |
199 | } | 189 | } |
200 | else | 190 | else |
201 | contentLineList_.append(cl); | 191 | contentLineList_.append(cl); |
202 | } | 192 | } |
203 | 193 | ||
204 | /////////////////////////////////////////////////////////////// | 194 | /////////////////////////////////////////////////////////////// |
205 | // LAST LINE | 195 | // LAST LINE |
206 | 196 | ||
197 | |||
198 | // LR: sorry, but the remaining code in this method makes no sense | ||
199 | |||
200 | #if 0 | ||
207 | split = endLine.find(':'); | 201 | split = endLine.find(':'); |
208 | 202 | ||
209 | if (split == -1) // invalid, no END | 203 | if (split == -1) // invalid, no END |
210 | return; | 204 | return; |
211 | 205 | ||
212 | firstPart = endLine.left(split); | 206 | firstPart = endLine.left(split); |
213 | valuePart = endLine.right(firstPart.length() - split - 1); | 207 | valuePart = endLine.right(firstPart.length() - split - 1); |
214 | 208 | ||
@@ -219,16 +213,17 @@ VCard::_parse() | |||
219 | firstPart= firstPart.right(firstPart.length() - split - 1); | 213 | firstPart= firstPart.right(firstPart.length() - split - 1); |
220 | } | 214 | } |
221 | 215 | ||
222 | if (qstricmp(firstPart, "END") != 0) // No END ! | 216 | if (qstricmp(firstPart, "END") != 0) // No END ! |
223 | return; | 217 | return; |
224 | 218 | ||
225 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! | 219 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! |
226 | return; | 220 | return; |
221 | #endif | ||
227 | } | 222 | } |
228 | 223 | ||
229 | void | 224 | void |
230 | VCard::_assemble() | 225 | VCard::_assemble() |
231 | { | 226 | { |
232 | vDebug("Assembling vcard"); | 227 | vDebug("Assembling vcard"); |
233 | strRep_ = "BEGIN:VCARD\r\n"; | 228 | strRep_ = "BEGIN:VCARD\r\n"; |
234 | strRep_ += "VERSION:3.0\r\n"; | 229 | strRep_ += "VERSION:3.0\r\n"; |