summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp43
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--libkcal/calendar.h4
-rw-r--r--libkcal/calendarlocal.cpp8
-rw-r--r--libkcal/calendarlocal.h4
-rw-r--r--libkcal/incidencebase.cpp12
-rw-r--r--libkcal/incidencebase.h3
-rw-r--r--libkcal/sharpformat.cpp18
8 files changed, 35 insertions, 59 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 9160e1d..cbe2a10 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -888,48 +888,54 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
{
if ( ! lastSync.count() == 0 )
return;
if ( toDelete->type() == "Journal" )
return;
Event* eve = lastSync.first();
while ( eve ) {
int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
if ( id >= 0 ) {
QString des = eve->description();
QString pref = "e";
if ( toDelete->type() == "Todo" )
pref = "t";
des += pref+ QString::number ( id ) + ",";
eve->setReadOnly( false );
eve->setDescription( des );
eve->setReadOnly( true );
}
eve = lastSync.next();
}
}
+void CalendarView::checkExternalId( Incidence * inc )
+{
+ QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
+ checkExternSyncEvent( lastSync, inc );
+
+}
bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
{
bool syncOK = true;
int addedEvent = 0;
int addedEventR = 0;
int deletedEventR = 0;
int deletedEventL = 0;
int changedLocal = 0;
int changedRemote = 0;
//QPtrList<Event> el = local->rawEvents();
Event* eventR;
QString uid;
int take;
Event* eventL;
Event* eventRSync;
Event* eventLSync;
QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
bool fullDateRange = false;
mLastCalendarSync = QDateTime::currentDateTime();
QDateTime modifiedCalendar = mLastCalendarSync;;
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
eventRSync = (Event*) eventR->clone();
@@ -1005,49 +1011,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
//qDebug("take %d %s ", take, inL->summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local
inL->setZaurusUid( inR->zaurusUid() );
remote->deleteIncidence( inR );
if ( inL->revision() < maxrev )
inL->setRevision( maxrev );
remote->addIncidence( inL->clone() );
++changedRemote;
} else {
if ( inR->revision() < maxrev )
inR->setRevision( maxrev );
local->deleteIncidence( inL );
local->addIncidence( inR->clone() );
++changedLocal;
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = eventLSync->description();
QString pref = "e";
if ( inR->type() == "Todo" )
pref = "t";
- if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
+ if ( des.find(pref+QString::number( inR->getID(mCurrentSyncDevice) ) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
//remote->deleteIncidence( inR );
++deletedEventR;
} else {
inR->setLastModified( modifiedCalendar );
local->addIncidence( inR->clone() );
++addedEvent;
}
} else {
if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
local->addIncidence( inR->clone() );
++addedEvent;
} else {
checkExternSyncEvent(eventRSyncSharp, inR);
remote->deleteIncidence( inR );
++deletedEventR;
}
}
}
}
inR = er.next();
}
QPtrList<Incidence> el = local->rawIncidences();
@@ -1055,54 +1061,54 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
modulo = (el.count()/10)+1;
bar.setCaption (i18n("Add / remove events") );
bar.setTotalSteps ( el.count() ) ;
bar.show();
incCounter = 0;
while ( inL ) {
qApp->processEvents();
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
++incCounter;
uid = inL->uid();
bool skipIncidence = false;
if ( uid.left(15) == QString("last-syncEvent-") )
skipIncidence = true;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
skipIncidence = true;
if ( !skipIncidence ) {
inR = remote->incidence( uid );
if ( ! inR ) {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
- if ( inL->zaurusId() >= 0 && mode != 4 ) {
+ if ( inL->getID(mCurrentSyncDevice) >= 0 && mode != 4 ) {
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
- inL->setZaurusId( -1 );
+ inL->setID(mCurrentSyncDevice, -1 );
++addedEventR;
inL->setLastModified( modifiedCalendar );
remote->addIncidence( inL->clone() );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
remote->addIncidence( inL->clone() );
}
}
}
}
}
inL = el.next();
}
bar.hide();
@@ -1179,49 +1185,49 @@ void CalendarView::syncSharp()
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
qApp->processEvents();
if ( syncOK ) {
if ( KOPrefs::instance()->mWriteBackFile )
{
QPtrList<Incidence> iL = mCalendar->rawIncidences();
Incidence* inc = iL.first();
/* obsolete
while ( inc ) {
inc->setZaurusStat( inc->revision () );
inc = iL.next();
}
*/
// pending: clean last sync event description
sharpFormat.save(calendar);
iL = calendar->rawIncidences();
inc = iL.first();
Incidence* loc;
while ( inc ) {
if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
loc = mCalendar->incidence(inc->uid() );
if ( loc ) {
- loc->setZaurusId( inc->zaurusId() );
+ loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
loc->setZaurusUid( inc->zaurusUid() );
}
}
inc = iL.next();
}
Incidence* lse = getLastSyncEvent();
if ( lse ) {
lse->setReadOnly( false );
lse->setDescription( "" );
lse->setReadOnly( true );
}
}
}
setModified( true );
} else {
QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
question, i18n("Ok")) ;
}
delete calendar;
updateView();
return ;//syncOK;
#endif
@@ -1808,64 +1814,49 @@ void CalendarView::updateConfig()
void CalendarView::eventChanged(Event *event)
{
changeEventDisplay(event,KOGlobals::EVENTEDITED);
//updateUnmanagedViews();
}
void CalendarView::eventAdded(Event *event)
{
changeEventDisplay(event,KOGlobals::EVENTADDED);
}
void CalendarView::eventToBeDeleted(Event *)
{
kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
}
void CalendarView::eventDeleted()
{
changeEventDisplay(0,KOGlobals::EVENTDELETED);
}
void CalendarView::changeTodoDisplay(Todo *which, int action)
{
changeIncidenceDisplay((Incidence *)which, action);
}
-void CalendarView::checkZaurusId( int id, bool todo )
-{
- if ( id >= 0 ) {
- Incidence* lse = mCalendar->event( "last-syncEvent-Sharp-DTM");
- if ( lse ) {
- QString des = lse->description();
- QString pref = "e";
- if ( todo )
- pref = "t";
- des += pref+ QString::number ( id ) + ",";
- lse->setReadOnly( false );
- lse->setDescription( des );
- lse->setReadOnly( true );
- }
- }
-}
+
void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
{
updateUnmanagedViews();
//qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
if ( action == KOGlobals::EVENTDELETED ) { //delete
mCalendar->checkAlarmForIncidence( 0, true );
if ( mEventViewerDialog )
mEventViewerDialog->hide();
}
else
mCalendar->checkAlarmForIncidence( which , false );
}
// most of the changeEventDisplays() right now just call the view's
// total update mode, but they SHOULD be recoded to be more refresh-efficient.
void CalendarView::changeEventDisplay(Event *which, int action)
{
// kdDebug() << "CalendarView::changeEventDisplay" << endl;
changeIncidenceDisplay((Incidence *)which, action);
mDateNavigator->updateView();
//mDialogManager->updateSearchDialog();
if (which) {
// If there is an event view visible update the display
@@ -2555,61 +2546,61 @@ void CalendarView::todo_unsub(Todo *anTodo )
// Todo *anTodo = selectedTodo();
if (!anTodo) return;
if (!anTodo->relatedTo()) return;
anTodo->relatedTo()->removeRelation(anTodo);
anTodo->setRelatedTo(0);
anTodo->updated();
anTodo->setRelatedToUid("");
setModified(true);
updateView();
}
void CalendarView::deleteTodo(Todo *todo)
{
if (!todo) {
KNotifyClient::beep();
return;
}
if (KOPrefs::instance()->mConfirm) {
switch (msgItemDelete()) {
case KMessageBox::Continue: // OK
if (!todo->relations().isEmpty()) {
KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
i18n("Delete To-Do"));
} else {
- checkZaurusId( todo->zaurusId(), true );
+ checkExternalId( todo );
calendar()->deleteTodo(todo);
changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
updateView();
}
break;
} // switch
} else {
if (!todo->relations().isEmpty()) {
KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
i18n("Delete To-Do"));
} else {
- checkZaurusId( todo->zaurusId(), true );
+ checkExternalId( todo );
mCalendar->deleteTodo(todo);
changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
updateView();
}
}
emit updateSearchDialog();
}
void CalendarView::deleteJournal(Journal *jour)
{
if (!jour) {
KNotifyClient::beep();
return;
}
if (KOPrefs::instance()->mConfirm) {
switch (msgItemDelete()) {
case KMessageBox::Continue: // OK
calendar()->deleteJournal(jour);
updateView();
break;
} // switch
} else {
calendar()->deleteJournal(jour);;
updateView();
}
@@ -2629,91 +2620,91 @@ void CalendarView::deleteEvent(Event *anEvent)
if (!itemDate.isValid()) {
//kdDebug() << "Date Not Valid" << endl;
if (KOPrefs::instance()->mConfirm) {
km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
i18n("KO/Pi Confirmation"),i18n("Delete All"));
if ( km == KMessageBox::Continue )
km = KMessageBox::No; // No = all below
} else
km = KMessageBox::No;
} else {
km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
i18n("KO/Pi Confirmation"),i18n("Current"),
i18n("All"));
}
switch(km) {
case KMessageBox::No: // Continue // all
//qDebug("KMessageBox::No ");
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
schedule(Scheduler::Cancel,anEvent);
- checkZaurusId( anEvent->zaurusId());
+ checkExternalId( anEvent);
mCalendar->deleteEvent(anEvent);
changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
break;
// Disabled because it does not work
//#if 0
case KMessageBox::Yes: // just this one
//QDate qd = mNavigator->selectedDates().first();
//if (!qd.isValid()) {
// kdDebug() << "no date selected, or invalid date" << endl;
// KNotifyClient::beep();
// return;
//}
//while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
anEvent->addExDate(itemDate);
int duration = anEvent->recurrence()->duration();
if ( duration > 0 ) {
anEvent->recurrence()->setDuration( duration - 1 );
}
changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
}
break;
//#endif
} // switch
} else {
if (KOPrefs::instance()->mConfirm) {
switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
i18n("\nAre you sure you want\nto delete this event?"),
i18n("KO/Pi Confirmation"),i18n("Delete"))) {
case KMessageBox::Continue: // OK
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
schedule(Scheduler::Cancel,anEvent);
- checkZaurusId( anEvent->zaurusId());
+ checkExternalId( anEvent);
mCalendar->deleteEvent(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
break;
} // switch
} else {
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
schedule(Scheduler::Cancel,anEvent);
- checkZaurusId( anEvent->zaurusId());
+ checkExternalId( anEvent);
mCalendar->deleteEvent(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
}
} // if-else
emit updateSearchDialog();
}
bool CalendarView::deleteEvent(const QString &uid)
{
Event *ev = mCalendar->event(uid);
if (ev) {
deleteEvent(ev);
return true;
} else {
return false;
}
}
/*****************************************************************************/
void CalendarView::action_mail()
{
#ifndef KORG_NOMAIL
KOMailClient mailClient;
@@ -3425,49 +3416,49 @@ void CalendarView::deleteIncidence(Incidence *incidence)
void CalendarView::lookForOutgoingMessages()
{
OutgoingDialog *ogd = mDialogManager->outgoingDialog();
ogd->loadMessages();
}
void CalendarView::lookForIncomingMessages()
{
IncomingDialog *icd = mDialogManager->incomingDialog();
icd->retrieve();
}
bool CalendarView::removeCompletedSubTodos( Todo* t )
{
bool deleteTodo = true;
QPtrList<Incidence> subTodos;
Incidence *aTodo;
subTodos = t->relations();
for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
if (! removeCompletedSubTodos( (Todo*) aTodo ))
deleteTodo = false;
}
if ( deleteTodo ) {
if ( t->isCompleted() ) {
- checkZaurusId( t->zaurusId(), true );
+ checkExternalId( t );
mCalendar->deleteTodo( t );
changeTodoDisplay( t,KOGlobals::EVENTDELETED );
}
else
deleteTodo = false;
}
return deleteTodo;
}
void CalendarView::purgeCompleted()
{
int result = KMessageBox::warningContinueCancel(this,
i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
if (result == KMessageBox::Continue) {
QPtrList<Todo> todoCal;
QPtrList<Todo> rootTodos;
//QPtrList<Incidence> rel;
Todo *aTodo;//, *rTodo;
Incidence *rIncidence;
bool childDelete = false;
bool deletedOne = true;
todoCal = calendar()->todos();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 557554f..f7a1213 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -462,49 +462,49 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
//Attendee* getYourAttendee(Event *event);
protected:
void schedule(Scheduler::Method, Incidence *incidence = 0);
// returns KMsgBox::OKCandel()
int msgItemDelete();
void showEventEditor();
void showTodoEditor();
void writeLocale();
Todo *selectedTodo();
private:
AlarmDialog * mAlarmDialog;
QString mAlarmNotification;
QString mSuspendAlarmNotification;
QTimer* mSuspendTimer;
QTimer* mAlarmTimer;
QTimer* mRecheckAlarmTimer;
void computeAlarm( QString );
void startAlarm( QString, QString );
void setSyncEventsReadOnly();
QDateTime loadedFileVersion;
void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
- void checkZaurusId( int id, bool todo = false );
+ void checkExternalId( Incidence * inc );
int mGlobalSyncMode;
QString mCurrentSyncDevice;
QString mCurrentSyncName;
KOBeamPrefs* beamDialog;
void init();
int mDatePickerMode;
bool mFlagEditDescription;
QDateTime mLastCalendarSync;
void createPrinter();
void calendarModified( bool, Calendar * );
CalPrinter *mCalPrinter;
QSplitter *mPanner;
QSplitter *mLeftSplitter;
QWidget *mLeftFrame;
QWidgetStack *mRightFrame;
KDatePicker* mDatePicker;
QVBox* mDateFrame;
NavigatorBar *mNavigatorBar;
KDateNavigator *mDateNavigator; // widget showing small month view.
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index df5bbcf..d59bca6 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -141,98 +141,98 @@ public:
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( int ) = 0;
+ virtual Event *event( QString, int ) = 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( int ) = 0;
+ virtual Todo *todo( QString, int ) = 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;
/**
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 09ce9f0..e464a77 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -191,76 +191,76 @@ bool CalendarLocal::addTodo( Todo *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( int id )
+Todo *CalendarLocal::todo( QString syncProf, int id )
{
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->zaurusId() == id ) return todo;
+ 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( int id )
+Event *CalendarLocal::event( QString syncProf, int id )
{
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
- if ( todo->zaurusId() == id ) return todo;
+ 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
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 3257198..4728063 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -154,50 +154,50 @@ class CalendarLocal : public Calendar
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 *CalendarLocal::todo( int uid );
- Event *CalendarLocal::event( int uid );
+ Todo *todo( QString, int uid );
+ Event *event( QString,int uid );
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. */
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index f1db8b7..5d8785b 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -17,73 +17,71 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include "calformat.h"
#include "incidencebase.h"
using namespace KCal;
IncidenceBase::IncidenceBase() :
mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
mPilotId(0), mSyncStatus(SYNCMOD)
{
setUid(CalFormat::createUniqueId());
mOrganizer = "";
mFloats = false;
mDuration = 0;
mHasDuration = false;
mPilotId = 0;
- mZaurusId = -1;
mZaurusUid = 0;
mExternalId = ":";
mTempSyncStat = 0;
mSyncStatus = 0;
mAttendees.setAutoDelete( true );
}
IncidenceBase::IncidenceBase(const IncidenceBase &i) :
CustomProperties( i )
{
mReadOnly = i.mReadOnly;
mDtStart = i.mDtStart;
mDuration = i.mDuration;
mHasDuration = i.mHasDuration;
mOrganizer = i.mOrganizer;
mUid = i.mUid;
QPtrList<Attendee> attendees = i.attendees();
for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
mAttendees.append( new Attendee( *a ) );
}
mFloats = i.mFloats;
mLastModified = i.mLastModified;
mPilotId = i.mPilotId;
- mZaurusId = i.mZaurusId;
mZaurusUid = i.mZaurusUid;
mTempSyncStat = i.mTempSyncStat;
mSyncStatus = i.mSyncStatus;
mExternalId = i.mExternalId;
// The copied object is a new one, so it isn't observed by the observer
// of the original object.
mObservers.clear();
mAttendees.setAutoDelete( true );
}
IncidenceBase::~IncidenceBase()
{
}
bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
{
// do not compare mSyncStatus and mExternalId
if( i1.attendees().count() != i2.attendees().count() ) {
return false; // no need to check further
}
if ( i1.attendees().count() > 0 ) {
Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
@@ -321,58 +319,48 @@ bool IncidenceBase::hasDuration() const
return mHasDuration;
}
void IncidenceBase::setSyncStatus(int stat)
{
if (mReadOnly) return;
mSyncStatus = stat;
}
int IncidenceBase::syncStatus() const
{
return mSyncStatus;
}
void IncidenceBase::setPilotId( int id )
{
if (mReadOnly) return;
mPilotId = id;
}
int IncidenceBase::pilotId() const
{
return mPilotId;
}
-void IncidenceBase::setZaurusId( int id )
-{
- if (mReadOnly) return;
- mZaurusId = id;
-}
-
-int IncidenceBase::zaurusId() const
-{
- return mZaurusId;
-}
int IncidenceBase::zaurusUid() const
{
return mZaurusUid;
}
void IncidenceBase::setZaurusUid( int id )
{
if (mReadOnly) return;
mZaurusUid = id;
}
int IncidenceBase::tempSyncStat() const
{
return mTempSyncStat;
}
void IncidenceBase::setTempSyncStat( int id )
{
if (mReadOnly) return;
mTempSyncStat = id;
}
void IncidenceBase::setID( const QString & prof , int id )
{
int num = mExternalId.find( ":"+prof+";" );
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 2f85df6..e2950d3 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -105,74 +105,71 @@ class IncidenceBase : public CustomProperties
// void removeAttendee(const char *n);
/** Remove all Attendees. */
void clearAttendees();
/** Return list of attendees. */
QPtrList<Attendee> attendees() const { return mAttendees; };
/** Return number of attendees. */
int attendeeCount() const { return mAttendees.count(); };
/** Return the Attendee with this email */
Attendee* attendeeByMail(const QString &);
/** Return first Attendee with one of this emails */
Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
/** pilot syncronization states */
enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
/** Set synchronisation satus. */
void setSyncStatus(int stat);
/** Return synchronisation status. */
int syncStatus() const;
/** Set Pilot Id. */
void setPilotId(int id);
/** Return Pilot Id. */
int pilotId() const;
- void setZaurusId(int id);
- int zaurusId() const;
void setZaurusUid(int id);
int zaurusUid() const;
void setTempSyncStat(int id);
int tempSyncStat() const;
void setIDStr( const QString & );
QString IDStr() const;
void setID( const QString &, int );
int getID( const QString & );
void setCsum( const QString &, int );
int getCsum( const QString & );
void registerObserver( Observer * );
void unRegisterObserver( Observer * );
void updated();
protected:
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
private:
// base components
QDateTime mDtStart;
QString mOrganizer;
QString mUid;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
bool mFloats;
int mDuration;
bool mHasDuration;
QString mExternalId;
- int mZaurusId;
int mZaurusUid;
int mTempSyncStat;
// PILOT SYNCHRONIZATION STUFF
int mPilotId; // unique id for pilot sync
int mSyncStatus; // status (for sync)
QPtrList<Observer> mObservers;
};
bool operator==( const IncidenceBase&, const IncidenceBase& );
}
#endif
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index d39d2dd..605a54d 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -64,54 +64,54 @@ 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( attList[0].toInt() );
+ event = existingCalendar->event( "Sharp_DTM",attList[0].toInt() );
if ( event )
event = (Event*)event->clone();
else
event = new Event;
- event->setZaurusId( attList[0].toInt() );
+ event->setID("Sharp_DTM", attList[0].toInt() );
event->setZaurusUid( 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->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();
@@ -168,61 +168,61 @@ class SharpParser : public QObject
}
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( attList[0].toInt() );
+ todo = existingCalendar->todo( "Sharp_DTM", attList[0].toInt() );
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->setZaurusId( attList[0].toInt() );
+ todo->setID( "Sharp_DTM", attList[0].toInt() );
todo->setZaurusUid( 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 );
@@ -445,49 +445,49 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
if ( loopCount > 25 ) {
qDebug("KO: Error in while loop");
ok = false;
start = 0;
break;
}
if ( ok )
tempString = getPart( answer, ok, start );
if ( start >= len || start == 0 ) {
start = 0;
ok = false;
}
if ( tempString.right(1) =="\n" )
tempString = tempString.left( tempString.length()-1);
templist.append( tempString );
}
++ccc;
if ( ccc == 2 && loopCount < 25 ) {
start = 0;
bool ok;
int newnum = templist[0].toInt( &ok );
if ( ok && newnum > 0) {
retval = newnum;
- inc->setZaurusId( newnum );
+ inc->setID( "Sharp_DTM",newnum );
inc->setZaurusUid( getCsum( templist ) );
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
}
}
}
//qDebug("getNumFromRecord returning : %d ", retval);
return retval;
}
bool SharpFormat::save( Calendar *calendar)
{
QLabel status ( i18n("Processing/adding 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("Writing DTM Data") );
status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
status.show();
status.raise();
qApp->processEvents();
bool debug = DEBUGMODE;
QString codec = "utf8";
@@ -499,49 +499,49 @@ bool SharpFormat::save( Calendar *calendar)
Event* ev = er.first();
QString fileName = "/tmp/kopitempout";
int i = 0;
QString changeString = ePrefix;
QString deleteString = ePrefix;
bool deleteEnt = false;
bool changeEnt = false;
QString message = i18n("Processing event # ");
int procCount = 0;
while ( ev ) {
//qDebug("i %d ", ++i);
if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
QString eString = getEventString( ev );
if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
// deleting empty strings does not work.
// we write first and x and then delete the record with the x
eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
changeString += eString + "\n";
deleteString += eString + "\n";
deleteEnt = true;
changeEnt = true;
}
- else if ( ev->zaurusId() == -1 ) { // add new
+ else if ( ev->getID("Sharp_DTM") == -1 ) { // add new
command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
system ( command.utf8() );
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
return false;
}
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
answer = ts.read();
file.close();
//qDebug("answer \n%s ", answer.latin1());
getNumFromRecord( answer, ev ) ;
}
else { // change existing
//qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
//command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
changeString += eString + "\n";
changeEnt = true;
}
}
ev = er.next();
@@ -585,49 +585,49 @@ bool SharpFormat::save( Calendar *calendar)
changeString = tPrefix;
deleteString = tPrefix;
status.setText ( i18n("Processing todos ...") );
qApp->processEvents();
QPtrList<Todo> tl = calendar->rawTodos();
Todo* to = tl.first();
i = 0;
message = i18n("Processing todo # ");
procCount = 0;
while ( to ) {
if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
QString eString = getTodoString( to );
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
// deleting empty strings does not work.
// we write first and x and then delete the record with the x
eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
changeString += eString + "\n";
deleteString += eString + "\n";
deleteEnt = true;
changeEnt = true;
}
- else if ( to->zaurusId() == -1 ) { // add new
+ else if ( to->getID("Sharp_DTM") == -1 ) { // add new
command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
system ( command.utf8() );
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
return false;
}
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
answer = ts.read();
file.close();
//qDebug("answer \n%s ", answer.latin1());
getNumFromRecord( answer, to ) ;
}
else { // change existing
//qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
//command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
changeString += eString + "\n";
changeEnt = true;
}
}
@@ -675,49 +675,49 @@ QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
{
QString datestr;
QString timestr;
int offset = KGlobal::locale()->localTimeOffset( dti );
QDateTime dt;
if (useTZ)
dt = dti.addSecs ( -(offset*60));
else
dt = dti;
if(dt.date().isValid()){
const QDate& date = dt.date();
datestr.sprintf("%04d%02d%02d",
date.year(), date.month(), date.day());
}
if(dt.time().isValid()){
const QTime& time = dt.time();
timestr.sprintf("T%02d%02d%02d",
time.hour(), time.minute(), time.second());
}
return datestr + timestr;
}
QString SharpFormat::getEventString( Event* event )
{
QStringList list;
- list.append( QString::number(event->zaurusId() ) );
+ list.append( QString::number(event->getID("Sharp_DTM") ) );
list.append( event->categories().join(",") );
if ( !event->summary().isEmpty() )
list.append( event->summary() );
else
list.append("" );
if ( !event->location().isEmpty() )
list.append( event->location() );
else
list.append("" );
if ( !event->description().isEmpty() )
list.append( event->description() );
else
list.append( "" );
if ( event->doesFloat () ) {
list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
list.append( "1" );
}
else {
list.append( dtToString( event->dtStart()) );
list.append( dtToString( event->dtEnd()) ); //6
list.append( "0" );
}
@@ -839,49 +839,49 @@ QString SharpFormat::getEventString( Event* event )
if (event->dtStart().date() == event->dtEnd().date() )
list.append( "0" );
else
list.append( "1" );
for(QStringList::Iterator it=list.begin();
it!=list.end(); ++it){
QString& s = (*it);
s.replace(QRegExp("\""), "\"\"");
if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
s.prepend('\"');
s.append('\"');
} else if(s.isEmpty() && !s.isNull()){
s = "\"\"";
}
}
return list.join(",");
}
QString SharpFormat::getTodoString( Todo* todo )
{
QStringList list;
- list.append( QString::number( todo->zaurusId() ) );
+ list.append( QString::number( todo->getID("Sharp_DTM") ) );
list.append( todo->categories().join(",") );
if ( todo->hasStartDate() ) {
list.append( dtToString( todo->dtStart()) );
} else
list.append( QString() );
if ( todo->hasDueDate() ) {
QTime tim;
if ( todo->doesFloat()) {
list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
} else {
list.append( dtToString(todo->dtDue() ) );
}
} else
list.append( QString() );
if ( todo->isCompleted() ) {
list.append( dtToString( todo->completed()) );
list.append( "0" ); // yes 0 == completed
} else {
list.append( dtToString( todo->completed()) );
list.append( "1" );
}