-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 20 | ||||
-rw-r--r-- | kabc/addressee.cpp | 1 | ||||
-rw-r--r-- | kabc/kabc.pro | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | libkcal/event.cpp | 46 | ||||
-rw-r--r-- | libkcal/event.h | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 104 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 | ||||
-rw-r--r-- | libkcal/todo.cpp | 58 | ||||
-rw-r--r-- | libkcal/todo.h | 1 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 141 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 69 | ||||
-rw-r--r-- | microkde/microkde.pro | 2 | ||||
-rw-r--r-- | microkde/ofileselector_p.cpp | 7 |
14 files changed, 305 insertions, 154 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0375fee..7310755 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c @@ -108,13 +108,13 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); break; case GSM_CAL_CALL: *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); break; case GSM_CAL_BIRTHDAY: - *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); + *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); break; case GSM_CAL_MEETING: default: *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); break; } @@ -147,31 +147,31 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note } else { SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); } } /* Birthday is known to be recurranced */ - if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { + if (Recurrance != -1 ) { switch(note->Entries[Recurrance].Number/24) { case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; - case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; + case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1 #0%c%c",13,10); break; } } } else if (Version == Siemens_VCalendar) { *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); switch (note->Type) { case GSM_CAL_MEETING: *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); break; case GSM_CAL_CALL: *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); break; case GSM_CAL_BIRTHDAY: - *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); + *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); break; case GSM_CAL_MEMO: default: *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); break; } @@ -185,13 +185,13 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note if (Recurrance != -1) { switch(note->Entries[Recurrance].Number/24) { case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10); break; case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10); break; case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10); break; - case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10); break; + case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1%c%c",13,10); break; } } if (note->Type == GSM_CAL_CALL) { buffer[0] = 0; buffer[1] = 0; @@ -217,13 +217,13 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); break; case GSM_CAL_VACATION: *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); break; case GSM_CAL_BIRTHDAY: - *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); + *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); break; case GSM_CAL_MEMO: default: *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); break; } @@ -387,14 +387,14 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; - if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; + if (strstr(Line,"CATEGORIES:Birthday")) Calendar->Type = GSM_CAL_BIRTHDAY; if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; if (strstr(Line,"RRULE:D1")) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 1*24; Calendar->EntriesNum++; @@ -417,12 +417,18 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda if (strstr(Line,"RRULE:YD1")) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; Calendar->Entries[Calendar->EntriesNum].Number = 365*24; Calendar->EntriesNum++; } // LR + if (strstr(Line,"RRULE:YM1")) { + Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; + Calendar->Entries[Calendar->EntriesNum].Number = 365*24; + Calendar->EntriesNum++; + } + // LR if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); Calendar->EntriesNum++; } if (ReadVCALText(Line, "DESCRIPTION", Buff)) { diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2564894..40877ef 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -307,12 +307,13 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) bool found = false; PhoneNumber::List::Iterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { if ( ( *phoneItAD ).contains( (*it) ) ) { found = true; (*it).setType( ( *phoneItAD ).type() ); + (*it).setNumber( ( *phoneItAD ).number() ); break; } } if ( isSubSet && ! found ) mData->phoneNumbers.append( *phoneItAD ); } diff --git a/kabc/kabc.pro b/kabc/kabc.pro index d690acc..17ebff8 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro @@ -45,13 +45,12 @@ distributionlisteditor.h \ vcardformatplugin.h \ formats/vcardformatplugin2.h \ picture.h \ secrecy.h \ sound.h \ addressbook.h \ - syncprefwidget.h \ timezone.h \ tmpaddressbook.h \ addressee.h \ addresseedialog.h \ vcardconverter.h \ vcard21parser.h \ @@ -157,13 +156,12 @@ formatfactory.cpp \ address.cpp \ phonenumber.cpp \ picture.cpp \ secrecy.cpp \ sound.cpp \ addressbook.cpp \ - syncprefwidget.cpp \ timezone.cpp \ tmpaddressbook.cpp \ addressee.cpp \ addresseelist.cpp \ addresseedialog.cpp \ vcardconverter.cpp \ diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3e0a27d..e4a11f5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1127,14 +1127,16 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } } } inL = el.next(); } int delFut = 0; + int remRem = 0; if ( mSyncManager->mWriteBackInFuture ) { er = remote->rawIncidences(); + remRem = er.count(); inR = er.first(); QDateTime dt; QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); while ( inR ) { if ( inR->type() == "Todo" ) { @@ -1172,13 +1174,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->addEvent( eventRSync ); QString mes; mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); QString delmess; if ( delFut ) { - delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); + delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); mes += delmess; } if ( mSyncManager->mShowSyncSummary ) { KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); } qDebug( mes ); diff --git a/libkcal/event.cpp b/libkcal/event.cpp index dfa265b..7256f05 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -53,12 +53,58 @@ bool KCal::operator==( const Event& e1, const Event& e2 ) e1.dtEnd() == e2.dtEnd() && e1.hasEndDate() == e2.hasEndDate() && e1.transparency() == e2.transparency(); } +bool Event::contains ( Event* from ) +{ + + if ( !from->summary().isEmpty() ) + if ( !summary().startsWith( from->summary() )) + return false; + if ( from->dtStart().isValid() ) + if (dtStart() != from->dtStart() ) + return false; + if ( from->dtEnd().isValid() ) + if ( dtEnd() != from->dtEnd() ) + return false; + if ( !from->location().isEmpty() ) + if ( !location().startsWith( from->location() ) ) + return false; + if ( !from->description().isEmpty() ) + if ( !description().startsWith( from->description() )) + return false; + if ( from->alarms().count() ) { + Alarm *a = from->alarms().first(); + if ( a->enabled() ){ + if ( !alarms().count() ) + return false; + Alarm *b = alarms().first(); + if( ! b->enabled() ) + return false; + if ( ! (a->offset() == b->offset() )) + return false; + } + } + QStringList cat = categories(); + QStringList catFrom = from->categories(); + QString nCat; + int iii; + for ( iii = 0; iii < catFrom.count();++iii ) { + nCat = catFrom[iii]; + if ( !nCat.isEmpty() ) + if ( !cat.contains( nCat )) { + return false; + } + } + if ( from->doesRecur() ) + if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) + return false; + return true; +} void Event::setDtEnd(const QDateTime &dtEnd) { if (mReadOnly) return; mDtEnd = getEvenTime( dtEnd ); diff --git a/libkcal/event.h b/libkcal/event.h index 2a8bd95..3bc8adc 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -68,12 +68,14 @@ class Event : public Incidence void setTransparency(Transparency transparency); /** get the event's time transparency level. */ Transparency transparency() const; void setDuration(int seconds); + bool contains ( Event*); + private: bool accept(Visitor &v) { return v.visit(this); } QDateTime mDtEnd; bool mHasEndDate; Transparency mTransparency; diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 281434e..101db57 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -309,26 +309,33 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) Event* ev = er.first(); qDebug("reading events... "); while ( ev ) { QStringList cat = ev->categories(); if ( cat.contains( "MeetingDEF" )) { ev->setCategories( QStringList() ); + } else + if ( cat.contains( "Birthday" )) { + ev->setFloats( true ); + QDate da = ev->dtStart().date(); + ev->setDtStart( QDateTime( da) ); + ev->setDtEnd( QDateTime( da.addDays(1)) ); + } + uint cSum; + cSum = PhoneFormat::getCsumEvent( ev ); int id = ev->pilotId(); Event *event; event = existingCal->event( mProfileName ,QString::number( id ) ); if ( event ) { event = (Event*)event->clone(); copyEvent( event, ev ); calendar->deleteEvent( ev ); calendar->addEvent( event); } else event = ev; - uint cSum; - cSum = PhoneFormat::getCsumEvent( event ); event->setCsum( mProfileName, QString::number( cSum )); event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setID( mProfileName,QString::number( id ) ); ev = er.next(); } { @@ -339,26 +346,26 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) QStringList cat = ev->categories(); if ( cat.contains( "MeetingDEF" )) { ev->setCategories( QStringList() ); } int id = ev->pilotId(); + uint cSum; + cSum = PhoneFormat::getCsumTodo( ev ); Todo *event; event = existingCal->todo( mProfileName ,QString::number( id ) ); if ( event ) { //qDebug("copy todo %s ", event->summary().latin1()); event = (Todo*)event->clone(); copyTodo( event, ev ); calendar->deleteTodo( ev ); calendar->addTodo( event); } else event = ev; - uint cSum; - cSum = PhoneFormat::getCsumTodo( event ); event->setCsum( mProfileName, QString::number( cSum )); event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setID( mProfileName,QString::number( id ) ); ev = tr.next(); } } @@ -379,17 +386,13 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) if ( from->alarms().count() ) { to->clearAlarms(); Alarm *a = from->alarms().first(); Alarm *b = to->newAlarm( ); b->setEnabled( a->enabled() ); - if ( a->hasStartOffset() ) { - b->setStartOffset( a->startOffset() ); - } - if ( a->hasTime() ) - b->setTime( a->time() ); + b->setStartOffset(Duration( a->offset() ) ); } QStringList cat = to->categories(); QStringList catFrom = from->categories(); QString nCat; int iii; @@ -398,39 +401,42 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) if ( !nCat.isEmpty() ) if ( !cat.contains( nCat )) { cat << nCat; } } to->setCategories( cat ); - Recurrence * r = new Recurrence( *from->recurrence(),to); - to->setRecurrence( r ) ; + if ( from->doesRecur() ) { + Recurrence * r = new Recurrence( *from->recurrence(),to); + to->setRecurrence( r ) ; + } } void PhoneFormat::copyTodo( Todo* to, Todo* from ) { - if ( from->dtStart().isValid() ) + if ( from->hasStartDate() ) { + to->setHasStartDate( true ); to->setDtStart( from->dtStart() ); - if ( from->dtDue().isValid() ) + } + if ( from->hasDueDate() ){ + to->setHasDueDate( true ); to->setDtDue( from->dtDue() ); + } if ( !from->location().isEmpty() ) to->setLocation( from->location() ); if ( !from->description().isEmpty() ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); if ( from->alarms().count() ) { to->clearAlarms(); Alarm *a = from->alarms().first(); Alarm *b = to->newAlarm( ); b->setEnabled( a->enabled() ); - if ( a->hasStartOffset() ) - b->setStartOffset( a->startOffset() ); - if ( a->hasTime() ) - b->setTime( a->time() ); + b->setStartOffset(Duration( a->offset() ) ); } QStringList cat = to->categories(); QStringList catFrom = from->categories(); QString nCat; int iii; @@ -458,32 +464,26 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) else to->setPriority(from->priority()); } #include <qcstring.h> -void PhoneFormat::afterSave( Incidence* inc) +void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) { - uint csum; - inc->removeID( mProfileName ); - if ( inc->type() == "Event") - csum = PhoneFormat::getCsumEvent( (Event*) inc ); - else - csum = PhoneFormat::getCsumTodo( (Todo*) inc ); - inc->setCsum( mProfileName, QString::number( csum )); - + inc->setID( mProfileName, id ); + inc->setCsum( mProfileName, csum); inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); } bool PhoneFormat::writeToPhone( Calendar * calendar) { #ifdef _WIN32_ - QString fileName = locateLocal("tmp", "tempfile.vcs"); + QString fileName = locateLocal("tmp", "phonefile.vcs"); #else - QString fileName = "/tmp/kdepimtemp.vcs"; + QString fileName = "/tmp/phonefile.vcs"; #endif VCalFormat vfsave; vfsave.setLocalTime ( true ); QString id = calendar->timeZoneId(); calendar->setLocalTime(); @@ -491,24 +491,13 @@ bool PhoneFormat::writeToPhone( Calendar * calendar) return false; calendar->setTimeZoneId( id ); return PhoneAccess::writeToPhone( fileName ); } bool PhoneFormat::save( Calendar *calendar) { - QLabel status ( i18n(" Opening device ..."), 0 ); - int w = status.sizeHint().width()+20 ; - if ( w < 200 ) w = 230; - int h = status.sizeHint().height()+20 ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - status.setCaption(i18n("Writing to phone...") ); - status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - status.show(); - status.raise(); - qApp->processEvents(); - QString message; + // 1 remove events which should be deleted QPtrList<Event> er = calendar->rawEvents(); Event* ev = er.first(); while ( ev ) { if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { @@ -531,13 +520,24 @@ bool PhoneFormat::save( Calendar *calendar) } to = tl.next(); } // 3 save file if ( !writeToPhone( calendar ) ) return false; - + QLabel status ( i18n(" Opening device ..."), 0 ); + int w = status.sizeHint().width()+20 ; + if ( w < 200 ) w = 230; + int h = status.sizeHint().height()+20 ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + status.setCaption(i18n("Writing to phone...") ); + status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + QString message; + status.show(); + status.raise(); + qApp->processEvents(); // 5 reread data message = i18n(" Rereading all data ... "); status.setText ( message ); qApp->processEvents(); CalendarLocal* calendarTemp = new CalendarLocal(); calendarTemp->setTimeZoneId( calendar->timeZoneId()); @@ -556,25 +556,17 @@ bool PhoneFormat::save( Calendar *calendar) Event* ev1; int procCount = 0; while ( ev ) { //qDebug("event new ID %s",ev->summary().latin1()); status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); - uint csum; - csum = PhoneFormat::getCsumEvent( ev ); - QString cSum = QString::number( csum ); - //ev->setCsum( mProfileName, cSum ); - //qDebug("Event cSum %s ", cSum.latin1()); ev1 = er1.first(); while ( ev1 ) { - if ( ev1->getCsum( mProfileName ) == cSum ) { + if ( ev->contains( ev1 ) ) { + afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); er1.remove( ev1 ); - afterSave( ev ); - ev->setID(mProfileName, ev1->getID(mProfileName) ); - //qDebug("Event found on phone for %s ", ev->summary().latin1()); - break; } ev1 = er1.next(); } if ( ! ev1 ) { // ev->removeID(mProfileName); @@ -591,23 +583,17 @@ bool PhoneFormat::save( Calendar *calendar) QPtrList<Todo> tl1 = calendarTemp->rawTodos(); Todo* to1 ; message = i18n(" Comparing todo # "); while ( to ) { status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); - uint csum; - csum = PhoneFormat::getCsumTodo( to ); - QString cSum = QString::number( csum ); - //to->setCsum( mProfileName, cSum ); - //qDebug("Todo cSum %s ", cSum.latin1()); Todo* to1 = tl1.first(); while ( to1 ) { - if ( to1->getCsum( mProfileName ) == cSum ) { + if ( to->contains( to1 ) ) { + afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); tl1.remove( to1 ); - afterSave( to ); - to->setID(mProfileName, to1->getID(mProfileName) ); break; } to1 = tl1.next(); } if ( ! to1 ) { //to->removeID(mProfileName); diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 001fd81..d11f68b 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h @@ -51,12 +51,12 @@ class PhoneFormat : public QObject { static bool writeToPhone( Calendar * ); private: void copyEvent( Event* to, Event* from ); void copyTodo( Todo* to, Todo* from ); //int initDevice(GSM_StateMachine *s); QString mProfileName; - void afterSave( Incidence* ); + void afterSave( Incidence* ,const QString&,const QString&); }; } #endif diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 0c1e3e4..3d2de61 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -53,13 +53,71 @@ Todo::~Todo() Incidence *Todo::clone() { return new Todo(*this); } +bool Todo::contains ( Todo* from ) +{ + if ( !from->summary().isEmpty() ) + if ( !summary().startsWith( from->summary() )) + return false; + if ( from->hasStartDate() ) { + if ( !hasStartDate() ) + return false; + if ( from->dtStart() != dtStart()) + return false; + } + if ( from->hasDueDate() ){ + if ( !hasDueDate() ) + return false; + if ( from->dtDue() != dtDue()) + return false; + } + if ( !from->location().isEmpty() ) + if ( !location().startsWith( from->location() ) ) + return false; + if ( !from->description().isEmpty() ) + if ( !description().startsWith( from->description() )) + return false; + if ( from->alarms().count() ) { + Alarm *a = from->alarms().first(); + if ( a->enabled() ){ + if ( !alarms().count() ) + return false; + Alarm *b = alarms().first(); + if( ! b->enabled() ) + return false; + if ( ! (a->offset() == b->offset() )) + return false; + } + } + + QStringList cat = categories(); + QStringList catFrom = from->categories(); + QString nCat; + int iii; + for ( iii = 0; iii < catFrom.count();++iii ) { + nCat = catFrom[iii]; + if ( !nCat.isEmpty() ) + if ( !cat.contains( nCat )) { + return false; + } + } + if ( from->isCompleted() ) { + if ( !isCompleted() ) + return false; + } + if( priority() != from->priority() ) + return false; + + + return true; + +} bool KCal::operator==( const Todo& t1, const Todo& t2 ) { bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); if ( ! ret ) return false; diff --git a/libkcal/todo.h b/libkcal/todo.h index 9aa92f8..0f22c59 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -96,12 +96,13 @@ class Todo : public Incidence QString completedStr() const; /** set date and time of completion */ void setCompleted(const QDateTime &completed); /** Return true, if todo has a date associated with completion */ bool hasCompletedDate() const; + bool contains ( Todo*); private: bool accept(Visitor &v) { return v.visit(this); } QDateTime mDtDue; // due date of todo diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index a6ae1bc..df93209 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp @@ -59,13 +59,14 @@ void VCalFormat::setLocalTime ( bool b ) useLocalTime = b; } bool VCalFormat::load(Calendar *calendar, const QString &fileName) { mCalendar = calendar; clearException(); - useLocalTime = mCalendar->isLocalTime(); + if ( ! useLocalTime ) + useLocalTime = mCalendar->isLocalTime(); VObject *vcal = 0; // this is not necessarily only 1 vcal. Could be many vcals, or include // a vcard... vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); @@ -87,13 +88,14 @@ bool VCalFormat::load(Calendar *calendar, const QString &fileName) } bool VCalFormat::save(Calendar *calendar, const QString &fileName) { mCalendar = calendar; - useLocalTime = mCalendar->isLocalTime(); + if ( ! useLocalTime ) + useLocalTime = mCalendar->isLocalTime(); QString tmpStr; VObject *vcal, *vo; vcal = newVObject(VCCalProp); @@ -1169,78 +1171,82 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); } } /*********************** YEARLY-BY-MONTH *******************************/ else if (tmpStr.left(2) == "YM") { - int index = tmpStr.find(' '); - int last = tmpStr.findRev(' ') + 1; - int rFreq = tmpStr.mid(2, (index-1)).toInt(); - index += 1; - short tmpMonth; - if( index == last ) { - // e.g. YM1 #0 - tmpMonth = anEvent->dtStart().date().month(); - anEvent->recurrence()->addYearlyNum(tmpMonth); - } - else { - // e.g. YM1 3 #0 - while (index < last) { - int index2 = tmpStr.find(' ', index); - tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); - index = index2+1; - anEvent->recurrence()->addYearlyNum(tmpMonth); - } // while != # - } - index = last; if (tmpStr.mid(index,1) == "#") index++; - if (tmpStr.find('T', index) != -1) { - QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); - } else { - int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); - if (rDuration == 0) - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); - else - anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); - } + // we have to set this such that recurrence accepts addYearlyNum(tmpDay); + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); + int index = tmpStr.find(' '); + int last = tmpStr.findRev(' ') + 1; + int rFreq = tmpStr.mid(2, (index-1)).toInt(); + index += 1; + short tmpMonth; + if( index == last ) { + // e.g. YM1 #0 + tmpMonth = anEvent->dtStart().date().month(); + anEvent->recurrence()->addYearlyNum(tmpMonth); + } + else { + // e.g. YM1 3 #0 + while (index < last) { + int index2 = tmpStr.find(' ', index); + tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); + index = index2+1; + anEvent->recurrence()->addYearlyNum(tmpMonth); + } // while != # + } + index = last; if (tmpStr.mid(index,1) == "#") index++; + if (tmpStr.find('T', index) != -1) { + QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); + } else { + int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); + if (rDuration == 0) + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); + else + anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); + } } /*********************** YEARLY-BY-DAY *********************************/ else if (tmpStr.left(2) == "YD") { - int index = tmpStr.find(' '); - int last = tmpStr.findRev(' ') + 1; - int rFreq = tmpStr.mid(2, (index-1)).toInt(); - index += 1; - short tmpDay; - if( index == last ) { - // e.g. YD1 #0 - tmpDay = anEvent->dtStart().date().dayOfYear(); - anEvent->recurrence()->addYearlyNum(tmpDay); - } - else { - // e.g. YD1 123 #0 - while (index < last) { - int index2 = tmpStr.find(' ', index); - tmpDay = tmpStr.mid(index, (index2-index)).toShort(); - index = index2+1; - anEvent->recurrence()->addYearlyNum(tmpDay); - } // while != # - } - index = last; if (tmpStr.mid(index,1) == "#") index++; - if (tmpStr.find('T', index) != -1) { - QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); - } else { - int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); - if (rDuration == 0) - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); - else - anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); - } + // we have to set this such that recurrence accepts addYearlyNum(tmpDay); + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); + int index = tmpStr.find(' '); + int last = tmpStr.findRev(' ') + 1; + int rFreq = tmpStr.mid(2, (index-1)).toInt(); + index += 1; + short tmpDay; + if( index == last ) { + // e.g. YD1 #0 + tmpDay = anEvent->dtStart().date().dayOfYear(); + anEvent->recurrence()->addYearlyNum(tmpDay); + } + else { + // e.g. YD1 123 #0 + while (index < last) { + int index2 = tmpStr.find(' ', index); + tmpDay = tmpStr.mid(index, (index2-index)).toShort(); + index = index2+1; + anEvent->recurrence()->addYearlyNum(tmpDay); + } // while != # + } + index = last; if (tmpStr.mid(index,1) == "#") index++; + if (tmpStr.find('T', index) != -1) { + QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); + } else { + int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); + if (rDuration == 0) + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); + else + anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); + } } else { - kdDebug(5800) << "we don't understand this type of recurrence!" << endl; + kdDebug(5800) << "we don't understand this type of recurrence!" << endl; } // if } // repeats // recurrence exceptions if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { @@ -1533,18 +1539,19 @@ void VCalFormat::populate(VObject *vcal) << "We only support " << _VCAL_VERSION << endl; deleteStr(s); } // set the time zone if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { - char *s = fakeCString(vObjectUStringZValue(curVO)); - mCalendar->setTimeZone(s); - deleteStr(s); + if ( vObjectUStringZValue(curVO) != 0 ) { + char *s = fakeCString(vObjectUStringZValue(curVO)); + mCalendar->setTimeZone(s); + deleteStr(s); + } } - // Store all events with a relatedTo property in a list for post-processing mEventsRelate.clear(); mTodosRelate.clear(); initPropIterator(&i, vcal); diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 8298aa6..e24ad9e 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp @@ -22,12 +22,13 @@ #include <qstring.h> #include <qapplication.h> #include <qptrlist.h> #include <qregexp.h> #include <qfile.h> +#include <qlabel.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qdir.h> #include <kmessagebox.h> #include <stdlib.h> #include "phoneaccess.h" @@ -136,19 +137,39 @@ bool PhoneAccess::writeToPhone( QString fileName) #else QString command ="./kammu --restore " + fileName ; #endif #else QString command ="kammu --restore " + fileName ; #endif - int ret; - while ( (ret = system ( command.latin1())) != 0 ) { - qDebug("Error S::command returned %d.", ret); - int retval = KMessageBox::warningContinueCancel(0, - i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); - if ( retval != KMessageBox::Continue ) - return false; + int ret = 1; + while ( ret != 0 ) { + QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); + int w = 235; + int h = status->sizeHint().height()+20 ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + if ( dw > 310 ) + w = 310; + status->setCaption(i18n("Writing to phone...") ); + status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + status->show(); + status->raise(); + status->update(); + qApp->processEvents(); + status->update(); + qApp->processEvents(); + ret = system ( command.latin1()); + delete status; + qApp->processEvents(); + if ( ret ) { + qDebug("Error S::command returned %d.", ret); + int retval = KMessageBox::warningContinueCancel(0, + i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); + if ( retval != KMessageBox::Continue ) + return false; + } } return true; } bool PhoneAccess::readFromPhone( QString fileName) { @@ -159,15 +180,37 @@ bool PhoneAccess::readFromPhone( QString fileName) QString command ="./kammu --backup " + fileName + " -yes" ; #endif #else QString command ="kammu --backup " + fileName + " -yes" ; #endif int ret; - while ( (ret = system ( command.latin1())) != 0 ) { - qDebug("Error reading from phone:Command returned %d", ret); - int retval = KMessageBox::warningContinueCancel(0, - i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); - if ( retval != KMessageBox::Continue ) - return false; + while ( ret != 0 ) { + QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); + int w = 235; + int h = status->sizeHint().height()+20 ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + if ( dw > 310 ) + w = 310; + status->setCaption(i18n("Reading from phone...") ); + status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + status->show(); + status->raise(); + status->update(); + qApp->processEvents(); + status->update(); + qApp->processEvents(); + ret = system ( command.latin1() ); + delete status; + qApp->processEvents(); + if ( ret ) { + qDebug("Error reading from phone:Command returned %d", ret); + int retval = KMessageBox::warningContinueCancel(0, + i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); + if ( retval != KMessageBox::Continue ) + return false; + + } } + qApp->processEvents(); return true; } diff --git a/microkde/microkde.pro b/microkde/microkde.pro index 71d662b..21da158 100644 --- a/microkde/microkde.pro +++ b/microkde/microkde.pro @@ -78,13 +78,12 @@ KDGanttMinimizeSplitter.h \ kresources/manager.h \ kresources/selectdialog.h \ kresources/configpage.h \ kresources/configwidget.h \ kresources/configdialog.h \ kresources/kcmkresources.h \ - kresources/syncwidget.h \ kdecore/kmdcodec.h \ kdecore/kconfigbase.h \ kdecore/klocale.h \ kdecore/kcatalogue.h \ kdecore/ksharedptr.h \ kdecore/kshell.h \ @@ -157,13 +156,12 @@ KDGanttMinimizeSplitter.cpp \ kresources/configwidget.cpp \ kresources/factory.cpp \ kresources/kcmkresources.cpp \ kresources/managerimpl.cpp \ kresources/resource.cpp \ kresources/selectdialog.cpp \ - kresources/syncwidget.cpp \ kutils/kcmultidialog.cpp \ kdeui/kaction.cpp \ kdeui/kactionclasses.cpp \ kdeui/kactioncollection.cpp \ kdeui/kmainwindow.cpp \ kdeui/ktoolbar.cpp \ diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index cf6074d..fd5f965 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp @@ -17,12 +17,14 @@ #undef private #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include <qpe/storage.h> +#include <kglobal.h> +#include <klocale.h> #include "ofileselector_p.h" //US#include "ofileselector.h" #include "klocale.h" @@ -464,13 +466,14 @@ void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { locked = true; pix = Resource::loadPixmap("locked"); } } (void)new OFileSelectorItem( m_view, pix, name, - info->lastModified().toString(), QString::number( info->size() ), + KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), + QString::number( info->size() ), dir, locked ); } void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { bool locked = false; QString name; QPixmap pix; if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || @@ -484,13 +487,13 @@ void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : info->fileName(); (void)new OFileSelectorItem( m_view, pix, name, - info->lastModified().toString(), + KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), QString::number( info->size() ), info->dirPath( true ), locked, true ); } void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { |