summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-02 00:52:35 (UTC)
committer zautrix <zautrix>2004-08-02 00:52:35 (UTC)
commit54157cb44316de72d776cfae70bdadf6c52f4773 (patch) (side-by-side diff)
tree953c8ae225a54fc43a7298d49b08e821bf741cb9
parent3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0 (diff)
downloadkdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.zip
kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.tar.gz
kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.tar.bz2
Hack, hack, hack
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
@@ -906,12 +906,18 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
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;
@@ -1023,13 +1029,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
} 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() );
@@ -1073,18 +1079,18 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 {
@@ -1197,13 +1203,13 @@ void CalendarView::syncSharp()
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();
@@ -1826,28 +1832,13 @@ 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 );
@@ -2573,25 +2564,25 @@ void CalendarView::deleteTodo(Todo *todo)
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();
@@ -2647,13 +2638,13 @@ void CalendarView::deleteEvent(Event *anEvent)
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
@@ -2681,21 +2672,21 @@ void CalendarView::deleteEvent(Event *anEvent)
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();
}
@@ -3443,13 +3434,13 @@ bool CalendarView::removeCompletedSubTodos( Todo* t )
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;
}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 557554f..f7a1213 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -480,13 +480,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
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;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index df5bbcf..d59bca6 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -159,13 +159,13 @@ public:
*/
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);
@@ -208,13 +208,13 @@ public:
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.
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 09ce9f0..e464a77 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -209,17 +209,17 @@ void CalendarLocal::deleteTodo( Todo *todo )
}
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()
@@ -232,17 +232,17 @@ QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
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 )
{
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 3257198..4728063 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -172,14 +172,14 @@ class CalendarLocal : public Calendar
/**
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;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index f1db8b7..5d8785b 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -35,13 +35,12 @@ IncidenceBase::IncidenceBase() :
setUid(CalFormat::createUniqueId());
mOrganizer = "";
mFloats = false;
mDuration = 0;
mHasDuration = false;
mPilotId = 0;
- mZaurusId = -1;
mZaurusUid = 0;
mExternalId = ":";
mTempSyncStat = 0;
mSyncStatus = 0;
mAttendees.setAutoDelete( true );
}
@@ -59,13 +58,12 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
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.
@@ -339,22 +337,12 @@ void IncidenceBase::setPilotId( int 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 )
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 2f85df6..e2950d3 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -123,14 +123,12 @@ class IncidenceBase : public CustomProperties
/** 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;
@@ -158,13 +156,12 @@ class IncidenceBase : public CustomProperties
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)
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index d39d2dd..605a54d 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -82,18 +82,18 @@ class SharpParser : public QObject
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] );
@@ -186,25 +186,25 @@ class SharpParser : public QObject
}
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]);
@@ -463,13 +463,13 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
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);
@@ -517,13 +517,13 @@ bool SharpFormat::save( Calendar *calendar)
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;
@@ -603,13 +603,13 @@ bool SharpFormat::save( Calendar *calendar)
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;
@@ -693,13 +693,13 @@ QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
}
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() )
@@ -857,13 +857,13 @@ QString SharpFormat::getEventString( Event* event )
}
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() );