summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp38
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp4
3 files changed, 13 insertions, 33 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 04051a2..0c35bb3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -637,133 +637,128 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
637 } 637 }
638 //qDebug("Alarm timer started with secs: %d ", sec); 638 //qDebug("Alarm timer started with secs: %d ", sec);
639 mAlarmTimer->start( sec *1000 , true ); 639 mAlarmTimer->start( sec *1000 , true );
640 640
641} 641}
642// called by mRecheckAlarmTimer to get next alarm 642// called by mRecheckAlarmTimer to get next alarm
643// we need this, because a QTimer has only a max range of 25 days 643// we need this, because a QTimer has only a max range of 25 days
644void CalendarView::recheckTimerAlarm() 644void CalendarView::recheckTimerAlarm()
645{ 645{
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 mCalendar->checkAlarmForIncidence( 0, true ); 648 mCalendar->checkAlarmForIncidence( 0, true );
649} 649}
650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
651{ 651{
652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
654#ifndef DESKTOP_VERSION 654#ifndef DESKTOP_VERSION
655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
656#endif 656#endif
657 return; 657 return;
658 } 658 }
659 mAlarmTimer->stop(); 659 mAlarmTimer->stop();
660} 660}
661void CalendarView::selectWeekNum ( int num ) 661void CalendarView::selectWeekNum ( int num )
662{ 662{
663 dateNavigator()->selectWeek( num ); 663 dateNavigator()->selectWeek( num );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701void CalendarView::confSync()
702{
703 //DELETE
704}
705
706 701
707//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
708//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
709 704
710// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
711// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
712// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
713// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
714// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
715// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
716 711
717int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
718{ 713{
719 714
720 //void setZaurusId(int id); 715 //void setZaurusId(int id);
721 // int zaurusId() const; 716 // int zaurusId() const;
722 // void setZaurusUid(int id); 717 // void setZaurusUid(int id);
723 // int zaurusUid() const; 718 // int zaurusUid() const;
724 // void setZaurusStat(int id); 719 // void setZaurusStat(int id);
725 // int zaurusStat() const; 720 // int zaurusStat() const;
726 // 0 equal 721 // 0 equal
727 // 1 take local 722 // 1 take local
728 // 2 take remote 723 // 2 take remote
729 // 3 cancel 724 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 725 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 726 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 727 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 729 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 731 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 732 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 733 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 735 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 736 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 737 if ( mode <= SYNC_PREF_ASK )
743 return 0; 738 return 0;
744 } else { 739 } else {
745 if ( locCh ) { 740 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 741 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 742 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 743 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 744 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 745 } else {
751 //qDebug(" not loc changed "); 746 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 747 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 748 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 749 remoteMod =( lastSync.addDays( 1 ) );
755 750
756 } 751 }
757 } 752 }
758 full = true; 753 full = true;
759 if ( mode < SYNC_PREF_ASK ) 754 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 755 mode = SYNC_PREF_ASK;
761 } else { 756 } else {
762 if ( localMod == remoteMod ) 757 if ( localMod == remoteMod )
763 if ( local->revision() == remote->revision() ) 758 if ( local->revision() == remote->revision() )
764 return 0; 759 return 0;
765 760
766 } 761 }
767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 762 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
768 763
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 764 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
@@ -1140,246 +1135,238 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1140 inR = er.first(); 1135 inR = er.first();
1141 QDateTime dt; 1136 QDateTime dt;
1142 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1137 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1143 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1138 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1144 while ( inR ) { 1139 while ( inR ) {
1145 if ( inR->type() == "Todo" ) { 1140 if ( inR->type() == "Todo" ) {
1146 Todo * t = (Todo*)inR; 1141 Todo * t = (Todo*)inR;
1147 if ( t->hasDueDate() ) 1142 if ( t->hasDueDate() )
1148 dt = t->dtDue(); 1143 dt = t->dtDue();
1149 else 1144 else
1150 dt = cur.addSecs( 62 ); 1145 dt = cur.addSecs( 62 );
1151 } 1146 }
1152 else if (inR->type() == "Event" ) { 1147 else if (inR->type() == "Event" ) {
1153 bool ok; 1148 bool ok;
1154 dt = inR->getNextOccurence( cur, &ok ); 1149 dt = inR->getNextOccurence( cur, &ok );
1155 if ( !ok ) 1150 if ( !ok )
1156 dt = cur.addSecs( -62 ); 1151 dt = cur.addSecs( -62 );
1157 } 1152 }
1158 else 1153 else
1159 dt = inR->dtStart(); 1154 dt = inR->dtStart();
1160 if ( dt < cur || dt > end ) { 1155 if ( dt < cur || dt > end ) {
1161 remote->deleteIncidence( inR ); 1156 remote->deleteIncidence( inR );
1162 ++delFut; 1157 ++delFut;
1163 } 1158 }
1164 inR = er.next(); 1159 inR = er.next();
1165 } 1160 }
1166 } 1161 }
1167 bar.hide(); 1162 bar.hide();
1168 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1163 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1169 eventLSync->setReadOnly( false ); 1164 eventLSync->setReadOnly( false );
1170 eventLSync->setDtStart( mLastCalendarSync ); 1165 eventLSync->setDtStart( mLastCalendarSync );
1171 eventRSync->setDtStart( mLastCalendarSync ); 1166 eventRSync->setDtStart( mLastCalendarSync );
1172 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1167 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1173 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1168 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1174 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1169 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1175 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1170 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1176 eventLSync->setReadOnly( true ); 1171 eventLSync->setReadOnly( true );
1177 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1172 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1178 remote->addEvent( eventRSync ); 1173 remote->addEvent( eventRSync );
1179 QString mes; 1174 QString mes;
1180 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 ); 1175 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 );
1181 QString delmess; 1176 QString delmess;
1182 if ( delFut ) { 1177 if ( delFut ) {
1183 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 ); 1178 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 );
1184 mes += delmess; 1179 mes += delmess;
1185 } 1180 }
1186 if ( mSyncManager->mShowSyncSummary ) { 1181 if ( mSyncManager->mShowSyncSummary ) {
1187 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1188 } 1183 }
1189 qDebug( mes ); 1184 qDebug( mes );
1190 mCalendar->checkAlarmForIncidence( 0, true ); 1185 mCalendar->checkAlarmForIncidence( 0, true );
1191 return syncOK; 1186 return syncOK;
1192} 1187}
1193 1188
1194void CalendarView::setSyncDevice( QString s ) 1189void CalendarView::setSyncDevice( QString s )
1195{ 1190{
1196 mCurrentSyncDevice= s; 1191 mCurrentSyncDevice= s;
1197} 1192}
1198void CalendarView::setSyncName( QString s ) 1193void CalendarView::setSyncName( QString s )
1199{ 1194{
1200 mCurrentSyncName= s; 1195 mCurrentSyncName= s;
1201} 1196}
1202bool CalendarView::syncCalendar(QString filename, int mode) 1197bool CalendarView::syncCalendar(QString filename, int mode)
1203{ 1198{
1199 //qDebug("syncCalendar %s ", filename.latin1());
1204 mGlobalSyncMode = SYNC_MODE_NORMAL; 1200 mGlobalSyncMode = SYNC_MODE_NORMAL;
1205 CalendarLocal* calendar = new CalendarLocal(); 1201 CalendarLocal* calendar = new CalendarLocal();
1206 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1207 FileStorage* storage = new FileStorage( calendar ); 1203 FileStorage* storage = new FileStorage( calendar );
1208 bool syncOK = false; 1204 bool syncOK = false;
1209 storage->setFileName( filename ); 1205 storage->setFileName( filename );
1210 // qDebug("loading ... "); 1206 // qDebug("loading ... ");
1211 if ( storage->load() ) { 1207 if ( storage->load() ) {
1212 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1213 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1214 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1215 if ( syncOK ) { 1211 if ( syncOK ) {
1216 if ( mSyncManager->mWriteBackFile ) 1212 if ( mSyncManager->mWriteBackFile )
1217 { 1213 {
1218 storage->setSaveFormat( new ICalFormat() ); 1214 storage->setSaveFormat( new ICalFormat() );
1219 storage->save(); 1215 storage->save();
1220 } 1216 }
1221 } 1217 }
1222 setModified( true ); 1218 setModified( true );
1223 } 1219 }
1224 delete storage; 1220 delete storage;
1225 delete calendar; 1221 delete calendar;
1226 if ( syncOK ) 1222 if ( syncOK )
1227 updateView(); 1223 updateView();
1228 return syncOK; 1224 return syncOK;
1229} 1225}
1230void CalendarView::syncPhone() 1226
1231{
1232 //DELETE
1233}
1234void CalendarView::syncExternal( int mode ) 1227void CalendarView::syncExternal( int mode )
1235{ 1228{
1236 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1237 1230
1238 qApp->processEvents(); 1231 qApp->processEvents();
1239 CalendarLocal* calendar = new CalendarLocal(); 1232 CalendarLocal* calendar = new CalendarLocal();
1240 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1241 bool syncOK = false; 1234 bool syncOK = false;
1242 bool loadSuccess = false; 1235 bool loadSuccess = false;
1243 PhoneFormat* phoneFormat = 0; 1236 PhoneFormat* phoneFormat = 0;
1244#ifndef DESKTOP_VERSION 1237#ifndef DESKTOP_VERSION
1245 SharpFormat* sharpFormat = 0; 1238 SharpFormat* sharpFormat = 0;
1246 if ( mode == 0 ) { // sharp 1239 if ( mode == 0 ) { // sharp
1247 sharpFormat = new SharpFormat () ; 1240 sharpFormat = new SharpFormat () ;
1248 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1241 loadSuccess = sharpFormat->load( calendar, mCalendar );
1249 1242
1250 } else 1243 } else
1251#endif 1244#endif
1252 if ( mode == 1 ) { // phone 1245 if ( mode == 1 ) { // phone
1253 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1254 mSyncManager->mPhoneDevice, 1247 mSyncManager->mPhoneDevice,
1255 mSyncManager->mPhoneConnection, 1248 mSyncManager->mPhoneConnection,
1256 mSyncManager->mPhoneModel); 1249 mSyncManager->mPhoneModel);
1257 loadSuccess = phoneFormat->load( calendar,mCalendar); 1250 loadSuccess = phoneFormat->load( calendar,mCalendar);
1258 1251
1259 } else 1252 } else
1260 return; 1253 return;
1261 if ( loadSuccess ) { 1254 if ( loadSuccess ) {
1262 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1263 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1264 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1265 qApp->processEvents(); 1258 qApp->processEvents();
1266 if ( syncOK ) { 1259 if ( syncOK ) {
1267 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1268 { 1261 {
1269 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1262 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1270 Incidence* inc = iL.first(); 1263 Incidence* inc = iL.first();
1271 if ( phoneFormat ) { 1264 if ( phoneFormat ) {
1272 while ( inc ) { 1265 while ( inc ) {
1273 inc->removeID(mCurrentSyncDevice); 1266 inc->removeID(mCurrentSyncDevice);
1274 inc = iL.next(); 1267 inc = iL.next();
1275 } 1268 }
1276 } 1269 }
1277#ifndef DESKTOP_VERSION 1270#ifndef DESKTOP_VERSION
1278 if ( sharpFormat ) 1271 if ( sharpFormat )
1279 sharpFormat->save(calendar); 1272 sharpFormat->save(calendar);
1280#endif 1273#endif
1281 if ( phoneFormat ) 1274 if ( phoneFormat )
1282 phoneFormat->save(calendar); 1275 phoneFormat->save(calendar);
1283 iL = calendar->rawIncidences(); 1276 iL = calendar->rawIncidences();
1284 inc = iL.first(); 1277 inc = iL.first();
1285 Incidence* loc; 1278 Incidence* loc;
1286 while ( inc ) { 1279 while ( inc ) {
1287 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1288 loc = mCalendar->incidence(inc->uid() ); 1281 loc = mCalendar->incidence(inc->uid() );
1289 if ( loc ) { 1282 if ( loc ) {
1290 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1291 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1292 } 1285 }
1293 } 1286 }
1294 inc = iL.next(); 1287 inc = iL.next();
1295 } 1288 }
1296 Incidence* lse = getLastSyncEvent(); 1289 Incidence* lse = getLastSyncEvent();
1297 if ( lse ) { 1290 if ( lse ) {
1298 lse->setReadOnly( false ); 1291 lse->setReadOnly( false );
1299 lse->setDescription( "" ); 1292 lse->setDescription( "" );
1300 lse->setReadOnly( true ); 1293 lse->setReadOnly( true );
1301 } 1294 }
1302 } 1295 }
1303 } 1296 }
1304 setModified( true ); 1297 setModified( true );
1305 } else { 1298 } else {
1306 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1307 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1308 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1309 1302
1310 } 1303 }
1311 delete calendar; 1304 delete calendar;
1312 updateView(); 1305 updateView();
1313 return ;//syncOK; 1306 return ;//syncOK;
1314 1307
1315} 1308}
1316void CalendarView::syncSharp()
1317{
1318 //DELETE
1319
1320}
1321
1322 1309
1323bool CalendarView::importBday() 1310bool CalendarView::importBday()
1324{ 1311{
1325#ifndef KORG_NOKABC 1312#ifndef KORG_NOKABC
1326 1313
1327#ifdef DESKTOP_VERSION 1314#ifdef DESKTOP_VERSION
1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1329 KABC::AddressBook::Iterator it; 1316 KABC::AddressBook::Iterator it;
1330 int count = 0; 1317 int count = 0;
1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1332 ++count; 1319 ++count;
1333 } 1320 }
1334 QProgressBar bar(count,0 ); 1321 QProgressBar bar(count,0 );
1335 int w = 300; 1322 int w = 300;
1336 if ( QApplication::desktop()->width() < 320 ) 1323 if ( QApplication::desktop()->width() < 320 )
1337 w = 220; 1324 w = 220;
1338 int h = bar.sizeHint().height() ; 1325 int h = bar.sizeHint().height() ;
1339 int dw = QApplication::desktop()->width(); 1326 int dw = QApplication::desktop()->width();
1340 int dh = QApplication::desktop()->height(); 1327 int dh = QApplication::desktop()->height();
1341 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1342 bar.show(); 1329 bar.show();
1343 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1330 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1344 qApp->processEvents(); 1331 qApp->processEvents();
1345 count = 0; 1332 count = 0;
1346 int addCount = 0; 1333 int addCount = 0;
1347 KCal::Attendee* a = 0; 1334 KCal::Attendee* a = 0;
1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1349 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1350 return false; 1337 return false;
1351 bar.setProgress( count++ ); 1338 bar.setProgress( count++ );
1352 qApp->processEvents(); 1339 qApp->processEvents();
1353 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1354 if ( (*it).birthday().date().isValid() ){ 1341 if ( (*it).birthday().date().isValid() ){
1355 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1356 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1357 ++addCount; 1344 ++addCount;
1358 } 1345 }
1359 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1360 if ( anni.isValid() ){ 1347 if ( anni.isValid() ){
1361 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1363 ++addCount; 1350 ++addCount;
1364 } 1351 }
1365 } 1352 }
1366 updateView(); 1353 updateView();
1367 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1368#else //DESKTOP_VERSION 1355#else //DESKTOP_VERSION
1369 1356
1370 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1371 // the result should now arrive through method insertBirthdays 1358 // the result should now arrive through method insertBirthdays
1372 1359
1373#endif //DESKTOP_VERSION 1360#endif //DESKTOP_VERSION
1374 1361
1375#endif //KORG_NOKABC 1362#endif //KORG_NOKABC
1376 1363
1377 1364
1378 return true; 1365 return true;
1379} 1366}
1380 1367
1381// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1382void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1383 const QStringList& anniversaryList, const QStringList& realNameList, 1370 const QStringList& anniversaryList, const QStringList& realNameList,
1384 const QStringList& emailList, const QStringList& assembledNameList, 1371 const QStringList& emailList, const QStringList& assembledNameList,
1385 const QStringList& uidList) 1372 const QStringList& uidList)
@@ -1528,238 +1515,244 @@ bool CalendarView::importQtopia( const QString &categories,
1528 if ( mSyncManager->mWriteBackFile ) 1515 if ( mSyncManager->mWriteBackFile )
1529 { 1516 {
1530 // write back XML file 1517 // write back XML file
1531 1518
1532 } 1519 }
1533 setModified( true ); 1520 setModified( true );
1534 } 1521 }
1535 } else { 1522 } else {
1536 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1537 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1538 question, i18n("Ok")) ; 1525 question, i18n("Ok")) ;
1539 } 1526 }
1540 delete calendar; 1527 delete calendar;
1541 updateView(); 1528 updateView();
1542 return syncOK; 1529 return syncOK;
1543 1530
1544 1531
1545#endif 1532#endif
1546 1533
1547} 1534}
1548 1535
1549void CalendarView::setSyncEventsReadOnly() 1536void CalendarView::setSyncEventsReadOnly()
1550{ 1537{
1551 Event * ev; 1538 Event * ev;
1552 QPtrList<Event> eL = mCalendar->rawEvents(); 1539 QPtrList<Event> eL = mCalendar->rawEvents();
1553 ev = eL.first(); 1540 ev = eL.first();
1554 while ( ev ) { 1541 while ( ev ) {
1555 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1542 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1556 ev->setReadOnly( true ); 1543 ev->setReadOnly( true );
1557 ev = eL.next(); 1544 ev = eL.next();
1558 } 1545 }
1559} 1546}
1560bool CalendarView::openCalendar(QString filename, bool merge) 1547bool CalendarView::openCalendar(QString filename, bool merge)
1561{ 1548{
1562 1549
1563 if (filename.isEmpty()) { 1550 if (filename.isEmpty()) {
1564 return false; 1551 return false;
1565 } 1552 }
1566 1553
1567 if (!QFile::exists(filename)) { 1554 if (!QFile::exists(filename)) {
1568 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1569 return false; 1556 return false;
1570 } 1557 }
1571 1558
1572 globalFlagBlockAgenda = 1; 1559 globalFlagBlockAgenda = 1;
1573 if (!merge) mCalendar->close(); 1560 if (!merge) mCalendar->close();
1574 1561
1575 mStorage->setFileName( filename ); 1562 mStorage->setFileName( filename );
1576 1563
1577 if ( mStorage->load() ) { 1564 if ( mStorage->load() ) {
1578 if ( merge ) ;//setModified( true ); 1565 if ( merge ) ;//setModified( true );
1579 else { 1566 else {
1580 //setModified( true ); 1567 //setModified( true );
1581 mViewManager->setDocumentId( filename ); 1568 mViewManager->setDocumentId( filename );
1582 mDialogManager->setDocumentId( filename ); 1569 mDialogManager->setDocumentId( filename );
1583 mTodoList->setDocumentId( filename ); 1570 mTodoList->setDocumentId( filename );
1584 } 1571 }
1585 globalFlagBlockAgenda = 2; 1572 globalFlagBlockAgenda = 2;
1586 // if ( getLastSyncEvent() ) 1573 // if ( getLastSyncEvent() )
1587 // getLastSyncEvent()->setReadOnly( true ); 1574 // getLastSyncEvent()->setReadOnly( true );
1588 mCalendar->reInitAlarmSettings(); 1575 mCalendar->reInitAlarmSettings();
1589 setSyncEventsReadOnly(); 1576 setSyncEventsReadOnly();
1590 updateUnmanagedViews(); 1577 updateUnmanagedViews();
1591 updateView(); 1578 updateView();
1592 setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 ));
1593 if ( filename != MainWindow::defaultFileName() ) { 1579 if ( filename != MainWindow::defaultFileName() ) {
1594 saveCalendar( MainWindow::defaultFileName() ); 1580 saveCalendar( MainWindow::defaultFileName() );
1595 watchSavedFile(); 1581 } else {
1582 QFileInfo finf ( MainWindow::defaultFileName());
1583 if ( finf.exists() ) {
1584 setLoadedFileVersion( finf.lastModified () );
1585 }
1596 } 1586 }
1597 return true; 1587 return true;
1598 } else { 1588 } else {
1599 // while failing to load, the calendar object could 1589 // while failing to load, the calendar object could
1600 // have become partially populated. Clear it out. 1590 // have become partially populated. Clear it out.
1601 if ( !merge ) { 1591 if ( !merge ) {
1602 mCalendar->close(); 1592 mCalendar->close();
1603 mViewManager->setDocumentId( filename ); 1593 mViewManager->setDocumentId( filename );
1604 mDialogManager->setDocumentId( filename ); 1594 mDialogManager->setDocumentId( filename );
1605 mTodoList->setDocumentId( filename ); 1595 mTodoList->setDocumentId( filename );
1606 } 1596 }
1607 1597
1608 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1609 1599
1610 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1611 globalFlagBlockAgenda = 2; 1601 globalFlagBlockAgenda = 2;
1612 mCalendar->reInitAlarmSettings(); 1602 mCalendar->reInitAlarmSettings();
1613 setSyncEventsReadOnly(); 1603 setSyncEventsReadOnly();
1614 updateUnmanagedViews(); 1604 updateUnmanagedViews();
1615 updateView(); 1605 updateView();
1616 } 1606 }
1617 return false; 1607 return false;
1618} 1608}
1619void CalendarView::showOpenError() 1609void CalendarView::showOpenError()
1620{ 1610{
1621 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1611 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1622} 1612}
1623void CalendarView::setLoadedFileVersion(QDateTime dt) 1613void CalendarView::setLoadedFileVersion(QDateTime dt)
1624{ 1614{
1625 loadedFileVersion = dt; 1615 loadedFileVersion = dt;
1626} 1616}
1627bool CalendarView::checkFileChanged(QString fn) 1617bool CalendarView::checkFileChanged(QString fn)
1628{ 1618{
1629 QFileInfo finf ( fn ); 1619 QFileInfo finf ( fn );
1630 if ( !finf.exists() ) 1620 if ( !finf.exists() )
1631 return true; 1621 return true;
1632 QDateTime dt = finf.lastModified (); 1622 QDateTime dt = finf.lastModified ();
1633 if ( dt <= loadedFileVersion ) 1623 if ( dt <= loadedFileVersion )
1634 return false; 1624 return false;
1635 return true; 1625 return true;
1636 1626
1637} 1627}
1638void CalendarView::watchSavedFile() 1628void CalendarView::watchSavedFile()
1639{ 1629{
1640 QFileInfo finf ( MainWindow::defaultFileName()); 1630 QFileInfo finf ( MainWindow::defaultFileName());
1641 if ( !finf.exists() ) 1631 if ( !finf.exists() )
1642 return; 1632 return;
1643 QDateTime dt = finf.lastModified (); 1633 QDateTime dt = finf.lastModified ();
1644 if ( dt < loadedFileVersion ) { 1634 if ( dt < loadedFileVersion ) {
1645 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1646 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1647 return; 1637 return;
1648 } 1638 }
1649 loadedFileVersion = dt; 1639 loadedFileVersion = dt;
1650} 1640}
1651 1641
1652bool CalendarView::checkFileVersion(QString fn) 1642bool CalendarView::checkFileVersion(QString fn)
1653{ 1643{
1654 QFileInfo finf ( fn ); 1644 QFileInfo finf ( fn );
1655 if ( !finf.exists() ) 1645 if ( !finf.exists() )
1656 return true; 1646 return true;
1657 QDateTime dt = finf.lastModified (); 1647 QDateTime dt = finf.lastModified ();
1658 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1659 //qDebug("file on disk version %s",dt.toString().latin1()); 1649 //qDebug("file on disk version %s",dt.toString().latin1());
1660 if ( dt <= loadedFileVersion ) 1650 if ( dt <= loadedFileVersion )
1661 return true; 1651 return true;
1662 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1663 i18n("KO/Pi Warning"),i18n("Overwrite"), 1653 i18n("KO/Pi Warning"),i18n("Overwrite"),
1664 i18n("Sync+save")); 1654 i18n("Sync+save"));
1665 1655
1666 if ( km == KMessageBox::Cancel ) 1656 if ( km == KMessageBox::Cancel )
1667 return false; 1657 return false;
1668 if ( km == KMessageBox::Yes ) 1658 if ( km == KMessageBox::Yes )
1669 return true; 1659 return true;
1670 1660
1671 setSyncDevice("deleteaftersync" ); 1661 setSyncDevice("deleteaftersync" );
1672 mSyncManager->mAskForPreferences = true; 1662 mSyncManager->mAskForPreferences = true;
1673 mSyncManager->mSyncAlgoPrefs = 3; 1663 mSyncManager->mSyncAlgoPrefs = 3;
1674 mSyncManager->mWriteBackFile = false; 1664 mSyncManager->mWriteBackFile = false;
1675 mSyncManager->mWriteBackExistingOnly = false; 1665 mSyncManager->mWriteBackExistingOnly = false;
1676 mSyncManager->mShowSyncSummary = false; 1666 mSyncManager->mShowSyncSummary = false;
1677 syncCalendar( fn, 3 ); 1667 syncCalendar( fn, 3 );
1678 Event * e = getLastSyncEvent(); 1668 Event * e = getLastSyncEvent();
1679 mCalendar->deleteEvent ( e ); 1669 mCalendar->deleteEvent ( e );
1680 updateView(); 1670 updateView();
1681 return true; 1671 return true;
1682} 1672}
1683 1673
1684bool CalendarView::saveCalendar( QString filename ) 1674bool CalendarView::saveCalendar( QString filename )
1685{ 1675{
1686 1676
1687 // Store back all unsaved data into calendar object 1677 // Store back all unsaved data into calendar object
1688 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1689 if ( mViewManager->currentView() ) 1679 if ( mViewManager->currentView() )
1690 mViewManager->currentView()->flushView(); 1680 mViewManager->currentView()->flushView();
1691 1681
1692 //mStorage->setFileName( filename ); 1682
1693 1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1694 mStorage->setSaveFormat( new ICalFormat() ); 1684 mStorage->setSaveFormat( new ICalFormat() );
1695 mStorage->setFileName( filename ); 1685 mStorage->setFileName( filename );
1696 bool success; 1686 bool success;
1697 success = mStorage->save(); 1687 success = mStorage->save();
1698 if ( !success ) { 1688 if ( !success ) {
1699 return false; 1689 return false;
1700 } 1690 }
1701 1691 if ( filename == MainWindow::defaultFileName() ) {
1692 setLoadedFileVersion( lfv );
1693 watchSavedFile();
1694 }
1702 return true; 1695 return true;
1703} 1696}
1704 1697
1705void CalendarView::closeCalendar() 1698void CalendarView::closeCalendar()
1706{ 1699{
1707 1700
1708 // child windows no longer valid 1701 // child windows no longer valid
1709 emit closingDown(); 1702 emit closingDown();
1710 1703
1711 mCalendar->close(); 1704 mCalendar->close();
1712 setModified(false); 1705 setModified(false);
1713 updateView(); 1706 updateView();
1714} 1707}
1715 1708
1716void CalendarView::archiveCalendar() 1709void CalendarView::archiveCalendar()
1717{ 1710{
1718 mDialogManager->showArchiveDialog(); 1711 mDialogManager->showArchiveDialog();
1719} 1712}
1720 1713
1721 1714
1722void CalendarView::readSettings() 1715void CalendarView::readSettings()
1723{ 1716{
1724 1717
1725 1718
1726 // mViewManager->showAgendaView(); 1719 // mViewManager->showAgendaView();
1727 QString str; 1720 QString str;
1728 //qDebug("CalendarView::readSettings() "); 1721 //qDebug("CalendarView::readSettings() ");
1729 // read settings from the KConfig, supplying reasonable 1722 // read settings from the KConfig, supplying reasonable
1730 // defaults where none are to be found 1723 // defaults where none are to be found
1731 KConfig *config = KOGlobals::config(); 1724 KConfig *config = KOGlobals::config();
1732#ifndef KORG_NOSPLITTER 1725#ifndef KORG_NOSPLITTER
1733 config->setGroup("KOrganizer Geometry"); 1726 config->setGroup("KOrganizer Geometry");
1734 1727
1735 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1728 QValueList<int> sizes = config->readIntListEntry("Separator1");
1736 if (sizes.count() != 2) { 1729 if (sizes.count() != 2) {
1737 sizes << mDateNavigator->minimumSizeHint().width(); 1730 sizes << mDateNavigator->minimumSizeHint().width();
1738 sizes << 300; 1731 sizes << 300;
1739 } 1732 }
1740 mPanner->setSizes(sizes); 1733 mPanner->setSizes(sizes);
1741 1734
1742 sizes = config->readIntListEntry("Separator2"); 1735 sizes = config->readIntListEntry("Separator2");
1743 if ( ( mResourceView && sizes.count() == 4 ) || 1736 if ( ( mResourceView && sizes.count() == 4 ) ||
1744 ( !mResourceView && sizes.count() == 3 ) ) { 1737 ( !mResourceView && sizes.count() == 3 ) ) {
1745 mLeftSplitter->setSizes(sizes); 1738 mLeftSplitter->setSizes(sizes);
1746 } 1739 }
1747#endif 1740#endif
1748 globalFlagBlockAgenda = 1; 1741 globalFlagBlockAgenda = 1;
1749 mViewManager->showAgendaView(); 1742 mViewManager->showAgendaView();
1750 //mViewManager->readSettings( config ); 1743 //mViewManager->readSettings( config );
1751 mTodoList->restoreLayout(config,QString("Todo Layout")); 1744 mTodoList->restoreLayout(config,QString("Todo Layout"));
1752 readFilterSettings(config); 1745 readFilterSettings(config);
1753 config->setGroup( "Views" ); 1746 config->setGroup( "Views" );
1754 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1755 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1756 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1749 else if ( dateCount == 7 ) mNavigator->selectWeek();
1757 else mNavigator->selectDates( dateCount ); 1750 else mNavigator->selectDates( dateCount );
1758 // mViewManager->readSettings( config ); 1751 // mViewManager->readSettings( config );
1759 updateConfig(); 1752 updateConfig();
1760 globalFlagBlockAgenda = 2; 1753 globalFlagBlockAgenda = 2;
1761 mViewManager->readSettings( config ); 1754 mViewManager->readSettings( config );
1762#ifdef DESKTOP_VERSION 1755#ifdef DESKTOP_VERSION
1763 config->setGroup("WidgetLayout"); 1756 config->setGroup("WidgetLayout");
1764 QStringList list; 1757 QStringList list;
1765 list = config->readListEntry("MainLayout"); 1758 list = config->readListEntry("MainLayout");
@@ -2121,133 +2114,128 @@ void CalendarView::updateUnmanagedViews()
2121int CalendarView::msgItemDelete() 2114int CalendarView::msgItemDelete()
2122{ 2115{
2123 return KMessageBox::warningContinueCancel(this, 2116 return KMessageBox::warningContinueCancel(this,
2124 i18n("This item will be\npermanently deleted."), 2117 i18n("This item will be\npermanently deleted."),
2125 i18n("KO/Pi Confirmation"),i18n("Delete")); 2118 i18n("KO/Pi Confirmation"),i18n("Delete"));
2126} 2119}
2127 2120
2128 2121
2129void CalendarView::edit_cut() 2122void CalendarView::edit_cut()
2130{ 2123{
2131 Event *anEvent=0; 2124 Event *anEvent=0;
2132 2125
2133 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2134 2127
2135 if (mViewManager->currentView()->isEventView()) { 2128 if (mViewManager->currentView()->isEventView()) {
2136 if ( incidence && incidence->type() == "Event" ) { 2129 if ( incidence && incidence->type() == "Event" ) {
2137 anEvent = static_cast<Event *>(incidence); 2130 anEvent = static_cast<Event *>(incidence);
2138 } 2131 }
2139 } 2132 }
2140 2133
2141 if (!anEvent) { 2134 if (!anEvent) {
2142 KNotifyClient::beep(); 2135 KNotifyClient::beep();
2143 return; 2136 return;
2144 } 2137 }
2145 DndFactory factory( mCalendar ); 2138 DndFactory factory( mCalendar );
2146 factory.cutEvent(anEvent); 2139 factory.cutEvent(anEvent);
2147 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2148} 2141}
2149 2142
2150void CalendarView::edit_copy() 2143void CalendarView::edit_copy()
2151{ 2144{
2152 Event *anEvent=0; 2145 Event *anEvent=0;
2153 2146
2154 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2155 2148
2156 if (mViewManager->currentView()->isEventView()) { 2149 if (mViewManager->currentView()->isEventView()) {
2157 if ( incidence && incidence->type() == "Event" ) { 2150 if ( incidence && incidence->type() == "Event" ) {
2158 anEvent = static_cast<Event *>(incidence); 2151 anEvent = static_cast<Event *>(incidence);
2159 } 2152 }
2160 } 2153 }
2161 2154
2162 if (!anEvent) { 2155 if (!anEvent) {
2163 KNotifyClient::beep(); 2156 KNotifyClient::beep();
2164 return; 2157 return;
2165 } 2158 }
2166 DndFactory factory( mCalendar ); 2159 DndFactory factory( mCalendar );
2167 factory.copyEvent(anEvent); 2160 factory.copyEvent(anEvent);
2168} 2161}
2169 2162
2170void CalendarView::edit_paste() 2163void CalendarView::edit_paste()
2171{ 2164{
2172 QDate date = mNavigator->selectedDates().first(); 2165 QDate date = mNavigator->selectedDates().first();
2173 2166
2174 DndFactory factory( mCalendar ); 2167 DndFactory factory( mCalendar );
2175 Event *pastedEvent = factory.pasteEvent( date ); 2168 Event *pastedEvent = factory.pasteEvent( date );
2176 2169
2177 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2178} 2171}
2179 2172
2180void CalendarView::edit_options() 2173void CalendarView::edit_options()
2181{ 2174{
2182 mDialogManager->showOptionsDialog(); 2175 mDialogManager->showOptionsDialog();
2183 //writeSettings(); 2176 //writeSettings();
2184} 2177}
2185void CalendarView::edit_sync_options()
2186{
2187 // DELETE
2188
2189}
2190 2178
2191void CalendarView::slotSelectPickerDate( QDate d) 2179void CalendarView::slotSelectPickerDate( QDate d)
2192{ 2180{
2193 mDateFrame->hide(); 2181 mDateFrame->hide();
2194 if ( mDatePickerMode == 1 ) { 2182 if ( mDatePickerMode == 1 ) {
2195 mNavigator->slotDaySelect( d ); 2183 mNavigator->slotDaySelect( d );
2196 } else if ( mDatePickerMode == 2 ) { 2184 } else if ( mDatePickerMode == 2 ) {
2197 if ( mMoveIncidence->type() == "Todo" ) { 2185 if ( mMoveIncidence->type() == "Todo" ) {
2198 Todo * to = (Todo *) mMoveIncidence; 2186 Todo * to = (Todo *) mMoveIncidence;
2199 QTime tim; 2187 QTime tim;
2200 if ( to->hasDueDate() ) 2188 if ( to->hasDueDate() )
2201 tim = to->dtDue().time(); 2189 tim = to->dtDue().time();
2202 else { 2190 else {
2203 tim = QTime ( 0,0,0 ); 2191 tim = QTime ( 0,0,0 );
2204 to->setFloats( true ); 2192 to->setFloats( true );
2205 to->setHasDueDate( true ); 2193 to->setHasDueDate( true );
2206 } 2194 }
2207 QDateTime dt ( d,tim ); 2195 QDateTime dt ( d,tim );
2208 to->setDtDue( dt ); 2196 to->setDtDue( dt );
2209 todoChanged( to ); 2197 todoChanged( to );
2210 } else { 2198 } else {
2211 QTime tim = mMoveIncidence->dtStart().time(); 2199 QTime tim = mMoveIncidence->dtStart().time();
2212 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2213 QDateTime dt ( d,tim ); 2201 QDateTime dt ( d,tim );
2214 mMoveIncidence->setDtStart( dt ); 2202 mMoveIncidence->setDtStart( dt );
2215 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2216 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2217 } 2205 }
2218 2206
2219 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2220 } 2208 }
2221} 2209}
2222 2210
2223void CalendarView::removeCategories() 2211void CalendarView::removeCategories()
2224{ 2212{
2225 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2213 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2226 QStringList catList = KOPrefs::instance()->mCustomCategories; 2214 QStringList catList = KOPrefs::instance()->mCustomCategories;
2227 QStringList catIncList; 2215 QStringList catIncList;
2228 QStringList newCatList; 2216 QStringList newCatList;
2229 Incidence* inc = incList.first(); 2217 Incidence* inc = incList.first();
2230 int i; 2218 int i;
2231 int count = 0; 2219 int count = 0;
2232 while ( inc ) { 2220 while ( inc ) {
2233 newCatList.clear(); 2221 newCatList.clear();
2234 catIncList = inc->categories() ; 2222 catIncList = inc->categories() ;
2235 for( i = 0; i< catIncList.count(); ++i ) { 2223 for( i = 0; i< catIncList.count(); ++i ) {
2236 if ( catList.contains (catIncList[i])) 2224 if ( catList.contains (catIncList[i]))
2237 newCatList.append( catIncList[i] ); 2225 newCatList.append( catIncList[i] );
2238 } 2226 }
2239 newCatList.sort(); 2227 newCatList.sort();
2240 inc->setCategories( newCatList.join(",") ); 2228 inc->setCategories( newCatList.join(",") );
2241 inc = incList.next(); 2229 inc = incList.next();
2242 } 2230 }
2243} 2231}
2244 2232
2245int CalendarView::addCategories() 2233int CalendarView::addCategories()
2246{ 2234{
2247 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2235 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2248 QStringList catList = KOPrefs::instance()->mCustomCategories; 2236 QStringList catList = KOPrefs::instance()->mCustomCategories;
2249 QStringList catIncList; 2237 QStringList catIncList;
2250 Incidence* inc = incList.first(); 2238 Incidence* inc = incList.first();
2251 int i; 2239 int i;
2252 int count = 0; 2240 int count = 0;
2253 while ( inc ) { 2241 while ( inc ) {
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 751b8d9..660cce7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -259,275 +259,271 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
259 void showTodo(Todo *); 259 void showTodo(Todo *);
260 /** create new todo */ 260 /** create new todo */
261 void newTodo(); 261 void newTodo();
262 /** create new todo with a parent todo */ 262 /** create new todo with a parent todo */
263 void newSubTodo(); 263 void newSubTodo();
264 /** create new todo with a parent todo */ 264 /** create new todo with a parent todo */
265 void newSubTodo(Todo *); 265 void newSubTodo(Todo *);
266 /** Delete todo */ 266 /** Delete todo */
267 void deleteTodo(Todo *); 267 void deleteTodo(Todo *);
268 268
269 269
270 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 270 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
271 * emitted as result. */ 271 * emitted as result. */
272 void checkClipboard(); 272 void checkClipboard();
273 273
274 /** using the KConfig associated with the kapp variable, read in the 274 /** using the KConfig associated with the kapp variable, read in the
275 * settings from the config file. 275 * settings from the config file.
276 */ 276 */
277 void readSettings(); 277 void readSettings();
278 278
279 /** write current state to config file. */ 279 /** write current state to config file. */
280 void writeSettings(); 280 void writeSettings();
281 281
282 /** read settings for calendar filters */ 282 /** read settings for calendar filters */
283 void readFilterSettings(KConfig *config); 283 void readFilterSettings(KConfig *config);
284 284
285 /** write settings for calendar filters */ 285 /** write settings for calendar filters */
286 void writeFilterSettings(KConfig *config); 286 void writeFilterSettings(KConfig *config);
287 287
288 /** passes on the message that an event has changed to the currently 288 /** passes on the message that an event has changed to the currently
289 * activated view so that it can make appropriate display changes. */ 289 * activated view so that it can make appropriate display changes. */
290 void changeEventDisplay(Event *, int); 290 void changeEventDisplay(Event *, int);
291 void changeIncidenceDisplay(Incidence *, int); 291 void changeIncidenceDisplay(Incidence *, int);
292 void changeTodoDisplay(Todo *, int); 292 void changeTodoDisplay(Todo *, int);
293 293
294 void eventAdded(Event *); 294 void eventAdded(Event *);
295 void eventChanged(Event *); 295 void eventChanged(Event *);
296 void eventToBeDeleted(Event *); 296 void eventToBeDeleted(Event *);
297 void eventDeleted(); 297 void eventDeleted();
298 298
299 void todoAdded(Todo *); 299 void todoAdded(Todo *);
300 void todoChanged(Todo *); 300 void todoChanged(Todo *);
301 void todoToBeDeleted(Todo *); 301 void todoToBeDeleted(Todo *);
302 void todoDeleted(); 302 void todoDeleted();
303 303
304 void updateView(const QDate &start, const QDate &end); 304 void updateView(const QDate &start, const QDate &end);
305 void updateView(); 305 void updateView();
306 306
307 /** Full update of visible todo views */ 307 /** Full update of visible todo views */
308 void updateTodoViews(); 308 void updateTodoViews();
309 309
310 void updateUnmanagedViews(); 310 void updateUnmanagedViews();
311 311
312 /** cut the current appointment to the clipboard */ 312 /** cut the current appointment to the clipboard */
313 void edit_cut(); 313 void edit_cut();
314 314
315 /** copy the current appointment(s) to the clipboard */ 315 /** copy the current appointment(s) to the clipboard */
316 void edit_copy(); 316 void edit_copy();
317 317
318 /** paste the current vobject(s) in the clipboard buffer into calendar */ 318 /** paste the current vobject(s) in the clipboard buffer into calendar */
319 void edit_paste(); 319 void edit_paste();
320 320
321 /** edit viewing and configuration options. */ 321 /** edit viewing and configuration options. */
322 void edit_options(); 322 void edit_options();
323 void edit_sync_options();
324 /** 323 /**
325 Functions for printing, previewing a print, and setting up printing 324 Functions for printing, previewing a print, and setting up printing
326 parameters. 325 parameters.
327 */ 326 */
328 void print(); 327 void print();
329 void printSetup(); 328 void printSetup();
330 void printPreview(); 329 void printPreview();
331 330
332 /** Export as iCalendar file */ 331 /** Export as iCalendar file */
333 void exportICalendar(); 332 void exportICalendar();
334 333
335 /** Export as vCalendar file */ 334 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 335 bool exportVCalendar( QString fn);
337 336
338 /** pop up a dialog to show an existing appointment. */ 337 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 338 void appointment_show();
340 /** 339 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 340 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 341 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 342 * currently in the View, called currIds.
344 */ 343 */
345 void appointment_edit(); 344 void appointment_edit();
346 /** 345 /**
347 * pop up dialog confirming deletion of currently selected event in the 346 * pop up dialog confirming deletion of currently selected event in the
348 * View. 347 * View.
349 */ 348 */
350 void appointment_delete(); 349 void appointment_delete();
351 350
352 /** mails the currently selected event to a particular user as a vCalendar 351 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 352 attachment. */
354 void action_mail(); 353 void action_mail();
355 354
356 /* frees a subtodo from it's relation */ 355 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 356 void todo_unsub( Todo * );
358 357
359 /** Take ownership of selected event. */ 358 /** Take ownership of selected event. */
360 void takeOverEvent(); 359 void takeOverEvent();
361 360
362 /** Take ownership of all events in calendar. */ 361 /** Take ownership of all events in calendar. */
363 void takeOverCalendar(); 362 void takeOverCalendar();
364 363
365 /** query whether or not the calendar is "dirty". */ 364 /** query whether or not the calendar is "dirty". */
366 bool isModified(); 365 bool isModified();
367 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 366 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
368 void setModified(bool modified=true); 367 void setModified(bool modified=true);
369 368
370 /** query if the calendar is read-only. */ 369 /** query if the calendar is read-only. */
371 bool isReadOnly(); 370 bool isReadOnly();
372 /** set state of calendar to read-only */ 371 /** set state of calendar to read-only */
373 void setReadOnly(bool readOnly=true); 372 void setReadOnly(bool readOnly=true);
374 373
375 void eventUpdated(Incidence *); 374 void eventUpdated(Incidence *);
376 375
377 /* iTIP scheduling actions */ 376 /* iTIP scheduling actions */
378 void schedule_publish(Incidence *incidence = 0); 377 void schedule_publish(Incidence *incidence = 0);
379 void schedule_request(Incidence *incidence = 0); 378 void schedule_request(Incidence *incidence = 0);
380 void schedule_refresh(Incidence *incidence = 0); 379 void schedule_refresh(Incidence *incidence = 0);
381 void schedule_cancel(Incidence *incidence = 0); 380 void schedule_cancel(Incidence *incidence = 0);
382 void schedule_add(Incidence *incidence = 0); 381 void schedule_add(Incidence *incidence = 0);
383 void schedule_reply(Incidence *incidence = 0); 382 void schedule_reply(Incidence *incidence = 0);
384 void schedule_counter(Incidence *incidence = 0); 383 void schedule_counter(Incidence *incidence = 0);
385 void schedule_declinecounter(Incidence *incidence = 0); 384 void schedule_declinecounter(Incidence *incidence = 0);
386 void schedule_publish_freebusy(int daysToPublish = 30); 385 void schedule_publish_freebusy(int daysToPublish = 30);
387 386
388 void openAddressbook(); 387 void openAddressbook();
389 388
390 void editFilters(); 389 void editFilters();
391 void toggleFilerEnabled(); 390 void toggleFilerEnabled();
392 QPtrList<CalFilter> filters(); 391 QPtrList<CalFilter> filters();
393 void toggleFilter(); 392 void toggleFilter();
394 void showFilter(bool visible); 393 void showFilter(bool visible);
395 void updateFilter(); 394 void updateFilter();
396 void filterEdited(); 395 void filterEdited();
397 void selectFilter( int ); 396 void selectFilter( int );
398 KOFilterView *filterView(); 397 KOFilterView *filterView();
399 398
400 void showIntro(); 399 void showIntro();
401 400
402 /** Move the curdatepient view date to today */ 401 /** Move the curdatepient view date to today */
403 void goToday(); 402 void goToday();
404 403
405 /** Move to the next date(s) in the current view */ 404 /** Move to the next date(s) in the current view */
406 void goNext(); 405 void goNext();
407 406
408 /** Move to the previous date(s) in the current view */ 407 /** Move to the previous date(s) in the current view */
409 void goPrevious(); 408 void goPrevious();
410 /** Move to the next date(s) in the current view */ 409 /** Move to the next date(s) in the current view */
411 void goNextMonth(); 410 void goNextMonth();
412 411
413 /** Move to the previous date(s) in the current view */ 412 /** Move to the previous date(s) in the current view */
414 void goPreviousMonth(); 413 void goPreviousMonth();
415 414
416 void toggleExpand(); 415 void toggleExpand();
417 void toggleDateNavigatorWidget(); 416 void toggleDateNavigatorWidget();
418 void toggleAllDaySize(); 417 void toggleAllDaySize();
419 void dialogClosing(Incidence *); 418 void dialogClosing(Incidence *);
420 419
421 /** Look for new messages in the inbox */ 420 /** Look for new messages in the inbox */
422 void lookForIncomingMessages(); 421 void lookForIncomingMessages();
423 /** Look for new messages in the outbox */ 422 /** Look for new messages in the outbox */
424 void lookForOutgoingMessages(); 423 void lookForOutgoingMessages();
425 424
426 void processMainViewSelection( Incidence * ); 425 void processMainViewSelection( Incidence * );
427 void processTodoListSelection( Incidence * ); 426 void processTodoListSelection( Incidence * );
428 427
429 void processIncidenceSelection( Incidence * ); 428 void processIncidenceSelection( Incidence * );
430 429
431 void purgeCompleted(); 430 void purgeCompleted();
432 bool removeCompletedSubTodos( Todo* ); 431 bool removeCompletedSubTodos( Todo* );
433 void slotCalendarChanged(); 432 void slotCalendarChanged();
434 bool importBday(); 433 bool importBday();
435 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 434 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
436 bool importQtopia( const QString &categoriesFile, 435 bool importQtopia( const QString &categoriesFile,
437 const QString &datebookFile, 436 const QString &datebookFile,
438 const QString &tasklistFile ); 437 const QString &tasklistFile );
439 void syncSharp( );
440 void syncPhone( );
441 void syncExternal( int mode ); 438 void syncExternal( int mode );
442 void slotSelectPickerDate( QDate ) ; 439 void slotSelectPickerDate( QDate ) ;
443 void showDatePicker( ) ; 440 void showDatePicker( ) ;
444 void moveIncidence(Incidence *) ; 441 void moveIncidence(Incidence *) ;
445 void beamIncidence(Incidence *) ; 442 void beamIncidence(Incidence *) ;
446 void beamCalendar() ; 443 void beamCalendar() ;
447 void beamFilteredCalendar() ; 444 void beamFilteredCalendar() ;
448 void beamIncidenceList(QPtrList<Incidence>) ; 445 void beamIncidenceList(QPtrList<Incidence>) ;
449 void manageCategories(); 446 void manageCategories();
450 int addCategories(); 447 int addCategories();
451 void removeCategories(); 448 void removeCategories();
452 void setSyncDevice( QString ); 449 void setSyncDevice( QString );
453 void setSyncName( QString ); 450 void setSyncName( QString );
454 protected slots: 451 protected slots:
455 void timerAlarm(); 452 void timerAlarm();
456 void suspendAlarm(); 453 void suspendAlarm();
457 void beamDone( Ir *ir ); 454 void beamDone( Ir *ir );
458 /** Select a view or adapt the current view to display the specified dates. */ 455 /** Select a view or adapt the current view to display the specified dates. */
459 void showDates( const KCal::DateList & ); 456 void showDates( const KCal::DateList & );
460 void selectWeekNum ( int ); 457 void selectWeekNum ( int );
461 458
462 public: 459 public:
463 // show a standard warning 460 // show a standard warning
464 // returns KMsgBox::yesNoCancel() 461 // returns KMsgBox::yesNoCancel()
465 int msgCalModified(); 462 int msgCalModified();
466 virtual bool sync(KSyncManager* manager, QString filename, int mode); 463 virtual bool sync(KSyncManager* manager, QString filename, int mode);
467 464
468 virtual bool syncExternal(KSyncManager* manager, QString resource); 465 virtual bool syncExternal(KSyncManager* manager, QString resource);
469 void confSync();
470 void setSyncManager(KSyncManager* manager); 466 void setSyncManager(KSyncManager* manager);
471 void setLoadedFileVersion(QDateTime); 467 void setLoadedFileVersion(QDateTime);
472 bool checkFileVersion(QString fn); 468 bool checkFileVersion(QString fn);
473 bool checkFileChanged(QString fn); 469 bool checkFileChanged(QString fn);
474 Event* getLastSyncEvent(); 470 Event* getLastSyncEvent();
475 /** Adapt navigation units correpsonding to step size of navigation of the 471 /** Adapt navigation units correpsonding to step size of navigation of the
476 * current view. 472 * current view.
477 */ 473 */
478 void adaptNavigationUnits(); 474 void adaptNavigationUnits();
479 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 475 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
480 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 476 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
481 //Attendee* getYourAttendee(Event *event); 477 //Attendee* getYourAttendee(Event *event);
482 protected: 478 protected:
483 void schedule(Scheduler::Method, Incidence *incidence = 0); 479 void schedule(Scheduler::Method, Incidence *incidence = 0);
484 480
485 // returns KMsgBox::OKCandel() 481 // returns KMsgBox::OKCandel()
486 int msgItemDelete(); 482 int msgItemDelete();
487 void showEventEditor(); 483 void showEventEditor();
488 void showTodoEditor(); 484 void showTodoEditor();
489 void writeLocale(); 485 void writeLocale();
490 Todo *selectedTodo(); 486 Todo *selectedTodo();
491 487
492 private: 488 private:
493 KSyncManager* mSyncManager; 489 KSyncManager* mSyncManager;
494 AlarmDialog * mAlarmDialog; 490 AlarmDialog * mAlarmDialog;
495 QString mAlarmNotification; 491 QString mAlarmNotification;
496 QString mSuspendAlarmNotification; 492 QString mSuspendAlarmNotification;
497 QTimer* mSuspendTimer; 493 QTimer* mSuspendTimer;
498 QTimer* mAlarmTimer; 494 QTimer* mAlarmTimer;
499 QTimer* mRecheckAlarmTimer; 495 QTimer* mRecheckAlarmTimer;
500 void computeAlarm( QString ); 496 void computeAlarm( QString );
501 void startAlarm( QString, QString ); 497 void startAlarm( QString, QString );
502 void setSyncEventsReadOnly(); 498 void setSyncEventsReadOnly();
503 499
504 QDateTime loadedFileVersion; 500 QDateTime loadedFileVersion;
505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 501 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
506 void checkExternalId( Incidence * inc ); 502 void checkExternalId( Incidence * inc );
507 int mGlobalSyncMode; 503 int mGlobalSyncMode;
508 QString mCurrentSyncDevice; 504 QString mCurrentSyncDevice;
509 QString mCurrentSyncName; 505 QString mCurrentSyncName;
510 KOBeamPrefs* beamDialog; 506 KOBeamPrefs* beamDialog;
511 void init(); 507 void init();
512 int mDatePickerMode; 508 int mDatePickerMode;
513 bool mFlagEditDescription; 509 bool mFlagEditDescription;
514 QDateTime mLastCalendarSync; 510 QDateTime mLastCalendarSync;
515 void createPrinter(); 511 void createPrinter();
516 512
517 void calendarModified( bool, Calendar * ); 513 void calendarModified( bool, Calendar * );
518 514
519 CalPrinter *mCalPrinter; 515 CalPrinter *mCalPrinter;
520 516
521 QSplitter *mPanner; 517 QSplitter *mPanner;
522 QSplitter *mLeftSplitter; 518 QSplitter *mLeftSplitter;
523 QWidget *mLeftFrame; 519 QWidget *mLeftFrame;
524 QWidgetStack *mRightFrame; 520 QWidgetStack *mRightFrame;
525 521
526 KDatePicker* mDatePicker; 522 KDatePicker* mDatePicker;
527 QVBox* mDateFrame; 523 QVBox* mDateFrame;
528 NavigatorBar *mNavigatorBar; 524 NavigatorBar *mNavigatorBar;
529 525
530 KDateNavigator *mDateNavigator; // widget showing small month view. 526 KDateNavigator *mDateNavigator; // widget showing small month view.
531 527
532 KOFilterView *mFilterView; 528 KOFilterView *mFilterView;
533 529
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index c7ce8cb..2d17986 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1323,133 +1323,131 @@ void MainWindow::importBday()
1323 if ( result == 0 ) { 1323 if ( result == 0 ) {
1324 mView->importBday(); 1324 mView->importBday();
1325 1325
1326 } 1326 }
1327 1327
1328 1328
1329} 1329}
1330void MainWindow::importQtopia() 1330void MainWindow::importQtopia()
1331{ 1331{
1332#ifndef DESKTOP_VERSION 1332#ifndef DESKTOP_VERSION
1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1334 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1334 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1335 i18n("Import!"), i18n("Cancel"), 0, 1335 i18n("Import!"), i18n("Cancel"), 0,
1336 0, 1 ); 1336 0, 1 );
1337 if ( result == 0 ) { 1337 if ( result == 0 ) {
1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1341 mView->importQtopia( categories, datebook, todolist ); 1341 mView->importQtopia( categories, datebook, todolist );
1342 } 1342 }
1343#else 1343#else
1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1345 i18n("Not supported \non desktop!\n"), 1345 i18n("Not supported \non desktop!\n"),
1346 i18n("Ok"), i18n("Cancel"), 0, 1346 i18n("Ok"), i18n("Cancel"), 0,
1347 0, 1 ); 1347 0, 1 );
1348 1348
1349#endif 1349#endif
1350} 1350}
1351 1351
1352void MainWindow::saveOnClose() 1352void MainWindow::saveOnClose()
1353{ 1353{
1354 KOPrefs *p = KOPrefs::instance(); 1354 KOPrefs *p = KOPrefs::instance();
1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1356 p->mToolBarUp = iconToolBar->x() > width()/2 || 1356 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1357 iconToolBar->y() > height()/2; 1357 iconToolBar->y() > height()/2;
1358 mView->writeSettings(); 1358 mView->writeSettings();
1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1360 save(); 1360 save();
1361} 1361}
1362void MainWindow::slotModifiedChanged( bool changed ) 1362void MainWindow::slotModifiedChanged( bool changed )
1363{ 1363{
1364 if ( mBlockAtStartup ) 1364 if ( mBlockAtStartup )
1365 return; 1365 return;
1366 int msec; 1366 int msec;
1367 // we store the changes after 1 minute, 1367 // we store the changes after 1 minute,
1368 // and for safety reasons after 10 minutes again 1368 // and for safety reasons after 10 minutes again
1369 if ( !mSyncManager->blockSave() ) 1369 if ( !mSyncManager->blockSave() )
1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1371 else 1371 else
1372 msec = 1000 * 600; 1372 msec = 1000 * 600;
1373 mSaveTimer.start( msec, true ); // 1 minute 1373 mSaveTimer.start( msec, true ); // 1 minute
1374 qDebug("KO: Saving File in %d secs!", msec/1000); 1374 qDebug("KO: Saving File in %d secs!", msec/1000);
1375 mCalendarModifiedFlag = true; 1375 mCalendarModifiedFlag = true;
1376} 1376}
1377void MainWindow::save() 1377void MainWindow::save()
1378{ 1378{
1379 if ( mSyncManager->blockSave() ) 1379 if ( mSyncManager->blockSave() )
1380 return; 1380 return;
1381 mSyncManager->setBlockSave(true); 1381 mSyncManager->setBlockSave(true);
1382 if ( mView->checkFileVersion( defaultFileName()) ) { 1382 if ( mView->checkFileVersion( defaultFileName()) ) {
1383 1383
1384 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1384 QTime neededSaveTime = QDateTime::currentDateTime().time();
1385 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1385 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1386 qDebug("KO: Start saving data to file!"); 1386 qDebug("KO: Start saving data to file!");
1387 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1388 mView->saveCalendar( defaultFileName() ); 1387 mView->saveCalendar( defaultFileName() );
1389 1388
1390 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1389 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1391 mView->watchSavedFile();
1392 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1390 qDebug("KO: Needed %d ms for saving.",msNeeded );
1393 QString savemes; 1391 QString savemes;
1394 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1392 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1395 setCaption(savemes); 1393 setCaption(savemes);
1396 } else 1394 } else
1397 setCaption(i18n("Saving cancelled!")); 1395 setCaption(i18n("Saving cancelled!"));
1398 mCalendarModifiedFlag = false; 1396 mCalendarModifiedFlag = false;
1399 mSyncManager->setBlockSave( false ); 1397 mSyncManager->setBlockSave( false );
1400} 1398}
1401 1399
1402void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1400void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1403{ 1401{
1404 if ( !e->isAutoRepeat() ) { 1402 if ( !e->isAutoRepeat() ) {
1405 mFlagKeyPressed = false; 1403 mFlagKeyPressed = false;
1406 } 1404 }
1407} 1405}
1408void MainWindow::keyPressEvent ( QKeyEvent * e ) 1406void MainWindow::keyPressEvent ( QKeyEvent * e )
1409{ 1407{
1410 qApp->processEvents(); 1408 qApp->processEvents();
1411 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1412 e->ignore(); 1410 e->ignore();
1413 // qDebug(" ignore %d",e->isAutoRepeat() ); 1411 // qDebug(" ignore %d",e->isAutoRepeat() );
1414 return; 1412 return;
1415 } 1413 }
1416 if (! e->isAutoRepeat() ) 1414 if (! e->isAutoRepeat() )
1417 mFlagKeyPressed = true; 1415 mFlagKeyPressed = true;
1418 KOPrefs *p = KOPrefs::instance(); 1416 KOPrefs *p = KOPrefs::instance();
1419 bool showSelectedDates = false; 1417 bool showSelectedDates = false;
1420 int size; 1418 int size;
1421 int pro = 0; 1419 int pro = 0;
1422 //qDebug("MainWindow::keyPressEvent "); 1420 //qDebug("MainWindow::keyPressEvent ");
1423 switch ( e->key() ) { 1421 switch ( e->key() ) {
1424 case Qt::Key_Right: 1422 case Qt::Key_Right:
1425 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1423 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1426 mView->goNextMonth(); 1424 mView->goNextMonth();
1427 else 1425 else
1428 mView->goNext(); 1426 mView->goNext();
1429 showSelectedDates = true; 1427 showSelectedDates = true;
1430 break; 1428 break;
1431 case Qt::Key_Left: 1429 case Qt::Key_Left:
1432 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1430 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1433 mView->goPreviousMonth(); 1431 mView->goPreviousMonth();
1434 else 1432 else
1435 mView->goPrevious(); 1433 mView->goPrevious();
1436 showSelectedDates = true; 1434 showSelectedDates = true;
1437 break; 1435 break;
1438 case Qt::Key_Down: 1436 case Qt::Key_Down:
1439 mView->viewManager()->agendaView()->scrollOneHourDown(); 1437 mView->viewManager()->agendaView()->scrollOneHourDown();
1440 break; 1438 break;
1441 case Qt::Key_Up: 1439 case Qt::Key_Up:
1442 mView->viewManager()->agendaView()->scrollOneHourUp(); 1440 mView->viewManager()->agendaView()->scrollOneHourUp();
1443 break; 1441 break;
1444 case Qt::Key_I: 1442 case Qt::Key_I:
1445 mView->showIncidence(); 1443 mView->showIncidence();
1446 break; 1444 break;
1447 case Qt::Key_Delete: 1445 case Qt::Key_Delete:
1448 case Qt::Key_Backspace: 1446 case Qt::Key_Backspace:
1449 mView->deleteIncidence(); 1447 mView->deleteIncidence();
1450 break; 1448 break;
1451 case Qt::Key_D: 1449 case Qt::Key_D:
1452 mView->viewManager()->showDayView(); 1450 mView->viewManager()->showDayView();
1453 showSelectedDates = true; 1451 showSelectedDates = true;
1454 break; 1452 break;
1455 case Qt::Key_O: 1453 case Qt::Key_O:
@@ -1760,80 +1758,78 @@ void MainWindow::importFile( QString fn, bool quick )
1760 if ( result == 0 ) { 1758 if ( result == 0 ) {
1761 if ( mView->openCalendar( fn, true )) { 1759 if ( mView->openCalendar( fn, true )) {
1762 KOPrefs::instance()->mLastImportFile = fn; 1760 KOPrefs::instance()->mLastImportFile = fn;
1763 setCaption(i18n("Imported file successfully")); 1761 setCaption(i18n("Imported file successfully"));
1764 } else { 1762 } else {
1765 setCaption(i18n("Error importing file")); 1763 setCaption(i18n("Error importing file"));
1766 } 1764 }
1767 } 1765 }
1768} 1766}
1769 1767
1770void MainWindow::importIcal() 1768void MainWindow::importIcal()
1771{ 1769{
1772 1770
1773 QString fn =KOPrefs::instance()->mLastImportFile; 1771 QString fn =KOPrefs::instance()->mLastImportFile;
1774 1772
1775 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1773 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1776 if ( fn == "" ) 1774 if ( fn == "" )
1777 return; 1775 return;
1778 importFile( fn, true ); 1776 importFile( fn, true );
1779 1777
1780} 1778}
1781 1779
1782void MainWindow::exportVCalendar() 1780void MainWindow::exportVCalendar()
1783{ 1781{
1784 QString fn = KOPrefs::instance()->mLastVcalFile; 1782 QString fn = KOPrefs::instance()->mLastVcalFile;
1785 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1783 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1786 if ( fn == "" ) 1784 if ( fn == "" )
1787 return; 1785 return;
1788 QFileInfo info; 1786 QFileInfo info;
1789 info.setFile( fn ); 1787 info.setFile( fn );
1790 QString mes; 1788 QString mes;
1791 bool createbup = true; 1789 bool createbup = true;
1792 if ( info. exists() ) { 1790 if ( info. exists() ) {
1793 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1791 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1794 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1792 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1795 i18n("Overwrite!"), i18n("Cancel"), 0, 1793 i18n("Overwrite!"), i18n("Cancel"), 0,
1796 0, 1 ); 1794 0, 1 );
1797 if ( result != 0 ) { 1795 if ( result != 0 ) {
1798 createbup = false; 1796 createbup = false;
1799 } 1797 }
1800 } 1798 }
1801 if ( createbup ) { 1799 if ( createbup ) {
1802 if ( mView->exportVCalendar( fn ) ) { 1800 if ( mView->exportVCalendar( fn ) ) {
1803 KOPrefs::instance()->mLastVcalFile = fn; 1801 KOPrefs::instance()->mLastVcalFile = fn;
1804 if ( fn.length() > 20 ) 1802 if ( fn.length() > 20 )
1805 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1803 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1806 else 1804 else
1807 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1805 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1808 setCaption(mes); 1806 setCaption(mes);
1809 } 1807 }
1810 } 1808 }
1811 1809
1812} 1810}
1813 1811
1814void MainWindow::syncFileRequest() 1812void MainWindow::syncFileRequest()
1815{ 1813{
1816 save(); 1814 save();
1817} 1815}
1818void MainWindow::getFile( bool success ) 1816void MainWindow::getFile( bool success )
1819{ 1817{
1820 if ( ! success ) { 1818 if ( ! success ) {
1821 setCaption( i18n("Error receiving file. Nothing changed!") ); 1819 setCaption( i18n("Error receiving file. Nothing changed!") );
1822 return; 1820 return;
1823 } 1821 }
1824 mView->watchSavedFile();
1825 mView->openCalendar( defaultFileName() ); 1822 mView->openCalendar( defaultFileName() );
1826 setCaption( i18n("Pi-Sync successful!") ); 1823 setCaption( i18n("Pi-Sync successful!") );
1827
1828} 1824}
1829 1825
1830void MainWindow::printSel( ) 1826void MainWindow::printSel( )
1831{ 1827{
1832 mView->viewManager()->agendaView()->agenda()->printSelection(); 1828 mView->viewManager()->agendaView()->agenda()->printSelection();
1833} 1829}
1834 1830
1835void MainWindow::printCal() 1831void MainWindow::printCal()
1836{ 1832{
1837 mView->print();//mCp->showDialog(); 1833 mView->print();//mCp->showDialog();
1838} 1834}
1839 1835