summaryrefslogtreecommitdiffabout
path: root/libkcal/phoneformat.cpp
Unidiff
Diffstat (limited to 'libkcal/phoneformat.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 900fc04..794e4b4 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -17,25 +17,26 @@
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <q3textstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <QDesktopWidget>
34 35
35#include <kdebug.h> 36#include <kdebug.h>
36#include <klocale.h> 37#include <klocale.h>
37#include <kglobal.h> 38#include <kglobal.h>
38#include <kmessagebox.h> 39#include <kmessagebox.h>
39#include <phoneaccess.h> 40#include <phoneaccess.h>
40 41
41#include "calendar.h" 42#include "calendar.h"
@@ -196,17 +197,17 @@ ulong PhoneFormat::getCsumEvent( Event* event )
196 break; 197 break;
197 case Recurrence::rMonthlyPos:// 2 198 case Recurrence::rMonthlyPos:// 2
198 list.append( "2" ); 199 list.append( "2" );
199 list.append( QString::number( rec->frequency()) );//12 200 list.append( QString::number( rec->frequency()) );//12
200 201
201 writeEndDate = true; 202 writeEndDate = true;
202 { 203 {
203 int count = 1; 204 int count = 1;
204 QPtrList<Recurrence::rMonthPos> rmp; 205 Q3PtrList<Recurrence::rMonthPos> rmp;
205 rmp = rec->monthPositions(); 206 rmp = rec->monthPositions();
206 if ( rmp.first()->negative ) 207 if ( rmp.first()->negative )
207 count = 5 - rmp.first()->rPos - 1; 208 count = 5 - rmp.first()->rPos - 1;
208 else 209 else
209 count = rmp.first()->rPos - 1; 210 count = rmp.first()->rPos - 1;
210 list.append( QString::number( count ) ); 211 list.append( QString::number( count ) );
211 212
212 } 213 }
@@ -236,17 +237,17 @@ ulong PhoneFormat::getCsumEvent( Event* event )
236 list.append( "0" ); 237 list.append( "0" );
237 list.append( "20991231T000000" ); 238 list.append( "20991231T000000" );
238 break; 239 break;
239 } 240 }
240 if ( writeEndDate ) { 241 if ( writeEndDate ) {
241 242
242 if ( rec->endDate().isValid() ) { // 15 + 16 243 if ( rec->endDate().isValid() ) { // 15 + 16
243 list.append( "1" ); 244 list.append( "1" );
244 list.append( PhoneParser::dtToString( rec->endDate()) ); 245 list.append( PhoneParser::dtToString( (QDateTime)rec->endDate()) );
245 } else { 246 } else {
246 list.append( "0" ); 247 list.append( "0" );
247 list.append( "20991231T000000" ); 248 list.append( "20991231T000000" );
248 } 249 }
249 250
250 } 251 }
251 attList << list.join(""); 252 attList << list.join("");
252 attList << event->categoriesStr(); 253 attList << event->categoriesStr();
@@ -300,17 +301,17 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
300 return false; 301 return false;
301 } 302 }
302 VCalFormat vfload; 303 VCalFormat vfload;
303 vfload.setLocalTime ( true ); 304 vfload.setLocalTime ( true );
304 qDebug("loading file ..."); 305 qDebug("loading file ...");
305 306
306 if ( ! vfload.load( calendar, fileName ) ) 307 if ( ! vfload.load( calendar, fileName ) )
307 return false; 308 return false;
308 QPtrList<Event> er = calendar->rawEvents(); 309 Q3PtrList<Event> er = calendar->rawEvents();
309 Event* ev = er.first(); 310 Event* ev = er.first();
310 qDebug("reading events... "); 311 qDebug("reading events... ");
311 while ( ev ) { 312 while ( ev ) {
312 QStringList cat = ev->categories(); 313 QStringList cat = ev->categories();
313 if ( cat.contains( "MeetingDEF" )) { 314 if ( cat.contains( "MeetingDEF" )) {
314 ev->setCategories( QStringList() ); 315 ev->setCategories( QStringList() );
315 } else 316 } else
316 if ( cat.contains( "Birthday" )) { 317 if ( cat.contains( "Birthday" )) {
@@ -335,17 +336,17 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
335 event = ev; 336 event = ev;
336 event->setCsum( mProfileName, QString::number( cSum )); 337 event->setCsum( mProfileName, QString::number( cSum ));
337 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 338 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
338 event->setID( mProfileName,QString::number( id ) ); 339 event->setID( mProfileName,QString::number( id ) );
339 ev = er.next(); 340 ev = er.next();
340 } 341 }
341 { 342 {
342 qDebug("reading todos... "); 343 qDebug("reading todos... ");
343 QPtrList<Todo> tr = calendar->rawTodos(); 344 Q3PtrList<Todo> tr = calendar->rawTodos();
344 Todo* ev = tr.first(); 345 Todo* ev = tr.first();
345 while ( ev ) { 346 while ( ev ) {
346 347
347 QStringList cat = ev->categories(); 348 QStringList cat = ev->categories();
348 if ( cat.contains( "MeetingDEF" )) { 349 if ( cat.contains( "MeetingDEF" )) {
349 ev->setCategories( QStringList() ); 350 ev->setCategories( QStringList() );
350 } 351 }
351 int id = ev->pilotId(); 352 int id = ev->pilotId();
@@ -460,17 +461,17 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
460 if( to->priority() == 2 && from->priority() == 1 ) 461 if( to->priority() == 2 && from->priority() == 1 )
461 ; //skip 462 ; //skip
462 else if (to->priority() == 4 && from->priority() == 5 ) 463 else if (to->priority() == 4 && from->priority() == 5 )
463 ; 464 ;
464 else 465 else
465 to->setPriority(from->priority()); 466 to->setPriority(from->priority());
466 467
467} 468}
468#include <qcstring.h> 469#include <q3cstring.h>
469 470
470void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) 471void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum)
471{ 472{
472 inc->setID( mProfileName, id ); 473 inc->setID( mProfileName, id );
473 inc->setCsum( mProfileName, csum); 474 inc->setCsum( mProfileName, csum);
474 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 475 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
475 476
476} 477}
@@ -492,28 +493,28 @@ bool PhoneFormat::writeToPhone( Calendar * calendar)
492 calendar->setTimeZoneId( id ); 493 calendar->setTimeZoneId( id );
493 return PhoneAccess::writeToPhone( fileName ); 494 return PhoneAccess::writeToPhone( fileName );
494} 495}
495bool PhoneFormat::save( Calendar *calendar) 496bool PhoneFormat::save( Calendar *calendar)
496{ 497{
497 498
498 499
499 // 1 remove events which should be deleted 500 // 1 remove events which should be deleted
500 QPtrList<Event> er = calendar->rawEvents(); 501 Q3PtrList<Event> er = calendar->rawEvents();
501 Event* ev = er.first(); 502 Event* ev = er.first();
502 while ( ev ) { 503 while ( ev ) {
503 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 504 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
504 calendar->deleteEvent( ev ); 505 calendar->deleteEvent( ev );
505 } else { 506 } else {
506 507
507 } 508 }
508 ev = er.next(); 509 ev = er.next();
509 } 510 }
510 // 2 remove todos which should be deleted 511 // 2 remove todos which should be deleted
511 QPtrList<Todo> tl = calendar->rawTodos(); 512 Q3PtrList<Todo> tl = calendar->rawTodos();
512 Todo* to = tl.first(); 513 Todo* to = tl.first();
513 while ( to ) { 514 while ( to ) {
514 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 515 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
515 calendar->deleteTodo( to ); 516 calendar->deleteTodo( to );
516 } else { 517 } else {
517 if ( to->isCompleted()) { 518 if ( to->isCompleted()) {
518 calendar->deleteTodo( to ); 519 calendar->deleteTodo( to );
519 } 520 }
@@ -547,17 +548,17 @@ bool PhoneFormat::save( Calendar *calendar)
547 return false; 548 return false;
548 } 549 }
549 // 6 compare data 550 // 6 compare data
550 551
551//algo 6 compare event 552//algo 6 compare event
552 er = calendar->rawEvents(); 553 er = calendar->rawEvents();
553 ev = er.first(); 554 ev = er.first();
554 message = i18n(" Comparing event # "); 555 message = i18n(" Comparing event # ");
555 QPtrList<Event> er1 = calendarTemp->rawEvents(); 556 Q3PtrList<Event> er1 = calendarTemp->rawEvents();
556 Event* ev1; 557 Event* ev1;
557 int procCount = 0; 558 int procCount = 0;
558 while ( ev ) { 559 while ( ev ) {
559 //qDebug("event new ID %s",ev->summary().latin1()); 560 //qDebug("event new ID %s",ev->summary().latin1());
560 status.setText ( message + QString::number ( ++procCount ) ); 561 status.setText ( message + QString::number ( ++procCount ) );
561 qApp->processEvents(); 562 qApp->processEvents();
562 ev1 = er1.first(); 563 ev1 = er1.first();
563 while ( ev1 ) { 564 while ( ev1 ) {
@@ -575,17 +576,17 @@ bool PhoneFormat::save( Calendar *calendar)
575 576
576 577
577 ev = er.next(); 578 ev = er.next();
578 } 579 }
579 //algo 6 compare todo 580 //algo 6 compare todo
580 tl = calendar->rawTodos(); 581 tl = calendar->rawTodos();
581 to = tl.first(); 582 to = tl.first();
582 procCount = 0; 583 procCount = 0;
583 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 584 Q3PtrList<Todo> tl1 = calendarTemp->rawTodos();
584 Todo* to1 ; 585 Todo* to1 ;
585 message = i18n(" Comparing todo # "); 586 message = i18n(" Comparing todo # ");
586 while ( to ) { 587 while ( to ) {
587 status.setText ( message + QString::number ( ++procCount ) ); 588 status.setText ( message + QString::number ( ++procCount ) );
588 qApp->processEvents(); 589 qApp->processEvents();
589 Todo* to1 = tl1.first(); 590 Todo* to1 = tl1.first();
590 while ( to1 ) { 591 while ( to1 ) {
591 if ( to->contains( to1 ) ) { 592 if ( to->contains( to1 ) ) {