summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 689618d..a7f7010 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -74,24 +74,25 @@
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#include <libkcal/phoneformat.h>
86#ifndef KORG_NOMAIL 87#ifndef KORG_NOMAIL
87#include "komailclient.h" 88#include "komailclient.h"
88#endif 89#endif
89#ifndef KORG_NOPRINTER 90#ifndef KORG_NOPRINTER
90#include "calprinter.h" 91#include "calprinter.h"
91#endif 92#endif
92#ifndef KORG_NOPLUGINS 93#ifndef KORG_NOPLUGINS
93#include "kocore.h" 94#include "kocore.h"
94#endif 95#endif
95#include "koeventeditor.h" 96#include "koeventeditor.h"
96#include "kotodoeditor.h" 97#include "kotodoeditor.h"
97#include "koprefs.h" 98#include "koprefs.h"
@@ -1166,56 +1167,74 @@ bool CalendarView::syncCalendar(QString filename, int mode)
1166 } 1167 }
1167 } 1168 }
1168 setModified( true ); 1169 setModified( true );
1169 } 1170 }
1170 delete storage; 1171 delete storage;
1171 delete calendar; 1172 delete calendar;
1172 if ( syncOK ) 1173 if ( syncOK )
1173 updateView(); 1174 updateView();
1174 return syncOK; 1175 return syncOK;
1175} 1176}
1176void CalendarView::syncPhone() 1177void CalendarView::syncPhone()
1177{ 1178{
1178 qDebug("CalendarView::syncPhone() "); 1179 syncExternal( 1 );
1179} 1180}
1180void CalendarView::syncSharp() 1181void CalendarView::syncExternal( int mode )
1181{ 1182{
1182#ifndef DESKTOP_VERSION 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1184 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1185 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1186 edit_sync_options(); 1186 edit_sync_options();
1187 qApp->processEvents(); 1187 qApp->processEvents();
1188 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1190 bool syncOK = false; 1190 bool syncOK = false;
1191 SharpFormat sharpFormat; 1191 boo loadSuccess = false;
1192 if ( sharpFormat.load( calendar, mCalendar ) ) { 1192 PhoneFormat* phoneFormat = 0;
1193#ifndef DESKTOP_VERSION
1194 SharpFormat* sharpFormat = 0;
1195 if ( mode == 0 ) { // sharp
1196 sharpFormat = new SharpFormat () ;
1197 loadSuccess = sharpFormat->load( calendar, mCalendar );
1198
1199 } else
1200#endif
1201 if ( mode == 1 ) { // phone
1202 phoneFormat = new PhoneFormat ();
1203 loadSuccess = phoneFormat->load( calendar, mCalendar );
1204
1205 } else
1206 return;
1207 if ( loadSuccess ) {
1193 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1194 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1195 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1196 qApp->processEvents(); 1211 qApp->processEvents();
1197 if ( syncOK ) { 1212 if ( syncOK ) {
1198 if ( KOPrefs::instance()->mWriteBackFile ) 1213 if ( KOPrefs::instance()->mWriteBackFile )
1199 { 1214 {
1200 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1215 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1201 Incidence* inc = iL.first(); 1216 Incidence* inc = iL.first();
1202 /* obsolete 1217 /* obsolete
1203 while ( inc ) { 1218 while ( inc ) {
1204 inc->setZaurusStat( inc->revision () ); 1219 inc->setZaurusStat( inc->revision () );
1205 inc = iL.next(); 1220 inc = iL.next();
1206 } 1221 }
1207 */ 1222 */
1208 // pending: clean last sync event description 1223#ifndef DESKTOP_VERSION
1209 sharpFormat.save(calendar); 1224 if ( sharpFormat )
1225 sharpFormat->save(calendar);
1226#endif
1227 if ( phoneFormat )
1228 phoneFormat->save(calendar);
1210 iL = calendar->rawIncidences(); 1229 iL = calendar->rawIncidences();
1211 inc = iL.first(); 1230 inc = iL.first();
1212 Incidence* loc; 1231 Incidence* loc;
1213 while ( inc ) { 1232 while ( inc ) {
1214 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1233 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1215 loc = mCalendar->incidence(inc->uid() ); 1234 loc = mCalendar->incidence(inc->uid() );
1216 if ( loc ) { 1235 if ( loc ) {
1217 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1236 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1218 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1237 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1219 } 1238 }
1220 } 1239 }
1221 inc = iL.next(); 1240 inc = iL.next();
@@ -1229,25 +1248,30 @@ void CalendarView::syncSharp()
1229 } 1248 }
1230 } 1249 }
1231 setModified( true ); 1250 setModified( true );
1232 } else { 1251 } else {
1233 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1252 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1234 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1253 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1235 question, i18n("Ok")) ; 1254 question, i18n("Ok")) ;
1236 1255
1237 } 1256 }
1238 delete calendar; 1257 delete calendar;
1239 updateView(); 1258 updateView();
1240 return ;//syncOK; 1259 return ;//syncOK;
1241#endif 1260
1261}
1262void CalendarView::syncSharp()
1263{
1264 syncExternal( 0 );
1265
1242} 1266}
1243 1267
1244 1268
1245#include <kabc/stdaddressbook.h> 1269#include <kabc/stdaddressbook.h>
1246bool CalendarView::importBday() 1270bool CalendarView::importBday()
1247{ 1271{
1248 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1272 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1249 KABC::AddressBook::Iterator it; 1273 KABC::AddressBook::Iterator it;
1250 int count = 0; 1274 int count = 0;
1251 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1275 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1252 ++count; 1276 ++count;
1253 } 1277 }