summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/sharpformat.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index 89eb72f..a53b3f8 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -308,130 +308,130 @@ class SharpParser : public QObject
308 QStringList::ConstIterator it; 308 QStringList::ConstIterator it;
309 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 309 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
310 QString cate = category( *it ); 310 QString cate = category( *it );
311 if ( oldCategories ) { 311 if ( oldCategories ) {
312 if ( ! oldCategories->contains( cate ) ) 312 if ( ! oldCategories->contains( cate ) )
313 oldCategories->append( cate ); 313 oldCategories->append( cate );
314 } 314 }
315 categories.append(cate ); 315 categories.append(cate );
316 } 316 }
317 return categories; 317 return categories;
318 } 318 }
319 319
320 private: 320 private:
321 Calendar *mCalendar; 321 Calendar *mCalendar;
322 QStringList * oldCategories; 322 QStringList * oldCategories;
323 static QString category( const QString &id ) 323 static QString category( const QString &id )
324 { 324 {
325 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 325 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
326 if ( it == mCategoriesMap.end() ) return id; 326 if ( it == mCategoriesMap.end() ) return id;
327 else return *it; 327 else return *it;
328 } 328 }
329 329
330 static void setCategory( const QString &id, const QString &name ) 330 static void setCategory( const QString &id, const QString &name )
331 { 331 {
332 mCategoriesMap.insert( id, name ); 332 mCategoriesMap.insert( id, name );
333 } 333 }
334 334
335 static QMap<QString,QString> mCategoriesMap; 335 static QMap<QString,QString> mCategoriesMap;
336}; 336};
337 337
338QMap<QString,QString> SharpParser::mCategoriesMap; 338QMap<QString,QString> SharpParser::mCategoriesMap;
339 339
340SharpFormat::SharpFormat() 340SharpFormat::SharpFormat()
341{ 341{
342 mCategories = 0; 342 mCategories = 0;
343} 343}
344 344
345SharpFormat::~SharpFormat() 345SharpFormat::~SharpFormat()
346{ 346{
347} 347}
348ulong SharpFormat::getCsum( const QStringList & attList) 348ulong SharpFormat::getCsum( const QStringList & attList)
349{ 349{
350 int max = attList.count() -1; 350 int max = attList.count() -1;
351 ulong cSum = 0; 351 ulong cSum = 0;
352 int j,k,i; 352 int j,k,i;
353 int add; 353 int add;
354 for ( i = 1; i < max ; ++i ) { 354 for ( i = 1; i < max ; ++i ) {
355 QString s = attList[i]; 355 QString s = attList[i];
356 if ( ! s.isEmpty() ){ 356 if ( ! s.isEmpty() ){
357 j = s.length(); 357 j = s.length();
358 for ( k = 0; k < j; ++k ) { 358 for ( k = 0; k < j; ++k ) {
359 int mul = k +1; 359 int mul = k +1;
360 add = s[k].unicode (); 360 add = s[k].unicode ();
361 if ( k < 16 ) 361 if ( k < 16 )
362 mul = mul * mul; 362 mul = mul * mul;
363 add = add * mul *i*i*i; 363 add = add * mul *i*i*i;
364 cSum += add; 364 cSum += add;
365 } 365 }
366 } 366 }
367 } 367 }
368 return cSum; 368 return cSum;
369 369
370} 370}
371#include <stdlib.h> 371#include <stdlib.h>
372//#define DEBUGMODE false 372#define DEBUGMODE false
373#define DEBUGMODE true 373//#define DEBUGMODE true
374bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 374bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
375{ 375{
376 376
377 377
378 bool debug = DEBUGMODE; 378 bool debug = DEBUGMODE;
379 QString text; 379 QString text;
380 QString codec = "utf8"; 380 QString codec = "utf8";
381 QLabel status ( i18n("Reading events ..."), 0 ); 381 QLabel status ( i18n("Reading events ..."), 0 );
382 382
383 int w = status.sizeHint().width()+20 ; 383 int w = status.sizeHint().width()+20 ;
384 if ( w < 200 ) w = 200; 384 if ( w < 200 ) w = 200;
385 int h = status.sizeHint().height()+20 ; 385 int h = status.sizeHint().height()+20 ;
386 int dw = QApplication::desktop()->width(); 386 int dw = QApplication::desktop()->width();
387 int dh = QApplication::desktop()->height(); 387 int dh = QApplication::desktop()->height();
388 status.setCaption(i18n("Reading DTM Data") ); 388 status.setCaption(i18n("Reading DTM Data") );
389 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 389 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
390 status.show(); 390 status.show();
391 status.raise(); 391 status.raise();
392 qApp->processEvents(); 392 qApp->processEvents();
393 QString fileName; 393 QString fileName;
394 if ( ! debug ) { 394 if ( ! debug ) {
395 fileName = "/tmp/kopitempout"; 395 fileName = "/tmp/kopitempout";
396 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 396 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
397 system ( command.latin1() ); 397 system ( command.latin1() );
398 } else { 398 } else {
399 fileName = "/tmp/events.txt"; 399 fileName = "/tmp/events.txt";
400 400
401 } 401 }
402 QFile file( fileName ); 402 QFile file( fileName );
403 if (!file.open( IO_ReadOnly ) ) { 403 if (!file.open( IO_ReadOnly ) ) {
404 return false; 404 return false;
405 405
406 } 406 }
407 QTextStream ts( &file ); 407 QTextStream ts( &file );
408 ts.setCodec( QTextCodec::codecForName("utf8") ); 408 ts.setCodec( QTextCodec::codecForName("utf8") );
409 text = ts.read(); 409 text = ts.read();
410 file.close(); 410 file.close();
411 status.setText( i18n("Processing events ...") ); 411 status.setText( i18n("Processing events ...") );
412 status.raise(); 412 status.raise();
413 qApp->processEvents(); 413 qApp->processEvents();
414 fromString2Cal( calendar, existngCal, text, "Event" ); 414 fromString2Cal( calendar, existngCal, text, "Event" );
415 status.setText( i18n("Reading todos ...") ); 415 status.setText( i18n("Reading todos ...") );
416 qApp->processEvents(); 416 qApp->processEvents();
417 if ( ! debug ) { 417 if ( ! debug ) {
418 fileName = "/tmp/kopitempout"; 418 fileName = "/tmp/kopitempout";
419 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 419 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
420 system ( command.latin1() ); 420 system ( command.latin1() );
421 } else { 421 } else {
422 fileName = "/tmp/todo.txt"; 422 fileName = "/tmp/todo.txt";
423 } 423 }
424 file.setName( fileName ); 424 file.setName( fileName );
425 if (!file.open( IO_ReadOnly ) ) { 425 if (!file.open( IO_ReadOnly ) ) {
426 return false; 426 return false;
427 427
428 } 428 }
429 ts.setDevice( &file ); 429 ts.setDevice( &file );
430 text = ts.read(); 430 text = ts.read();
431 file.close(); 431 file.close();
432 432
433 status.setText( i18n("Processing todos ...") ); 433 status.setText( i18n("Processing todos ...") );
434 status.raise(); 434 status.raise();
435 qApp->processEvents(); 435 qApp->processEvents();
436 fromString2Cal( calendar, existngCal, text, "Todo" ); 436 fromString2Cal( calendar, existngCal, text, "Todo" );
437 return true; 437 return true;