author | zautrix <zautrix> | 2004-08-07 14:52:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-07 14:52:25 (UTC) |
commit | 31764784e8753157a936e42e21dcdc41bd8e2eb7 (patch) (side-by-side diff) | |
tree | ddfe5653aadd0277d1181dc459ff73c50256be13 | |
parent | 5f86d160a6d4406bdef53c8fe244baed0518142d (diff) | |
download | kdepimpi-31764784e8753157a936e42e21dcdc41bd8e2eb7.zip kdepimpi-31764784e8753157a936e42e21dcdc41bd8e2eb7.tar.gz kdepimpi-31764784e8753157a936e42e21dcdc41bd8e2eb7.tar.bz2 |
Sync fixes
-rw-r--r-- | libkcal/calendar.h | 4 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 4 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 4 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 10 |
4 files changed, 11 insertions, 11 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index d59bca6..4a3223c 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -117,146 +117,146 @@ public: */ void setTimeZoneId( const QString & ); /** Return time zone id. */ QString timeZoneId() const; /** Use local time, not UTC or a time zone. */ void setLocalTime(); /** Return whether local time is being used. */ bool isLocalTime() const; /** Add an incidence to calendar. @return true on success, false on error. */ virtual bool addIncidence( Incidence * ); /** Return filtered list of all incidences of this calendar. */ virtual QPtrList<Incidence> incidences(); /** Return unfiltered list of all incidences of this calendar. */ virtual QPtrList<Incidence> rawIncidences(); /** Adds a Event to this calendar object. @param anEvent a pointer to the event to add @return true on success, false on error. */ virtual bool addEventNoDup( Event *event ) = 0; virtual bool addAnniversaryNoDup( Event *event ) = 0; virtual bool addEvent( Event *anEvent ) = 0; /** Delete event from calendar. */ virtual void deleteEvent( Event * ) = 0; /** Retrieves an event on the basis of the unique string ID. */ virtual Event *event( const QString &UniqueStr ) = 0; - virtual Event *event( QString, int ) = 0; + virtual Event *event( QString, QString ) = 0; /** Builds and then returns a list of all events that match for the date specified. useful for dayView, etc. etc. The calendar filter is applied. */ QPtrList<Event> events( const QDate &date, bool sorted = false); /** Get events, which occur on the given date. The calendar filter is applied. */ QPtrList<Event> events( const QDateTime &qdt ); /** Get events in a range of dates. If inclusive is set to true, only events are returned, which are completely included in the range. The calendar filter is applied. */ QPtrList<Event> events( const QDate &start, const QDate &end, bool inclusive = false); /** Return filtered list of all events in calendar. */ virtual QPtrList<Event> events(); /** Return unfiltered list of all events in calendar. */ virtual QPtrList<Event> rawEvents() = 0; /** Add a todo to the todolist. @return true on success, false on error. */ virtual bool addTodo( Todo *todo ) = 0; virtual bool addTodoNoDup( Todo *todo ) = 0; /** Remove a todo from the todolist. */ virtual void deleteTodo( Todo * ) = 0; virtual void deleteJournal( Journal * ) = 0; /** Return filterd list of todos. */ virtual QPtrList<Todo> todos(); /** Searches todolist for an event with this unique string identifier, returns a pointer or null. */ virtual Todo *todo( const QString &uid ) = 0; - virtual Todo *todo( QString, int ) = 0; + virtual Todo *todo( QString, QString ) = 0; /** Returns list of todos due on the specified date. */ virtual QPtrList<Todo> todos( const QDate &date ) = 0; /** Return unfiltered list of todos. */ virtual QPtrList<Todo> rawTodos() = 0; /** Add a Journal entry to calendar. @return true on success, false on error. */ virtual bool addJournal( Journal * ) = 0; /** Return Journal for given date. */ virtual Journal *journal( const QDate & ) = 0; /** Return Journal with given UID. */ virtual Journal *journal( const QString &UID ) = 0; /** Return list of all Journal entries. */ virtual QPtrList<Journal> journals() = 0; /** Searches all incidence types for an incidence with this unique string identifier, returns a pointer or null. */ Incidence* incidence( const QString&UID ); /** Setup relations for an incidence. */ virtual void setupRelations( Incidence * ); /** Remove all relations to an incidence */ virtual void removeRelations( Incidence * ); /** Set calendar filter, which filters events for the events() functions. The Filter object is owned by the caller. */ void setFilter( CalFilter * ); diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e464a77..21b4aaf 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -167,120 +167,120 @@ Event *CalendarLocal::event( const QString &uid ) for ( event = mEventList.first(); event; event = mEventList.next() ) { if ( event->uid() == uid ) { return event; } } return 0; } bool CalendarLocal::addTodoNoDup( Todo *todo ) { Todo * eve; for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { if ( *eve == *todo ) { //qDebug("duplicate todo found! not inserted! "); return false; } } return addTodo( todo ); } bool CalendarLocal::addTodo( Todo *todo ) { mTodoList.append( todo ); todo->registerObserver( this ); // Set up subtask relations setupRelations( todo ); setModified( true ); return true; } void CalendarLocal::deleteTodo( Todo *todo ) { // Handle orphaned children removeRelations( todo ); if ( mTodoList.removeRef( todo ) ) { setModified( true ); } } QPtrList<Todo> CalendarLocal::rawTodos() { return mTodoList; } -Todo *CalendarLocal::todo( QString syncProf, int id ) +Todo *CalendarLocal::todo( QString syncProf, QString id ) { Todo *todo; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->getID( syncProf ) == id ) return todo; } return 0; } QPtrList<Event> CalendarLocal::getExternLastSyncEvents() { QPtrList<Event> el; Event *todo; for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) if ( todo->summary().left(3) == "E: " ) el.append( todo ); } return el; } -Event *CalendarLocal::event( QString syncProf, int id ) +Event *CalendarLocal::event( QString syncProf, QString id ) { Event *todo; for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { if ( todo->getID( syncProf ) == id ) return todo; } return 0; } Todo *CalendarLocal::todo( const QString &uid ) { Todo *todo; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->uid() == uid ) return todo; } return 0; } QString CalendarLocal::nextSummary() const { return mNextSummary; } QDateTime CalendarLocal::nextAlarmEventDateTime() const { return mNextAlarmEventDateTime; } void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) { //mNextAlarmIncidence //mNextAlarmDateTime //return mNextSummary; //return mNextAlarmEventDateTime; bool newNextAlarm = false; bool computeNextAlarm = false; bool ok; int offset; QDateTime nextA; // QString nextSum; //QDateTime nextEvent; if ( mNextAlarmIncidence == 0 || incidence == 0 ) { computeNextAlarm = true; } else { if ( ! deleted ) { nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; if ( ok ) { if ( nextA < mNextAlarmDateTime ) { deRegisterAlarm(); mNextAlarmDateTime = nextA; mNextSummary = incidence->summary(); diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 4728063..5b6c64c 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -130,88 +130,88 @@ class CalendarLocal : public Calendar /** Return Journal with given UID. */ Journal *journal( const QString &uid ); /** Return list of all Journals stored in calendar. */ QPtrList<Journal> journals(); /** Return all alarms, which ocur in the given time interval. */ Alarm::List alarms( const QDateTime &from, const QDateTime &to ); /** Return all alarms, which ocur before given date. */ Alarm::List alarmsTo( const QDateTime &to ); QDateTime nextAlarm( int daysTo ) ; QDateTime nextAlarmEventDateTime() const; void checkAlarmForIncidence( Incidence *, bool deleted ) ; void registerAlarm(); void deRegisterAlarm(); QString getAlarmNotification(); QString nextSummary() const ; /** This method should be called whenever a Event is modified directly via it's pointer. It makes sure that the calendar is internally consistent. */ void update( IncidenceBase *incidence ); /** Builds and then returns a list of all events that match for the date specified. useful for dayView, etc. etc. */ QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); /** Get unfiltered events for date \a qdt. */ QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); /** Get unfiltered events in a range of dates. If inclusive is set to true, only events are returned, which are completely included in the range. */ QPtrList<Event> rawEvents( const QDate &start, const QDate &end, bool inclusive = false ); - Todo *todo( QString, int uid ); - Event *event( QString,int uid ); + Todo *todo( QString, QString ); + Event *event( QString, QString ); protected: // Event* mNextAlarmEvent; QString mNextSummary; QString mNextAlarmEventDateTimeString; QString mLastAlarmNotificationString; QDateTime mNextAlarmEventDateTime; QDateTime mNextAlarmDateTime; void reInitAlarmSettings(); /** Notification function of IncidenceBase::Observer. */ void incidenceUpdated( IncidenceBase *i ) { update( i ); } /** inserts an event into its "proper place" in the calendar. */ void insertEvent( Event *event ); /** Append alarms of incidence in interval to list of alarms. */ void appendAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ); /** Append alarms of recurring events in interval to list of alarms. */ void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, const QDateTime &from, const QDateTime &to ); private: void init(); QPtrList<Event> mEventList; QPtrList<Todo> mTodoList; QPtrList<Journal> mJournalList; }; } #endif diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index e8934bf..ebfe164 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp @@ -40,201 +40,201 @@ #include "alarm.h" #include "recurrence.h" #include "calendarlocal.h" #include "sharpformat.h" #include "syncdefines.h" using namespace KCal; //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 //ARSD silentalarm = 0 // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly // 12 RFRQ // 13 RPOS pos = 4. monday in month // 14 RDYS days: 1 mon/ 2 tue .. 64 sun // 15 REND 0 = no end/ 1 = end // 16 REDT rec end dt //ALSD //ALED //MDAY class SharpParser : public QObject { public: SharpParser( Calendar *calendar ) : mCalendar( calendar ) { oldCategories = 0; } bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) { int i = 1; bool skip = true; int max = attList.count() -2; while ( i < max ) { if ( !attList[i].isEmpty() ) { skip = false; break; } ++i ; } if ( skip ) return false; ulong cSum = SharpFormat::getCsum(attList ); if ( qName == "Event" ) { Event *event; - event = existingCalendar->event( "Sharp_DTM",attList[0].toInt() ); + event = existingCalendar->event( "Sharp_DTM",attList[0] ); if ( event ) event = (Event*)event->clone(); else event = new Event; event->setID("Sharp_DTM", attList[0] ); event->setCsum( "Sharp_DTM", QString::number( cSum )); event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); event->setSummary( attList[2] ); event->setLocation( attList[3] ); event->setDescription( attList[4] ); if ( attList[7] == "1" ) { - event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); - event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); + event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); + event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); event->setFloats( true ); } else { event->setFloats( false ); event->setDtStart( fromString( attList[5] ) ); event->setDtEnd( fromString( attList[6] )); } QString rtype = attList[11]; if ( rtype != "255" ) { // qDebug("recurs "); QDate startDate = event->dtStart().date(); QString freqStr = attList[12]; int freq = freqStr.toInt(); QString hasEndDateStr = attList[15] ; bool hasEndDate = hasEndDateStr == "1"; QString endDateStr = attList[16]; QDate endDate = fromString( endDateStr ).date(); QString weekDaysStr = attList[14]; uint weekDaysNum = weekDaysStr.toInt(); QBitArray weekDays( 7 ); int i; int bb = 1; for( i = 1; i <= 7; ++i ) { weekDays.setBit( i - 1, ( bb & weekDaysNum )); bb = 2 << (i-1); //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); } // qDebug("next "); QString posStr = attList[13]; int pos = posStr.toInt(); Recurrence *r = event->recurrence(); if ( rtype == "0" ) { if ( hasEndDate ) r->setDaily( freq, endDate ); else r->setDaily( freq, -1 ); } else if ( rtype == "1" ) { if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); else r->setWeekly( freq, weekDays, -1 ); } else if ( rtype == "3" ) { if ( hasEndDate ) r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); else r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); r->addMonthlyDay( startDate.day() ); } else if ( rtype == "2" ) { if ( hasEndDate ) r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); else r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); QBitArray days( 7 ); days.fill( false ); days.setBit( startDate.dayOfWeek() - 1 ); r->addMonthlyPos( pos, days ); } else if ( rtype == "4" ) { if ( hasEndDate ) r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); else r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); r->addYearlyNum( startDate.month() ); } } QString categoryList = attList[1] ; event->setCategories( lookupCategories( categoryList ) ); // strange 0 semms to mean: alarm enabled if ( attList[8] == "0" ) { Alarm *alarm; if ( event->alarms().count() > 0 ) alarm = event->alarms().first(); else { alarm = new Alarm( event ); event->addAlarm( alarm ); } alarm->setType( Alarm::Audio ); alarm->setEnabled( true ); int alarmOffset = attList[9].toInt(); alarm->setStartOffset( alarmOffset * -60 ); } mCalendar->addEvent( event); } else if ( qName == "Todo" ) { Todo *todo; - todo = existingCalendar->todo( "Sharp_DTM", attList[0].toInt() ); + todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); if (todo ) todo = (Todo*)todo->clone(); else todo = new Todo; //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 // 0 1 2 3 4 5 6 7 8 //1,,,,,1,4,Loch zumachen,"" //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes todo->setID( "Sharp_DTM", attList[0]); todo->setCsum( "Sharp_DTM", QString::number( cSum )); todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); todo->setSummary( attList[7] ); todo->setDescription( attList[8]); int priority = attList[6].toInt(); if ( priority == 0 ) priority = 3; todo->setPriority( priority ); QString categoryList = attList[1]; todo->setCategories( lookupCategories( categoryList ) ); QString hasDateStr = attList[3]; // due if ( !hasDateStr.isEmpty() ) { if ( hasDateStr.right(6) == "000000" ) { todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); todo->setFloats( true ); } else { todo->setDtDue( fromString( hasDateStr ) ); todo->setFloats( false ); } todo->setHasDueDate( true ); } hasDateStr = attList[2];//start if ( !hasDateStr.isEmpty() ) { todo->setDtStart( fromString( hasDateStr ) ); todo->setHasStartDate( true); } else todo->setHasStartDate( false ); hasDateStr = attList[4];//completed @@ -313,97 +313,97 @@ class SharpParser : public QObject { QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); if ( it == mCategoriesMap.end() ) return id; else return *it; } static void setCategory( const QString &id, const QString &name ) { mCategoriesMap.insert( id, name ); } static QMap<QString,QString> mCategoriesMap; }; QMap<QString,QString> SharpParser::mCategoriesMap; SharpFormat::SharpFormat() { mCategories = 0; } SharpFormat::~SharpFormat() { } ulong SharpFormat::getCsum( const QStringList & attList) { int max = attList.count() -1; ulong cSum = 0; int j,k,i; int add; for ( i = 1; i < max ; ++i ) { QString s = attList[i]; if ( ! s.isEmpty() ){ j = s.length(); for ( k = 0; k < j; ++k ) { int mul = k +1; add = s[k].unicode (); if ( k < 16 ) mul = mul * mul; add = add * mul *i*i*i; cSum += add; } } } return cSum; } #include <stdlib.h> -#define DEBUGMODE false +#define DEBUGMODE true bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) { bool debug = DEBUGMODE; //debug = true; QString text; QString codec = "utf8"; QLabel status ( i18n("Reading events ..."), 0 ); int w = status.sizeHint().width()+20 ; if ( w < 200 ) w = 200; int h = status.sizeHint().height()+20 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); status.setCaption(i18n("Reading DTM Data") ); status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); status.show(); status.raise(); qApp->processEvents(); QString fileName; if ( ! debug ) { fileName = "/tmp/kopitempout"; QString command ="db2file datebook -r -c "+ codec + " > " + fileName; system ( command.latin1() ); } else { fileName = "/tmp/events.txt"; } QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { return false; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); text = ts.read(); file.close(); status.setText( i18n("Processing events ...") ); status.raise(); qApp->processEvents(); fromString2Cal( calendar, existngCal, text, "Event" ); status.setText( i18n("Reading todos ...") ); qApp->processEvents(); if ( ! debug ) { fileName = "/tmp/kopitempout"; QString command = "db2file todo -r -c " + codec+ " > " + fileName; system ( command.latin1() ); |