author | zautrix <zautrix> | 2005-02-11 05:36:14 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-11 05:36:14 (UTC) |
commit | 0c1191e3253542b4858261241975c159ee7910c6 (patch) (unidiff) | |
tree | be97b6665d130f0b72db82005726fbf7cc030abb /kabc/vcard | |
parent | 38c6a7b6ae1e98cba0fdf2d0fba59ad4b9060940 (diff) | |
download | kdepimpi-0c1191e3253542b4858261241975c159ee7910c6.zip kdepimpi-0c1191e3253542b4858261241975c159ee7910c6.tar.gz kdepimpi-0c1191e3253542b4858261241975c159ee7910c6.tar.bz2 |
font fixes
-rw-r--r-- | kabc/vcard/ContentLine.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index 2f88cde..0a2f97d 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp | |||
@@ -68,282 +68,288 @@ ContentLine::ContentLine() | |||
68 | :Entity(), | 68 | :Entity(), |
69 | value_(0), | 69 | value_(0), |
70 | paramType_( ParamUnknown ), | 70 | paramType_( ParamUnknown ), |
71 | valueType_( ValueUnknown ), | 71 | valueType_( ValueUnknown ), |
72 | entityType_( EntityUnknown ) | 72 | entityType_( EntityUnknown ) |
73 | { | 73 | { |
74 | paramList_.setAutoDelete( TRUE ); | 74 | paramList_.setAutoDelete( TRUE ); |
75 | } | 75 | } |
76 | 76 | ||
77 | ContentLine::ContentLine(const ContentLine & x) | 77 | ContentLine::ContentLine(const ContentLine & x) |
78 | :Entity(x), | 78 | :Entity(x), |
79 | group_ (x.group_), | 79 | group_ (x.group_), |
80 | name_ (x.name_), | 80 | name_ (x.name_), |
81 | /*US paramList_(x.paramList_),*/ | 81 | /*US paramList_(x.paramList_),*/ |
82 | value_(x.value_->clone()), | 82 | value_(x.value_->clone()), |
83 | paramType_(x.paramType_), | 83 | paramType_(x.paramType_), |
84 | valueType_(x.valueType_), | 84 | valueType_(x.valueType_), |
85 | entityType_(x.entityType_) | 85 | entityType_(x.entityType_) |
86 | { | 86 | { |
87 | paramList_.setAutoDelete( TRUE ); | 87 | paramList_.setAutoDelete( TRUE ); |
88 | 88 | ||
89 | 89 | ||
90 | ParamListIterator it(x.paramList_); | 90 | ParamListIterator it(x.paramList_); |
91 | for (; it.current(); ++it) | 91 | for (; it.current(); ++it) |
92 | { | 92 | { |
93 | Param *p = new Param; | 93 | Param *p = new Param; |
94 | p->setName( it.current()->name() ); | 94 | p->setName( it.current()->name() ); |
95 | p->setValue( it.current()->value() ); | 95 | p->setValue( it.current()->value() ); |
96 | paramList_.append(p); | 96 | paramList_.append(p); |
97 | } | 97 | } |
98 | 98 | ||
99 | } | 99 | } |
100 | 100 | ||
101 | ContentLine::ContentLine(const QCString & s) | 101 | ContentLine::ContentLine(const QCString & s) |
102 | :Entity(s), | 102 | :Entity(s), |
103 | value_(0), | 103 | value_(0), |
104 | paramType_( ParamUnknown ), | 104 | paramType_( ParamUnknown ), |
105 | valueType_( ValueUnknown ), | 105 | valueType_( ValueUnknown ), |
106 | entityType_( EntityUnknown ) | 106 | entityType_( EntityUnknown ) |
107 | { | 107 | { |
108 | paramList_.setAutoDelete( TRUE ); | 108 | paramList_.setAutoDelete( TRUE ); |
109 | } | 109 | } |
110 | 110 | ||
111 | ContentLine & | 111 | ContentLine & |
112 | ContentLine::operator = (ContentLine & x) | 112 | ContentLine::operator = (ContentLine & x) |
113 | { | 113 | { |
114 | if (*this == x) return *this; | 114 | if (*this == x) return *this; |
115 | 115 | ||
116 | ParamListIterator it(x.paramList_); | 116 | ParamListIterator it(x.paramList_); |
117 | for (; it.current(); ++it) | 117 | for (; it.current(); ++it) |
118 | { | 118 | { |
119 | Param *p = new Param; | 119 | Param *p = new Param; |
120 | p->setName( it.current()->name() ); | 120 | p->setName( it.current()->name() ); |
121 | p->setValue( it.current()->value() ); | 121 | p->setValue( it.current()->value() ); |
122 | paramList_.append(p); | 122 | paramList_.append(p); |
123 | } | 123 | } |
124 | 124 | ||
125 | value_ = x.value_->clone(); | 125 | value_ = x.value_->clone(); |
126 | 126 | ||
127 | Entity::operator = (x); | 127 | Entity::operator = (x); |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | ContentLine & | 131 | ContentLine & |
132 | ContentLine::operator = (const QCString & s) | 132 | ContentLine::operator = (const QCString & s) |
133 | { | 133 | { |
134 | Entity::operator = (s); | 134 | Entity::operator = (s); |
135 | delete value_; | 135 | delete value_; |
136 | value_ = 0; | 136 | value_ = 0; |
137 | return *this; | 137 | return *this; |
138 | } | 138 | } |
139 | 139 | ||
140 | bool | 140 | bool |
141 | ContentLine::operator == (ContentLine & x) | 141 | ContentLine::operator == (ContentLine & x) |
142 | { | 142 | { |
143 | x.parse(); | 143 | x.parse(); |
144 | 144 | ||
145 | QPtrListIterator<Param> it(x.paramList()); | 145 | QPtrListIterator<Param> it(x.paramList()); |
146 | 146 | ||
147 | if (!paramList_.find(it.current())) | 147 | if (!paramList_.find(it.current())) |
148 | return false; | 148 | return false; |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | ContentLine::~ContentLine() | 153 | ContentLine::~ContentLine() |
154 | { | 154 | { |
155 | delete value_; | 155 | delete value_; |
156 | value_ = 0; | 156 | value_ = 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | void | 159 | void |
160 | ContentLine::_parse() | 160 | ContentLine::_parse() |
161 | { | 161 | { |
162 | vDebug("parse"); | 162 | vDebug("parse"); |
163 | 163 | ||
164 | // Unqote newlines | 164 | // Unfold folded lines |
165 | // NLR | ||
166 | strRep_ = strRep_.replace( QRegExp( "\\r" ), "" ); | ||
167 | // Unqote newlines | ||
165 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); | 168 | strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" ); |
169 | //NLR | ||
170 | strRep_ = strRep_.replace( QRegExp( "\\\\r" ), "\r" ); | ||
166 | 171 | ||
167 | int split = strRep_.find(':'); | 172 | int split = strRep_.find(':'); |
168 | 173 | ||
169 | if (split == -1) { // invalid content line | 174 | if (split == -1) { // invalid content line |
170 | vDebug("No ':'"); | 175 | vDebug("No ':'"); |
171 | return; | 176 | return; |
172 | } | 177 | } |
173 | 178 | ||
174 | QCString firstPart(strRep_.left(split)); | 179 | QCString firstPart(strRep_.left(split)); |
175 | QCString valuePart(strRep_.mid(split + 1)); | 180 | QCString valuePart(strRep_.mid(split + 1)); |
176 | 181 | ||
177 | split = firstPart.find('.'); | 182 | split = firstPart.find('.'); |
178 | 183 | ||
179 | if (split != -1) { | 184 | if (split != -1) { |
180 | group_ = firstPart.left(split); | 185 | group_ = firstPart.left(split); |
181 | firstPart= firstPart.mid(split + 1); | 186 | firstPart= firstPart.mid(split + 1); |
182 | } | 187 | } |
183 | 188 | ||
184 | vDebug("Group == " + group_); | 189 | vDebug("Group == " + group_); |
185 | vDebug("firstPart == " + firstPart); | 190 | vDebug("firstPart == " + firstPart); |
186 | vDebug("valuePart == " + valuePart); | 191 | vDebug("valuePart == " + valuePart); |
187 | 192 | ||
188 | // Now we have the group, the name and param list together and the value. | 193 | // Now we have the group, the name and param list together and the value. |
189 | 194 | ||
190 | QStrList l; | 195 | QStrList l; |
191 | 196 | ||
192 | RTokenise(firstPart, ";", l); | 197 | RTokenise(firstPart, ";", l); |
193 | 198 | ||
194 | if (l.count() == 0) {// invalid - no name ! | 199 | if (l.count() == 0) {// invalid - no name ! |
195 | vDebug("No name for this content line !"); | 200 | vDebug("No name for this content line !"); |
196 | return; | 201 | return; |
197 | } | 202 | } |
198 | 203 | ||
199 | name_ = l.at(0); | 204 | name_ = l.at(0); |
200 | 205 | ||
201 | // Now we have the name, so the rest of 'l' is the params. | 206 | // Now we have the name, so the rest of 'l' is the params. |
202 | // Remove the name part. | 207 | // Remove the name part. |
203 | l.remove(0u); | 208 | l.remove(0u); |
204 | 209 | ||
205 | entityType_= EntityNameToEntityType(name_); | 210 | entityType_= EntityNameToEntityType(name_); |
206 | paramType_= EntityTypeToParamType(entityType_); | 211 | paramType_= EntityTypeToParamType(entityType_); |
207 | 212 | ||
208 | unsigned int i = 0; | 213 | unsigned int i = 0; |
209 | 214 | ||
210 | // For each parameter, create a new parameter of the correct type. | 215 | // For each parameter, create a new parameter of the correct type. |
211 | 216 | ||
212 | QStrListIterator it(l); | 217 | QStrListIterator it(l); |
213 | 218 | ||
214 | for (; it.current(); ++it, i++) { | 219 | for (; it.current(); ++it, i++) { |
215 | 220 | ||
216 | QCString str = *it; | 221 | QCString str = *it; |
217 | 222 | ||
218 | split = str.find("="); | 223 | split = str.find("="); |
219 | if (split < 0 ) { | 224 | if (split < 0 ) { |
220 | vDebug("No '=' in paramter."); | 225 | vDebug("No '=' in paramter."); |
221 | continue; | 226 | continue; |
222 | } | 227 | } |
223 | 228 | ||
224 | QCString paraName = str.left(split); | 229 | QCString paraName = str.left(split); |
225 | QCString paraValue = str.mid(split + 1); | 230 | QCString paraValue = str.mid(split + 1); |
226 | 231 | ||
227 | QStrList paraValues; | 232 | QStrList paraValues; |
228 | RTokenise(paraValue, ",", paraValues); | 233 | RTokenise(paraValue, ",", paraValues); |
229 | 234 | ||
230 | QStrListIterator it2( paraValues ); | 235 | QStrListIterator it2( paraValues ); |
231 | 236 | ||
232 | for(; it2.current(); ++it2) { | 237 | for(; it2.current(); ++it2) { |
233 | 238 | ||
234 | Param *p = new Param; | 239 | Param *p = new Param; |
235 | p->setName( paraName ); | 240 | p->setName( paraName ); |
236 | p->setValue( *it2 ); | 241 | p->setValue( *it2 ); |
237 | 242 | ||
238 | paramList_.append(p); | 243 | paramList_.append(p); |
239 | } | 244 | } |
240 | } | 245 | } |
241 | 246 | ||
242 | // Create a new value of the correct type. | 247 | // Create a new value of the correct type. |
243 | 248 | ||
244 | valueType_ = EntityTypeToValueType(entityType_); | 249 | valueType_ = EntityTypeToValueType(entityType_); |
245 | 250 | ||
246 | //kdDebug(5710) << "valueType: " << valueType_ << endl; | 251 | //kdDebug(5710) << "valueType: " << valueType_ << endl; |
247 | 252 | ||
248 | switch (valueType_) { | 253 | switch (valueType_) { |
249 | 254 | ||
250 | case ValueSound: value_ = new SoundValue;break; | 255 | case ValueSound: value_ = new SoundValue;break; |
251 | case ValueAgent: value_ = new AgentValue;break; | 256 | case ValueAgent: value_ = new AgentValue;break; |
252 | case ValueAddress: value_ = new AdrValue; break; | 257 | case ValueAddress: value_ = new AdrValue; break; |
253 | case ValueTel: value_ = new TelValue; break; | 258 | case ValueTel: value_ = new TelValue; break; |
254 | case ValueTextBin: value_ = new TextBinValue;break; | 259 | case ValueTextBin: value_ = new TextBinValue;break; |
255 | case ValueOrg: value_ = new OrgValue; break; | 260 | case ValueOrg: value_ = new OrgValue; break; |
256 | case ValueN: value_ = new NValue; break; | 261 | case ValueN: value_ = new NValue; break; |
257 | case ValueUTC: value_ = new UTCValue; break; | 262 | case ValueUTC: value_ = new UTCValue; break; |
258 | case ValueURI: value_ = new URIValue; break; | 263 | case ValueURI: value_ = new URIValue; break; |
259 | case ValueClass: value_ = new ClassValue;break; | 264 | case ValueClass: value_ = new ClassValue;break; |
260 | case ValueFloat: value_ = new FloatValue;break; | 265 | case ValueFloat: value_ = new FloatValue;break; |
261 | case ValueImage: value_ = new ImageValue;break; | 266 | case ValueImage: value_ = new ImageValue;break; |
262 | case ValueDate: value_ = new DateValue; break; | 267 | case ValueDate: value_ = new DateValue; break; |
263 | case ValueTextList: value_ = new TextListValue;break; | 268 | case ValueTextList: value_ = new TextListValue;break; |
264 | case ValueGeo: value_ = new GeoValue; break; | 269 | case ValueGeo: value_ = new GeoValue; break; |
265 | case ValueText: | 270 | case ValueText: |
266 | case ValueUnknown: | 271 | case ValueUnknown: |
267 | default: value_ = new TextValue; break; | 272 | default: value_ = new TextValue; break; |
268 | } | 273 | } |
269 | 274 | ||
270 | *value_ = valuePart; | 275 | *value_ = valuePart; |
271 | } | 276 | } |
272 | 277 | ||
273 | void | 278 | void |
274 | ContentLine::_assemble() | 279 | ContentLine::_assemble() |
275 | { | 280 | { |
276 | //strRep_.truncate(0); | 281 | //strRep_.truncate(0); |
277 | QString line; | 282 | QString line; |
278 | if (!group_.isEmpty()) | 283 | if (!group_.isEmpty()) |
279 | line = group_ + '.'; | 284 | line = group_ + '.'; |
280 | line += name_; | 285 | line += name_; |
281 | ParamListIterator it(paramList_); | 286 | ParamListIterator it(paramList_); |
282 | for (; it.current(); ++it) | 287 | for (; it.current(); ++it) |
283 | line += ";" + it.current()->asString(); | 288 | line += ";" + it.current()->asString(); |
284 | 289 | ||
285 | if (value_ != 0) | 290 | if (value_ != 0) |
286 | line += ":" + value_->asString(); | 291 | line += ":" + value_->asString(); |
287 | 292 | ||
293 | line = line.replace( QRegExp( "\r" ), "\\r" ); | ||
288 | line = line.replace( QRegExp( "\n" ), "\\n" ); | 294 | line = line.replace( QRegExp( "\n" ), "\\n" ); |
289 | 295 | ||
290 | // Fold lines longer than 72 chars | 296 | // Fold lines longer than 72 chars |
291 | const int maxLen = 72; | 297 | const int maxLen = 72; |
292 | uint cursor = 0; | 298 | uint cursor = 0; |
293 | QString cut; | 299 | QString cut; |
294 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 300 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
295 | cut += line.mid( cursor * maxLen, maxLen ); | 301 | cut += line.mid( cursor * maxLen, maxLen ); |
296 | cut += "\r\n "; | 302 | cut += "\r\n "; |
297 | ++cursor; | 303 | ++cursor; |
298 | } | 304 | } |
299 | cut += line.mid( cursor * maxLen ); | 305 | cut += line.mid( cursor * maxLen ); |
300 | strRep_ = cut.latin1(); | 306 | strRep_ = cut.latin1(); |
301 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | 307 | //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); |
302 | #if 0 | 308 | #if 0 |
303 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); | 309 | vDebug("Assemble (argl) - my name is \"" + name_ + "\""); |
304 | strRep_.truncate(0); | 310 | strRep_.truncate(0); |
305 | 311 | ||
306 | QCString line; | 312 | QCString line; |
307 | 313 | ||
308 | if (!group_.isEmpty()) | 314 | if (!group_.isEmpty()) |
309 | line += group_ + '.'; | 315 | line += group_ + '.'; |
310 | 316 | ||
311 | line += name_; | 317 | line += name_; |
312 | 318 | ||
313 | vDebug("Adding parameters"); | 319 | vDebug("Adding parameters"); |
314 | ParamListIterator it(paramList_); | 320 | ParamListIterator it(paramList_); |
315 | 321 | ||
316 | for (; it.current(); ++it) | 322 | for (; it.current(); ++it) |
317 | line += ";" + it.current()->asString(); | 323 | line += ";" + it.current()->asString(); |
318 | 324 | ||
319 | vDebug("Adding value"); | 325 | vDebug("Adding value"); |
320 | if (value_ != 0) | 326 | if (value_ != 0) |
321 | line += ":" + value_->asString(); | 327 | line += ":" + value_->asString(); |
322 | else | 328 | else |
323 | vDebug("No value"); | 329 | vDebug("No value"); |
324 | 330 | ||
325 | // Quote newlines | 331 | // Quote newlines |
326 | line = line.replace( QRegExp( "\n" ), "\\n" ); | 332 | line = line.replace( QRegExp( "\n" ), "\\n" ); |
327 | 333 | ||
328 | // Fold lines longer than 72 chars | 334 | // Fold lines longer than 72 chars |
329 | const int maxLen = 72; | 335 | const int maxLen = 72; |
330 | uint cursor = 0; | 336 | uint cursor = 0; |
331 | while( line.length() > ( cursor + 1 ) * maxLen ) { | 337 | while( line.length() > ( cursor + 1 ) * maxLen ) { |
332 | strRep_ += line.mid( cursor * maxLen, maxLen ); | 338 | strRep_ += line.mid( cursor * maxLen, maxLen ); |
333 | strRep_ += "\r\n "; | 339 | strRep_ += "\r\n "; |
334 | ++cursor; | 340 | ++cursor; |
335 | } | 341 | } |
336 | strRep_ += line.mid( cursor * maxLen ); | 342 | strRep_ += line.mid( cursor * maxLen ); |
337 | qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); | 343 | qDebug("ContentLine::_assemble()\n%s*****", strRep_.data()); |
338 | #endif | 344 | #endif |
339 | } | 345 | } |
340 | 346 | ||
341 | void | 347 | void |
342 | ContentLine::clear() | 348 | ContentLine::clear() |
343 | { | 349 | { |
344 | group_.truncate(0); | 350 | group_.truncate(0); |
345 | name_.truncate(0); | 351 | name_.truncate(0); |
346 | paramList_.clear(); | 352 | paramList_.clear(); |
347 | delete value_; | 353 | delete value_; |
348 | value_ = 0; | 354 | value_ = 0; |
349 | } | 355 | } |