summaryrefslogtreecommitdiffabout
path: root/kabc/vcard
authorzautrix <zautrix>2005-02-11 05:36:14 (UTC)
committer zautrix <zautrix>2005-02-11 05:36:14 (UTC)
commit0c1191e3253542b4858261241975c159ee7910c6 (patch) (unidiff)
treebe97b6665d130f0b72db82005726fbf7cc030abb /kabc/vcard
parent38c6a7b6ae1e98cba0fdf2d0fba59ad4b9060940 (diff)
downloadkdepimpi-0c1191e3253542b4858261241975c159ee7910c6.zip
kdepimpi-0c1191e3253542b4858261241975c159ee7910c6.tar.gz
kdepimpi-0c1191e3253542b4858261241975c159ee7910c6.tar.bz2
font fixes
Diffstat (limited to 'kabc/vcard') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/ContentLine.cpp8
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
@@ -116,98 +116,103 @@ ContentLine::operator = (ContentLine & x)
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 &
132ContentLine::operator = (const QCString & s) 132ContentLine::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
141ContentLine::operator == (ContentLine & x) 141ContentLine::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
153ContentLine::~ContentLine() 153ContentLine::~ContentLine()
154{ 154{
155 delete value_; 155 delete value_;
156 value_ = 0; 156 value_ = 0;
157} 157}
158 158
159 void 159 void
160ContentLine::_parse() 160ContentLine::_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
@@ -240,96 +245,97 @@ ContentLine::_parse()
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
274ContentLine::_assemble() 279ContentLine::_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 }