summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 9571f16..8d024c1 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,19 +1,19 @@
/*
This file is part of KOrganizer.
Requires the Qt and KDE widget libraries, available at no cost at
http://www.troll.no and http://www.kde.org respectively
- Copyright (c) 1997, 1998, 1999
+ Copyright (c) savecale1997, 1998, 1999
Preston Brown (preton.brown@yale.edu)
Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
Ian Dawes (iadawes@globalserve.net)
Laszlo Boloni (boloni@cs.purdue.edu)
Copyright (c) 2000, 2001, 2002
Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@@ -770,24 +770,26 @@ void CalendarView::conflictNotAll()
void CalendarView::setCalReadOnly( int id, bool readO )
{
if ( readO ) {
emit save();
}
mCalendar->setReadOnly( id, readO );
}
void CalendarView::setScrollBarStep(int val )
{
#ifdef DESKTOP_VERSION
mDateScrollBar->setLineStep ( val );
+#else
+ Q_UNUSED( val );
#endif
}
void CalendarView::scrollBarValue(int val )
{
#ifdef DESKTOP_VERSION
if ( QApplication::desktop()->width() < 800 ) return;
if ( flag_blockScrollBar ) return;
flag_blockScrollBar = true;
int count = mNavigator->selectedDates().count();
int day = mNavigator->selectedDates().first().dayOfYear();
int stepdays = val;
if ( mDateScrollBar->lineStep () <= count ) {
@@ -796,24 +798,26 @@ void CalendarView::scrollBarValue(int val )
stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
stepdays = day+stepdays;
if ( stepdays < 0 ) stepdays = 0;
}
if ( stepdays == day ) {
flag_blockScrollBar = false;
return;
}
int year = mNavigator->selectedDates().first().year();
QDate d ( year,1,1 );
mNavigator->selectDates( d.addDays( stepdays-1) , count );
flag_blockScrollBar = false;
+#else
+ Q_UNUSED( val );
#endif
}
void CalendarView::updateView(const QDate &start, const QDate &end)
{
#ifdef DESKTOP_VERSION
if ( ! mDateScrollBar->draggingSlider () ) {
int dof = start.dayOfYear();
//qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
if ( dof != mDateScrollBar->value() ) {
mDateScrollBar->blockSignals( true );
mDateScrollBar->setValue( start.dayOfYear());
@@ -1593,24 +1597,25 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
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;
int filteredIN = 0;
int filteredOUT = 0;
//QPtrList<Event> el = local->rawEvents();
Event* eventR;
QString uid;
@@ -1723,40 +1728,40 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
//qDebug("take %d %s ", take, inL->summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local **********************
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
else
idS = inR->IDStr();
int calID = inR->calID();
remote->deleteIncidence( inR );
inR = inL->clone();
- inR->setCalID( calID );
+ inR->setCalID_block( calID );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
inR->setIDStr( idS );
remote->addIncidence( inR );
if ( mSyncManager->syncWithDesktop() )
inR->setPilotId( 2 );
++changedRemote;
} else {// take remote **********************
if ( !inL->isReadOnly() ) {
idS = inL->IDStr();
int pid = inL->pilotId();
int calID = inL->calID();
local->deleteIncidence( inL );
inL = inR->clone();
- inL->setCalID( calID );
+ inL->setCalID_block( calID );
if ( mSyncManager->syncWithDesktop() )
inL->setPilotId( pid );
inL->setIDStr( idS );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
}
local->addIncidence( inL );
++changedLocal;
}
}
}
@@ -1769,35 +1774,35 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
pref = "t";
if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
//remote->deleteIncidence( inR );
++deletedEventR;
} else {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
- inL->setCalID( 0 );// add to default cal
+ inL->setCalID_block( 0 );// add to default cal
local->addIncidence( inL );
++addedEvent;
}
} else {
if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
- inL->setCalID( 0 );// add to default cal
+ inL->setCalID_block( 0 );// add to default cal
local->addIncidence( inL );
++addedEvent;
} else {
checkExternSyncEvent(eventRSyncSharp, inR);
remote->deleteIncidence( inR );
++deletedEventR;
}
}
} else {
++filteredIN;
}
@@ -1837,40 +1842,40 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
//qDebug("remote added Incidence %s ", inL->summary().latin1());
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
- inR->setCalID( 0 );// add to default cal
+ inR->setCalID_block( 0 );// add to default cal
remote->addIncidence( inR );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
- inR->setCalID( 0 );// add to default cal
+ inR->setCalID_block( 0 );// add to default cal
remote->addIncidence( inR );
}
}
}
} else {
++filteredOUT;
}
}
}
inL = el.next();
}
int delFut = 0;
@@ -2440,25 +2445,27 @@ void CalendarView::mergeFile( QString fn )
{
clearAllViews();
mCalendar->mergeCalendarFile( fn );
mCalendar->reInitAlarmSettings();
setSyncEventsReadOnly();
updateUnmanagedViews();
updateView();
}
void CalendarView::mergeFileResource( QString fn ,QString resource )
{
if ( resource == "ALL" ) {
+ mCalendar->setAllCalendarEnabled( true );
mergeFile( fn );
+ restoreCalendarSettings();
return;
}
int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
if ( !exclusiveResource ) {
qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() );
return;
}
clearAllViews();
mCalendar->setCalendarRemove( exclusiveResource );
int def = mCalendar->defaultCalendar();
mCalendar->setDefaultCalendar(exclusiveResource);
@@ -2588,26 +2595,30 @@ bool CalendarView::saveCalendars()
}
restoreCalendarSettings();
//saveError = "test error";
if ( !saveError.isEmpty() ) {
saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
KMessageBox::error(this, saveError, i18n("Error saving data"));
return false;
}
return true;
}
bool CalendarView::saveCalendarResource(QString filename, QString resource)
{
- if ( resource == "ALL" )
- return saveCalendar( filename );
+ if ( resource == "ALL" ) {
+ mCalendar->setAllCalendarEnabled( true );
+ bool retval = saveCalendar( filename );
+ restoreCalendarSettings();
+ return retval;
+ }
int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
if ( !exclusiveResource ) {
qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() );
return false;
}
mCalendar->setDefaultCalendar( exclusiveResource );
mCalendar->setDefaultCalendarEnabledOnly();
mCalendar->setSyncEventsEnabled();
bool res = saveCalendar( filename );
restoreCalendarSettings();
return res;