summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 720ad78..7c7466b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -149,55 +149,55 @@ MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Inciden
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 //mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->type() == "Event" ) { 173 if ( inc->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->type() == "Todo" ) { 175 } else if ( inc->typeID() == todoID ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->type() == "Todo" ) 179 if ( inc->typeID() == todoID )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() < QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
@@ -952,54 +952,54 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
952 } else { 952 } else {
953 //qDebug(" not loc changed "); 953 //qDebug(" not loc changed ");
954 lastSync = localMod.addDays( 1 ); 954 lastSync = localMod.addDays( 1 );
955 if ( remCh ) 955 if ( remCh )
956 remoteMod =( lastSync.addDays( 1 ) ); 956 remoteMod =( lastSync.addDays( 1 ) );
957 957
958 } 958 }
959 } 959 }
960 full = true; 960 full = true;
961 if ( mode < SYNC_PREF_ASK ) 961 if ( mode < SYNC_PREF_ASK )
962 mode = SYNC_PREF_ASK; 962 mode = SYNC_PREF_ASK;
963 } else { 963 } else {
964 if ( localMod == remoteMod ) 964 if ( localMod == remoteMod )
965 // if ( local->revision() == remote->revision() ) 965 // if ( local->revision() == remote->revision() )
966 return 0; 966 return 0;
967 967
968 } 968 }
969 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 969 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
970 970
971 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 971 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
972 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 972 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
973 //full = true; //debug only 973 //full = true; //debug only
974 if ( full ) { 974 if ( full ) {
975 bool equ = false; 975 bool equ = false;
976 if ( local->type() == "Event" ) { 976 if ( local->typeID() == eventID ) {
977 equ = (*((Event*) local) == *((Event*) remote)); 977 equ = (*((Event*) local) == *((Event*) remote));
978 } 978 }
979 else if ( local->type() =="Todo" ) 979 else if ( local->typeID() == todoID )
980 equ = (*((Todo*) local) == (*(Todo*) remote)); 980 equ = (*((Todo*) local) == (*(Todo*) remote));
981 else if ( local->type() =="Journal" ) 981 else if ( local->typeID() == journalID )
982 equ = (*((Journal*) local) == *((Journal*) remote)); 982 equ = (*((Journal*) local) == *((Journal*) remote));
983 if ( equ ) { 983 if ( equ ) {
984 //qDebug("equal "); 984 //qDebug("equal ");
985 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 985 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
986 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 986 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
987 } 987 }
988 if ( mode < SYNC_PREF_FORCE_LOCAL ) 988 if ( mode < SYNC_PREF_FORCE_LOCAL )
989 return 0; 989 return 0;
990 990
991 }//else //debug only 991 }//else //debug only
992 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 992 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
993 } 993 }
994 int result; 994 int result;
995 bool localIsNew; 995 bool localIsNew;
996 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 996 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
997 997
998 998
999 // ************************************************ 999 // ************************************************
1000 // ************************************************ 1000 // ************************************************
1001 // ************************************************ 1001 // ************************************************
1002 // We may have that lastSync > remoteMod AND lastSync > localMod 1002 // We may have that lastSync > remoteMod AND lastSync > localMod
1003 // BUT remoteMod != localMod 1003 // BUT remoteMod != localMod
1004 1004
1005 1005
@@ -1078,59 +1078,59 @@ Event* CalendarView::getLastSyncEvent()
1078 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1078 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1079 QString sum = ""; 1079 QString sum = "";
1080 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1080 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1081 sum = "E: "; 1081 sum = "E: ";
1082 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1082 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1083 lse->setDtStart( mLastCalendarSync ); 1083 lse->setDtStart( mLastCalendarSync );
1084 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1084 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1085 lse->setCategories( i18n("SyncEvent") ); 1085 lse->setCategories( i18n("SyncEvent") );
1086 lse->setReadOnly( true ); 1086 lse->setReadOnly( true );
1087 mCalendar->addEvent( lse ); 1087 mCalendar->addEvent( lse );
1088 } 1088 }
1089 1089
1090 return lse; 1090 return lse;
1091 1091
1092} 1092}
1093 1093
1094// we check, if the to delete event has a id for a profile 1094// we check, if the to delete event has a id for a profile
1095// if yes, we set this id in the profile to delete 1095// if yes, we set this id in the profile to delete
1096void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1096void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1097{ 1097{
1098 if ( lastSync.count() == 0 ) { 1098 if ( lastSync.count() == 0 ) {
1099 //qDebug(" lastSync.count() == 0"); 1099 //qDebug(" lastSync.count() == 0");
1100 return; 1100 return;
1101 } 1101 }
1102 if ( toDelete->type() == "Journal" ) 1102 if ( toDelete->typeID() == journalID )
1103 return; 1103 return;
1104 1104
1105 Event* eve = lastSync.first(); 1105 Event* eve = lastSync.first();
1106 1106
1107 while ( eve ) { 1107 while ( eve ) {
1108 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1108 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1109 if ( !id.isEmpty() ) { 1109 if ( !id.isEmpty() ) {
1110 QString des = eve->description(); 1110 QString des = eve->description();
1111 QString pref = "e"; 1111 QString pref = "e";
1112 if ( toDelete->type() == "Todo" ) 1112 if ( toDelete->typeID() == todoID )
1113 pref = "t"; 1113 pref = "t";
1114 des += pref+ id + ","; 1114 des += pref+ id + ",";
1115 eve->setReadOnly( false ); 1115 eve->setReadOnly( false );
1116 eve->setDescription( des ); 1116 eve->setDescription( des );
1117 //qDebug("setdes %s ", des.latin1()); 1117 //qDebug("setdes %s ", des.latin1());
1118 eve->setReadOnly( true ); 1118 eve->setReadOnly( true );
1119 } 1119 }
1120 eve = lastSync.next(); 1120 eve = lastSync.next();
1121 } 1121 }
1122 1122
1123} 1123}
1124void CalendarView::checkExternalId( Incidence * inc ) 1124void CalendarView::checkExternalId( Incidence * inc )
1125{ 1125{
1126 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1126 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1127 checkExternSyncEvent( lastSync, inc ); 1127 checkExternSyncEvent( lastSync, inc );
1128 1128
1129} 1129}
1130bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1130bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1131{ 1131{
1132 bool syncOK = true; 1132 bool syncOK = true;
1133 int addedEvent = 0; 1133 int addedEvent = 0;
1134 int addedEventR = 0; 1134 int addedEventR = 0;
1135 int deletedEventR = 0; 1135 int deletedEventR = 0;
1136 int deletedEventL = 0; 1136 int deletedEventL = 0;
@@ -1265,49 +1265,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1265 if ( mSyncManager->syncWithDesktop() ) 1265 if ( mSyncManager->syncWithDesktop() )
1266 inR->setPilotId( 2 ); 1266 inR->setPilotId( 2 );
1267 ++changedRemote; 1267 ++changedRemote;
1268 } else {// take remote ********************** 1268 } else {// take remote **********************
1269 idS = inL->IDStr(); 1269 idS = inL->IDStr();
1270 int pid = inL->pilotId(); 1270 int pid = inL->pilotId();
1271 local->deleteIncidence( inL ); 1271 local->deleteIncidence( inL );
1272 inL = inR->clone(); 1272 inL = inR->clone();
1273 if ( mSyncManager->syncWithDesktop() ) 1273 if ( mSyncManager->syncWithDesktop() )
1274 inL->setPilotId( pid ); 1274 inL->setPilotId( pid );
1275 inL->setIDStr( idS ); 1275 inL->setIDStr( idS );
1276 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1276 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1277 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1277 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1278 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1278 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1279 } 1279 }
1280 local->addIncidence( inL ); 1280 local->addIncidence( inL );
1281 ++changedLocal; 1281 ++changedLocal;
1282 } 1282 }
1283 } 1283 }
1284 } else { // no conflict ********** add or delete remote 1284 } else { // no conflict ********** add or delete remote
1285 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1285 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1286 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1286 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1287 QString des = eventLSync->description(); 1287 QString des = eventLSync->description();
1288 QString pref = "e"; 1288 QString pref = "e";
1289 if ( inR->type() == "Todo" ) 1289 if ( inR->typeID() == todoID )
1290 pref = "t"; 1290 pref = "t";
1291 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1291 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1292 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1292 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1293 //remote->deleteIncidence( inR ); 1293 //remote->deleteIncidence( inR );
1294 ++deletedEventR; 1294 ++deletedEventR;
1295 } else { 1295 } else {
1296 inR->setLastModified( modifiedCalendar ); 1296 inR->setLastModified( modifiedCalendar );
1297 inL = inR->clone(); 1297 inL = inR->clone();
1298 inL->setIDStr( ":" ); 1298 inL->setIDStr( ":" );
1299 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1299 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1300 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1300 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1301 local->addIncidence( inL ); 1301 local->addIncidence( inL );
1302 ++addedEvent; 1302 ++addedEvent;
1303 1303
1304 } 1304 }
1305 } else { 1305 } else {
1306 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1306 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1307 inR->setLastModified( modifiedCalendar ); 1307 inR->setLastModified( modifiedCalendar );
1308 inL = inR->clone(); 1308 inL = inR->clone();
1309 inL->setIDStr( ":" ); 1309 inL->setIDStr( ":" );
1310 local->addIncidence( inL ); 1310 local->addIncidence( inL );
1311 ++addedEvent; 1311 ++addedEvent;
1312 1312
1313 } else { 1313 } else {
@@ -1322,49 +1322,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1322 } 1322 }
1323 } 1323 }
1324 inR = er.next(); 1324 inR = er.next();
1325 } 1325 }
1326 QPtrList<Incidence> el = local->rawIncidences(); 1326 QPtrList<Incidence> el = local->rawIncidences();
1327 inL = el.first(); 1327 inL = el.first();
1328 modulo = (el.count()/10)+1; 1328 modulo = (el.count()/10)+1;
1329 bar.setCaption (i18n("Add / remove events") ); 1329 bar.setCaption (i18n("Add / remove events") );
1330 bar.setTotalSteps ( el.count() ) ; 1330 bar.setTotalSteps ( el.count() ) ;
1331 bar.show(); 1331 bar.show();
1332 incCounter = 0; 1332 incCounter = 0;
1333 1333
1334 while ( inL ) { 1334 while ( inL ) {
1335 1335
1336 qApp->processEvents(); 1336 qApp->processEvents();
1337 if ( ! bar.isVisible() ) 1337 if ( ! bar.isVisible() )
1338 return false; 1338 return false;
1339 if ( incCounter % modulo == 0 ) 1339 if ( incCounter % modulo == 0 )
1340 bar.setProgress( incCounter ); 1340 bar.setProgress( incCounter );
1341 ++incCounter; 1341 ++incCounter;
1342 uid = inL->uid(); 1342 uid = inL->uid();
1343 bool skipIncidence = false; 1343 bool skipIncidence = false;
1344 if ( uid.left(15) == QString("last-syncEvent-") ) 1344 if ( uid.left(15) == QString("last-syncEvent-") )
1345 skipIncidence = true; 1345 skipIncidence = true;
1346 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1346 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1347 skipIncidence = true; 1347 skipIncidence = true;
1348 if ( !skipIncidence ) { 1348 if ( !skipIncidence ) {
1349 inR = remote->incidence( uid ); 1349 inR = remote->incidence( uid );
1350 if ( ! inR ) { 1350 if ( ! inR ) {
1351 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1351 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1352 // no conflict ********** add or delete local 1352 // no conflict ********** add or delete local
1353 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1353 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1354 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1354 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1355 checkExternSyncEvent(eventLSyncSharp, inL); 1355 checkExternSyncEvent(eventLSyncSharp, inL);
1356 local->deleteIncidence( inL ); 1356 local->deleteIncidence( inL );
1357 ++deletedEventL; 1357 ++deletedEventL;
1358 } else { 1358 } else {
1359 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1359 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1360 inL->removeID(mCurrentSyncDevice ); 1360 inL->removeID(mCurrentSyncDevice );
1361 ++addedEventR; 1361 ++addedEventR;
1362 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1362 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1363 inL->setLastModified( modifiedCalendar ); 1363 inL->setLastModified( modifiedCalendar );
1364 inR = inL->clone(); 1364 inR = inL->clone();
1365 inR->setIDStr( ":" ); 1365 inR->setIDStr( ":" );
1366 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1366 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1367 remote->addIncidence( inR ); 1367 remote->addIncidence( inR );
1368 } 1368 }
1369 } 1369 }
1370 } else { 1370 } else {
@@ -1378,56 +1378,56 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1378 inL->setLastModified( modifiedCalendar ); 1378 inL->setLastModified( modifiedCalendar );
1379 inR = inL->clone(); 1379 inR = inL->clone();
1380 inR->setIDStr( ":" ); 1380 inR->setIDStr( ":" );
1381 remote->addIncidence( inR ); 1381 remote->addIncidence( inR );
1382 } 1382 }
1383 } 1383 }
1384 } 1384 }
1385 } else { 1385 } else {
1386 ++filteredOUT; 1386 ++filteredOUT;
1387 } 1387 }
1388 } 1388 }
1389 } 1389 }
1390 inL = el.next(); 1390 inL = el.next();
1391 } 1391 }
1392 int delFut = 0; 1392 int delFut = 0;
1393 int remRem = 0; 1393 int remRem = 0;
1394 if ( mSyncManager->mWriteBackInFuture ) { 1394 if ( mSyncManager->mWriteBackInFuture ) {
1395 er = remote->rawIncidences(); 1395 er = remote->rawIncidences();
1396 remRem = er.count(); 1396 remRem = er.count();
1397 inR = er.first(); 1397 inR = er.first();
1398 QDateTime dt; 1398 QDateTime dt;
1399 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1399 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1400 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1400 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1401 while ( inR ) { 1401 while ( inR ) {
1402 if ( inR->type() == "Todo" ) { 1402 if ( inR->typeID() == todoID ) {
1403 Todo * t = (Todo*)inR; 1403 Todo * t = (Todo*)inR;
1404 if ( t->hasDueDate() ) 1404 if ( t->hasDueDate() )
1405 dt = t->dtDue(); 1405 dt = t->dtDue();
1406 else 1406 else
1407 dt = cur.addSecs( 62 ); 1407 dt = cur.addSecs( 62 );
1408 } 1408 }
1409 else if (inR->type() == "Event" ) { 1409 else if (inR->typeID() == eventID ) {
1410 bool ok; 1410 bool ok;
1411 dt = inR->getNextOccurence( cur, &ok ); 1411 dt = inR->getNextOccurence( cur, &ok );
1412 if ( !ok ) 1412 if ( !ok )
1413 dt = cur.addSecs( -62 ); 1413 dt = cur.addSecs( -62 );
1414 } 1414 }
1415 else 1415 else
1416 dt = inR->dtStart(); 1416 dt = inR->dtStart();
1417 if ( dt < cur || dt > end ) { 1417 if ( dt < cur || dt > end ) {
1418 remote->deleteIncidence( inR ); 1418 remote->deleteIncidence( inR );
1419 ++delFut; 1419 ++delFut;
1420 } 1420 }
1421 inR = er.next(); 1421 inR = er.next();
1422 } 1422 }
1423 } 1423 }
1424 bar.hide(); 1424 bar.hide();
1425 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1425 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1426 eventLSync->setReadOnly( false ); 1426 eventLSync->setReadOnly( false );
1427 eventLSync->setDtStart( mLastCalendarSync ); 1427 eventLSync->setDtStart( mLastCalendarSync );
1428 eventRSync->setDtStart( mLastCalendarSync ); 1428 eventRSync->setDtStart( mLastCalendarSync );
1429 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1429 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1430 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1430 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1431 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1431 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1432 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1432 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1433 eventLSync->setReadOnly( true ); 1433 eventLSync->setReadOnly( true );
@@ -2456,70 +2456,70 @@ void CalendarView::updateView()
2456 // We assume that the navigator only selects consecutive days. 2456 // We assume that the navigator only selects consecutive days.
2457 updateView( tmpList.first(), tmpList.last() ); 2457 updateView( tmpList.first(), tmpList.last() );
2458} 2458}
2459 2459
2460void CalendarView::updateUnmanagedViews() 2460void CalendarView::updateUnmanagedViews()
2461{ 2461{
2462 mDateNavigator->updateDayMatrix(); 2462 mDateNavigator->updateDayMatrix();
2463} 2463}
2464 2464
2465int CalendarView::msgItemDelete(const QString name) 2465int CalendarView::msgItemDelete(const QString name)
2466{ 2466{
2467 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2467 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2468 i18n("This item will be\npermanently deleted."), 2468 i18n("This item will be\npermanently deleted."),
2469 i18n("KO/Pi Confirmation"),i18n("Delete")); 2469 i18n("KO/Pi Confirmation"),i18n("Delete"));
2470} 2470}
2471 2471
2472 2472
2473void CalendarView::edit_cut() 2473void CalendarView::edit_cut()
2474{ 2474{
2475 Event *anEvent=0; 2475 Event *anEvent=0;
2476 2476
2477 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2477 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2478 2478
2479 if (mViewManager->currentView()->isEventView()) { 2479 if (mViewManager->currentView()->isEventView()) {
2480 if ( incidence && incidence->type() == "Event" ) { 2480 if ( incidence && incidence->typeID() == eventID ) {
2481 anEvent = static_cast<Event *>(incidence); 2481 anEvent = static_cast<Event *>(incidence);
2482 } 2482 }
2483 } 2483 }
2484 2484
2485 if (!anEvent) { 2485 if (!anEvent) {
2486 KNotifyClient::beep(); 2486 KNotifyClient::beep();
2487 return; 2487 return;
2488 } 2488 }
2489 DndFactory factory( mCalendar ); 2489 DndFactory factory( mCalendar );
2490 factory.cutIncidence(anEvent); 2490 factory.cutIncidence(anEvent);
2491 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2491 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2492} 2492}
2493 2493
2494void CalendarView::edit_copy() 2494void CalendarView::edit_copy()
2495{ 2495{
2496 Event *anEvent=0; 2496 Event *anEvent=0;
2497 2497
2498 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2498 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2499 2499
2500 if (mViewManager->currentView()->isEventView()) { 2500 if (mViewManager->currentView()->isEventView()) {
2501 if ( incidence && incidence->type() == "Event" ) { 2501 if ( incidence && incidence->typeID() == eventID ) {
2502 anEvent = static_cast<Event *>(incidence); 2502 anEvent = static_cast<Event *>(incidence);
2503 } 2503 }
2504 } 2504 }
2505 2505
2506 if (!anEvent) { 2506 if (!anEvent) {
2507 KNotifyClient::beep(); 2507 KNotifyClient::beep();
2508 return; 2508 return;
2509 } 2509 }
2510 DndFactory factory( mCalendar ); 2510 DndFactory factory( mCalendar );
2511 factory.copyIncidence(anEvent); 2511 factory.copyIncidence(anEvent);
2512} 2512}
2513 2513
2514void CalendarView::edit_paste() 2514void CalendarView::edit_paste()
2515{ 2515{
2516 QDate date = mNavigator->selectedDates().first(); 2516 QDate date = mNavigator->selectedDates().first();
2517 2517
2518 DndFactory factory( mCalendar ); 2518 DndFactory factory( mCalendar );
2519 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2519 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2520 2520
2521 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2521 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2522} 2522}
2523 2523
2524void CalendarView::edit_options() 2524void CalendarView::edit_options()
2525{ 2525{
@@ -2529,80 +2529,80 @@ void CalendarView::edit_options()
2529 mDialogManager->showOptionsDialog(); 2529 mDialogManager->showOptionsDialog();
2530 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2530 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2531 emit saveStopTimer(); 2531 emit saveStopTimer();
2532 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2532 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2533 i18n("Timezone settings"),i18n("Reload"))) { 2533 i18n("Timezone settings"),i18n("Reload"))) {
2534 qDebug("KO: TZ reload cancelled "); 2534 qDebug("KO: TZ reload cancelled ");
2535 return; 2535 return;
2536 } 2536 }
2537 qDebug("KO: Timezone change "); 2537 qDebug("KO: Timezone change ");
2538 openCalendar( MainWindow::defaultFileName() ); 2538 openCalendar( MainWindow::defaultFileName() );
2539 setModified(true); 2539 setModified(true);
2540 } 2540 }
2541 else 2541 else
2542 qDebug("KO: No tz change "); 2542 qDebug("KO: No tz change ");
2543 2543
2544} 2544}
2545 2545
2546 2546
2547void CalendarView::slotSelectPickerDate( QDate d) 2547void CalendarView::slotSelectPickerDate( QDate d)
2548{ 2548{
2549 mDateFrame->hide(); 2549 mDateFrame->hide();
2550 if ( mDatePickerMode == 1 ) { 2550 if ( mDatePickerMode == 1 ) {
2551 mNavigator->slotDaySelect( d ); 2551 mNavigator->slotDaySelect( d );
2552 } else if ( mDatePickerMode == 2 ) { 2552 } else if ( mDatePickerMode == 2 ) {
2553 if ( mMoveIncidence->type() == "Todo" ) { 2553 if ( mMoveIncidence->typeID() == todoID ) {
2554 Todo * to = (Todo *) mMoveIncidence; 2554 Todo * to = (Todo *) mMoveIncidence;
2555 QTime tim; 2555 QTime tim;
2556 int len = 0; 2556 int len = 0;
2557 if ( to->hasStartDate() && to->hasDueDate() ) 2557 if ( to->hasStartDate() && to->hasDueDate() )
2558 len = to->dtStart().secsTo( to->dtDue()); 2558 len = to->dtStart().secsTo( to->dtDue());
2559 if ( to->hasDueDate() ) 2559 if ( to->hasDueDate() )
2560 tim = to->dtDue().time(); 2560 tim = to->dtDue().time();
2561 else { 2561 else {
2562 tim = QTime ( 0,0,0 ); 2562 tim = QTime ( 0,0,0 );
2563 to->setFloats( true ); 2563 to->setFloats( true );
2564 to->setHasDueDate( true ); 2564 to->setHasDueDate( true );
2565 } 2565 }
2566 QDateTime dt ( d,tim ); 2566 QDateTime dt ( d,tim );
2567 to->setDtDue( dt ); 2567 to->setDtDue( dt );
2568 2568
2569 if ( to->hasStartDate() ) { 2569 if ( to->hasStartDate() ) {
2570 if ( len>0 ) 2570 if ( len>0 )
2571 to->setDtStart(to->dtDue().addSecs( -len )); 2571 to->setDtStart(to->dtDue().addSecs( -len ));
2572 else 2572 else
2573 if (to->dtStart() > to->dtDue() ) 2573 if (to->dtStart() > to->dtDue() )
2574 to->setDtStart(to->dtDue().addDays( -3 )); 2574 to->setDtStart(to->dtDue().addDays( -3 ));
2575 } 2575 }
2576 2576
2577 todoChanged( to ); 2577 todoChanged( to );
2578 } else { 2578 } else {
2579 if ( mMoveIncidence->doesRecur() ) { 2579 if ( mMoveIncidence->doesRecur() ) {
2580#if 0 2580#if 0
2581 // PENDING implement this 2581 // PENDING implement this
2582 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2582 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2583 mCalendar()->addIncidence( newInc ); 2583 mCalendar()->addIncidence( newInc );
2584 if ( mMoveIncidence->type() == "Todo" ) 2584 if ( mMoveIncidence->typeID() == todoID )
2585 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2585 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2586 else 2586 else
2587 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2587 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2588 mMoveIncidence = newInc; 2588 mMoveIncidence = newInc;
2589 2589
2590#endif 2590#endif
2591 } 2591 }
2592 QTime tim = mMoveIncidence->dtStart().time(); 2592 QTime tim = mMoveIncidence->dtStart().time();
2593 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2593 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2594 QDateTime dt ( d,tim ); 2594 QDateTime dt ( d,tim );
2595 mMoveIncidence->setDtStart( dt ); 2595 mMoveIncidence->setDtStart( dt );
2596 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2596 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2597 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2597 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2598 } 2598 }
2599 2599
2600 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2600 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2601 } 2601 }
2602} 2602}
2603 2603
2604void CalendarView::removeCategories() 2604void CalendarView::removeCategories()
2605{ 2605{
2606 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2606 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2607 QStringList catList = KOPrefs::instance()->mCustomCategories; 2607 QStringList catList = KOPrefs::instance()->mCustomCategories;
2608 QStringList catIncList; 2608 QStringList catIncList;
@@ -2746,49 +2746,49 @@ void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2746 KApplication::convert2latin1( fn ); 2746 KApplication::convert2latin1( fn );
2747#ifndef DESKTOP_VERSION 2747#ifndef DESKTOP_VERSION
2748 Ir *ir = new Ir( this ); 2748 Ir *ir = new Ir( this );
2749 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2749 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2750 ir->send( fn, description, "text/x-vCalendar" ); 2750 ir->send( fn, description, "text/x-vCalendar" );
2751#endif 2751#endif
2752 } 2752 }
2753} 2753}
2754void CalendarView::beamDone( Ir *ir ) 2754void CalendarView::beamDone( Ir *ir )
2755{ 2755{
2756#ifndef DESKTOP_VERSION 2756#ifndef DESKTOP_VERSION
2757 delete ir; 2757 delete ir;
2758#endif 2758#endif
2759 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2759 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2760 topLevelWidget()->raise(); 2760 topLevelWidget()->raise();
2761} 2761}
2762 2762
2763void CalendarView::moveIncidence(Incidence * inc ) 2763void CalendarView::moveIncidence(Incidence * inc )
2764{ 2764{
2765 if ( !inc ) return; 2765 if ( !inc ) return;
2766 showDatePickerPopup(); 2766 showDatePickerPopup();
2767 mDatePickerMode = 2; 2767 mDatePickerMode = 2;
2768 mMoveIncidence = inc ; 2768 mMoveIncidence = inc ;
2769 QDate da; 2769 QDate da;
2770 if ( mMoveIncidence->type() == "Todo" ) { 2770 if ( mMoveIncidence->typeID() == todoID ) {
2771 Todo * to = (Todo *) mMoveIncidence; 2771 Todo * to = (Todo *) mMoveIncidence;
2772 if ( to->hasDueDate() ) 2772 if ( to->hasDueDate() )
2773 da = to->dtDue().date(); 2773 da = to->dtDue().date();
2774 else 2774 else
2775 da = QDate::currentDate(); 2775 da = QDate::currentDate();
2776 } else { 2776 } else {
2777 da = mMoveIncidence->dtStart().date(); 2777 da = mMoveIncidence->dtStart().date();
2778 } 2778 }
2779 //PENDING set date for recurring incidence to date of recurrence 2779 //PENDING set date for recurring incidence to date of recurrence
2780 //mMoveIncidenceOldDate; 2780 //mMoveIncidenceOldDate;
2781 mDatePicker->setDate( da ); 2781 mDatePicker->setDate( da );
2782} 2782}
2783void CalendarView::showDatePickerPopup() 2783void CalendarView::showDatePickerPopup()
2784{ 2784{
2785 if ( mDateFrame->isVisible() ) 2785 if ( mDateFrame->isVisible() )
2786 mDateFrame->hide(); 2786 mDateFrame->hide();
2787 else { 2787 else {
2788 int offX = 0, offY = 0; 2788 int offX = 0, offY = 0;
2789#ifdef DESKTOP_VERSION 2789#ifdef DESKTOP_VERSION
2790 int w =mDatePicker->sizeHint().width() ; 2790 int w =mDatePicker->sizeHint().width() ;
2791 int h = mDatePicker->sizeHint().height() ; 2791 int h = mDatePicker->sizeHint().height() ;
2792 int dw = topLevelWidget()->width(); 2792 int dw = topLevelWidget()->width();
2793 int dh = topLevelWidget()->height(); 2793 int dh = topLevelWidget()->height();
2794 offX = topLevelWidget()->x(); 2794 offX = topLevelWidget()->x();
@@ -2879,49 +2879,49 @@ void CalendarView::beamIncidence()
2879 beamIncidence(incidence); 2879 beamIncidence(incidence);
2880 } 2880 }
2881} 2881}
2882void CalendarView::toggleCancelIncidence() 2882void CalendarView::toggleCancelIncidence()
2883{ 2883{
2884 Incidence *incidence = currentSelection(); 2884 Incidence *incidence = currentSelection();
2885 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2885 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2886 if ( incidence ) { 2886 if ( incidence ) {
2887 cancelIncidence(incidence); 2887 cancelIncidence(incidence);
2888 } 2888 }
2889} 2889}
2890 2890
2891 2891
2892void CalendarView::cancelIncidence(Incidence * inc ) 2892void CalendarView::cancelIncidence(Incidence * inc )
2893{ 2893{
2894 inc->setCancelled( ! inc->cancelled() ); 2894 inc->setCancelled( ! inc->cancelled() );
2895 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2895 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2896 updateView(); 2896 updateView();
2897} 2897}
2898void CalendarView::cloneIncidence(Incidence * orgInc ) 2898void CalendarView::cloneIncidence(Incidence * orgInc )
2899{ 2899{
2900 Incidence * newInc = orgInc->clone(); 2900 Incidence * newInc = orgInc->clone();
2901 newInc->recreate(); 2901 newInc->recreate();
2902 2902
2903 if ( newInc->type() == "Todo" ) { 2903 if ( newInc->typeID() == todoID ) {
2904 Todo* t = (Todo*) newInc; 2904 Todo* t = (Todo*) newInc;
2905 bool cloneSub = false; 2905 bool cloneSub = false;
2906 if ( orgInc->relations().count() ) { 2906 if ( orgInc->relations().count() ) {
2907 int result = KMessageBox::warningYesNoCancel(this, 2907 int result = KMessageBox::warningYesNoCancel(this,
2908 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 2908 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2909 i18n("Todo has subtodos"), 2909 i18n("Todo has subtodos"),
2910 i18n("Yes"), 2910 i18n("Yes"),
2911 i18n("No")); 2911 i18n("No"));
2912 2912
2913 if ( result == KMessageBox::Cancel ) { 2913 if ( result == KMessageBox::Cancel ) {
2914 delete t; 2914 delete t;
2915 return; 2915 return;
2916 } 2916 }
2917 if (result == KMessageBox::Yes) cloneSub = true; 2917 if (result == KMessageBox::Yes) cloneSub = true;
2918 } 2918 }
2919 showTodoEditor(); 2919 showTodoEditor();
2920 mTodoEditor->editTodo( t ); 2920 mTodoEditor->editTodo( t );
2921 if ( mTodoEditor->exec() ) { 2921 if ( mTodoEditor->exec() ) {
2922 if ( cloneSub ) { 2922 if ( cloneSub ) {
2923 orgInc->cloneRelations( t ); 2923 orgInc->cloneRelations( t );
2924 mCalendar->addIncidenceBranch( t ); 2924 mCalendar->addIncidenceBranch( t );
2925 updateView(); 2925 updateView();
2926 2926
2927 } else { 2927 } else {
@@ -3143,89 +3143,89 @@ void CalendarView::showJournal( Journal *jour )
3143{ 3143{
3144 getEventViewerDialog()->setJournal(jour); 3144 getEventViewerDialog()->setJournal(jour);
3145 getEventViewerDialog()->showMe(); 3145 getEventViewerDialog()->showMe();
3146 3146
3147} 3147}
3148// void CalendarView::todoModified (Todo *event, int changed) 3148// void CalendarView::todoModified (Todo *event, int changed)
3149// { 3149// {
3150// // if (mDialogList.find (event) != mDialogList.end ()) { 3150// // if (mDialogList.find (event) != mDialogList.end ()) {
3151// // kdDebug() << "Todo modified and open" << endl; 3151// // kdDebug() << "Todo modified and open" << endl;
3152// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3152// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3153// // temp->modified (changed); 3153// // temp->modified (changed);
3154 3154
3155// // } 3155// // }
3156 3156
3157// mViewManager->updateView(); 3157// mViewManager->updateView();
3158// } 3158// }
3159 3159
3160void CalendarView::appointment_show() 3160void CalendarView::appointment_show()
3161{ 3161{
3162 Event *anEvent = 0; 3162 Event *anEvent = 0;
3163 3163
3164 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3164 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3165 3165
3166 if (mViewManager->currentView()->isEventView()) { 3166 if (mViewManager->currentView()->isEventView()) {
3167 if ( incidence && incidence->type() == "Event" ) { 3167 if ( incidence && incidence->typeID() == eventID ) {
3168 anEvent = static_cast<Event *>(incidence); 3168 anEvent = static_cast<Event *>(incidence);
3169 } 3169 }
3170 } 3170 }
3171 3171
3172 if (!anEvent) { 3172 if (!anEvent) {
3173 KNotifyClient::beep(); 3173 KNotifyClient::beep();
3174 return; 3174 return;
3175 } 3175 }
3176 3176
3177 showEvent(anEvent); 3177 showEvent(anEvent);
3178} 3178}
3179 3179
3180void CalendarView::appointment_edit() 3180void CalendarView::appointment_edit()
3181{ 3181{
3182 Event *anEvent = 0; 3182 Event *anEvent = 0;
3183 3183
3184 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3184 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3185 3185
3186 if (mViewManager->currentView()->isEventView()) { 3186 if (mViewManager->currentView()->isEventView()) {
3187 if ( incidence && incidence->type() == "Event" ) { 3187 if ( incidence && incidence->typeID() == eventID ) {
3188 anEvent = static_cast<Event *>(incidence); 3188 anEvent = static_cast<Event *>(incidence);
3189 } 3189 }
3190 } 3190 }
3191 3191
3192 if (!anEvent) { 3192 if (!anEvent) {
3193 KNotifyClient::beep(); 3193 KNotifyClient::beep();
3194 return; 3194 return;
3195 } 3195 }
3196 3196
3197 editEvent(anEvent); 3197 editEvent(anEvent);
3198} 3198}
3199 3199
3200void CalendarView::appointment_delete() 3200void CalendarView::appointment_delete()
3201{ 3201{
3202 Event *anEvent = 0; 3202 Event *anEvent = 0;
3203 3203
3204 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3204 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3205 3205
3206 if (mViewManager->currentView()->isEventView()) { 3206 if (mViewManager->currentView()->isEventView()) {
3207 if ( incidence && incidence->type() == "Event" ) { 3207 if ( incidence && incidence->typeID() == eventID ) {
3208 anEvent = static_cast<Event *>(incidence); 3208 anEvent = static_cast<Event *>(incidence);
3209 } 3209 }
3210 } 3210 }
3211 3211
3212 if (!anEvent) { 3212 if (!anEvent) {
3213 KNotifyClient::beep(); 3213 KNotifyClient::beep();
3214 return; 3214 return;
3215 } 3215 }
3216 3216
3217 deleteEvent(anEvent); 3217 deleteEvent(anEvent);
3218} 3218}
3219 3219
3220void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3220void CalendarView::todo_resub( Todo * parent, Todo * sub )
3221{ 3221{
3222 if (!sub) return; 3222 if (!sub) return;
3223 if ( sub->relatedTo() == parent ) 3223 if ( sub->relatedTo() == parent )
3224 return; 3224 return;
3225 sub->setRelatedTo(parent); 3225 sub->setRelatedTo(parent);
3226 sub->updated(); 3226 sub->updated();
3227 setModified(true); 3227 setModified(true);
3228 updateView(); 3228 updateView();
3229} 3229}
3230void CalendarView::todo_unsub(Todo *anTodo ) 3230void CalendarView::todo_unsub(Todo *anTodo )
3231{ 3231{
@@ -3384,97 +3384,97 @@ bool CalendarView::deleteEvent(const QString &uid)
3384} 3384}
3385 3385
3386/*****************************************************************************/ 3386/*****************************************************************************/
3387 3387
3388void CalendarView::action_mail() 3388void CalendarView::action_mail()
3389{ 3389{
3390#ifndef KORG_NOMAIL 3390#ifndef KORG_NOMAIL
3391 KOMailClient mailClient; 3391 KOMailClient mailClient;
3392 3392
3393 Incidence *incidence = currentSelection(); 3393 Incidence *incidence = currentSelection();
3394 3394
3395 if (!incidence) { 3395 if (!incidence) {
3396 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3396 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3397 return; 3397 return;
3398 } 3398 }
3399 if(incidence->attendeeCount() == 0 ) { 3399 if(incidence->attendeeCount() == 0 ) {
3400 KMessageBox::sorry(this, 3400 KMessageBox::sorry(this,
3401 i18n("Can't generate mail:\nNo attendees defined.\n")); 3401 i18n("Can't generate mail:\nNo attendees defined.\n"));
3402 return; 3402 return;
3403 } 3403 }
3404 3404
3405 CalendarLocal cal_tmp; 3405 CalendarLocal cal_tmp;
3406 Event *event = 0; 3406 Event *event = 0;
3407 Event *ev = 0; 3407 Event *ev = 0;
3408 if ( incidence && incidence->type() == "Event" ) { 3408 if ( incidence && incidence->typeID() == eventID ) {
3409 event = static_cast<Event *>(incidence); 3409 event = static_cast<Event *>(incidence);
3410 ev = new Event(*event); 3410 ev = new Event(*event);
3411 cal_tmp.addEvent(ev); 3411 cal_tmp.addEvent(ev);
3412 } 3412 }
3413 ICalFormat mForm(); 3413 ICalFormat mForm();
3414 QString attachment = mForm.toString( &cal_tmp ); 3414 QString attachment = mForm.toString( &cal_tmp );
3415 if (ev) delete(ev); 3415 if (ev) delete(ev);
3416 3416
3417 mailClient.mailAttendees(currentSelection(), attachment); 3417 mailClient.mailAttendees(currentSelection(), attachment);
3418 3418
3419#endif 3419#endif
3420 3420
3421#if 0 3421#if 0
3422 Event *anEvent = 0; 3422 Event *anEvent = 0;
3423 if (mViewManager->currentView()->isEventView()) { 3423 if (mViewManager->currentView()->isEventView()) {
3424 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3424 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3425 } 3425 }
3426 3426
3427 if (!anEvent) { 3427 if (!anEvent) {
3428 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3428 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3429 return; 3429 return;
3430 } 3430 }
3431 if(anEvent->attendeeCount() == 0 ) { 3431 if(anEvent->attendeeCount() == 0 ) {
3432 KMessageBox::sorry(this, 3432 KMessageBox::sorry(this,
3433 i18n("Can't generate mail:\nNo attendees defined.\n")); 3433 i18n("Can't generate mail:\nNo attendees defined.\n"));
3434 return; 3434 return;
3435 } 3435 }
3436 3436
3437 mailobject.emailEvent(anEvent); 3437 mailobject.emailEvent(anEvent);
3438#endif 3438#endif
3439} 3439}
3440 3440
3441 3441
3442void CalendarView::schedule_publish(Incidence *incidence) 3442void CalendarView::schedule_publish(Incidence *incidence)
3443{ 3443{
3444 Event *event = 0; 3444 Event *event = 0;
3445 Todo *todo = 0; 3445 Todo *todo = 0;
3446 3446
3447 if (incidence == 0) { 3447 if (incidence == 0) {
3448 incidence = mViewManager->currentView()->selectedIncidences().first(); 3448 incidence = mViewManager->currentView()->selectedIncidences().first();
3449 if (incidence == 0) { 3449 if (incidence == 0) {
3450 incidence = mTodoList->selectedIncidences().first(); 3450 incidence = mTodoList->selectedIncidences().first();
3451 } 3451 }
3452 } 3452 }
3453 if ( incidence && incidence->type() == "Event" ) { 3453 if ( incidence && incidence->typeID() == eventID ) {
3454 event = static_cast<Event *>(incidence); 3454 event = static_cast<Event *>(incidence);
3455 } else { 3455 } else {
3456 if ( incidence && incidence->type() == "Todo" ) { 3456 if ( incidence && incidence->typeID() == todoID ) {
3457 todo = static_cast<Todo *>(incidence); 3457 todo = static_cast<Todo *>(incidence);
3458 } 3458 }
3459 } 3459 }
3460 3460
3461 if (!event && !todo) { 3461 if (!event && !todo) {
3462 KMessageBox::sorry(this,i18n("No event selected.")); 3462 KMessageBox::sorry(this,i18n("No event selected."));
3463 return; 3463 return;
3464 } 3464 }
3465 3465
3466 PublishDialog *publishdlg = new PublishDialog(); 3466 PublishDialog *publishdlg = new PublishDialog();
3467 if (incidence->attendeeCount()>0) { 3467 if (incidence->attendeeCount()>0) {
3468 QPtrList<Attendee> attendees = incidence->attendees(); 3468 QPtrList<Attendee> attendees = incidence->attendees();
3469 attendees.first(); 3469 attendees.first();
3470 while ( attendees.current()!=0 ) { 3470 while ( attendees.current()!=0 ) {
3471 publishdlg->addAttendee(attendees.current()); 3471 publishdlg->addAttendee(attendees.current());
3472 attendees.next(); 3472 attendees.next();
3473 } 3473 }
3474 } 3474 }
3475 bool send = true; 3475 bool send = true;
3476 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3476 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3477 if ( publishdlg->exec() != QDialog::Accepted ) 3477 if ( publishdlg->exec() != QDialog::Accepted )
3478 send = false; 3478 send = false;
3479 } 3479 }
3480 if ( send ) { 3480 if ( send ) {
@@ -3544,52 +3544,52 @@ void CalendarView::schedule_publish_freebusy(int daysToPublish)
3544 freebusy->setOrganizer(KOPrefs::instance()->email()); 3544 freebusy->setOrganizer(KOPrefs::instance()->email());
3545 3545
3546 3546
3547 PublishDialog *publishdlg = new PublishDialog(); 3547 PublishDialog *publishdlg = new PublishDialog();
3548 if ( publishdlg->exec() == QDialog::Accepted ) { 3548 if ( publishdlg->exec() == QDialog::Accepted ) {
3549 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3549 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3550 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3550 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3551 delete(freebusy); 3551 delete(freebusy);
3552 } 3552 }
3553 } 3553 }
3554 delete publishdlg; 3554 delete publishdlg;
3555} 3555}
3556 3556
3557void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3557void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3558{ 3558{
3559 Event *event = 0; 3559 Event *event = 0;
3560 Todo *todo = 0; 3560 Todo *todo = 0;
3561 3561
3562 if (incidence == 0) { 3562 if (incidence == 0) {
3563 incidence = mViewManager->currentView()->selectedIncidences().first(); 3563 incidence = mViewManager->currentView()->selectedIncidences().first();
3564 if (incidence == 0) { 3564 if (incidence == 0) {
3565 incidence = mTodoList->selectedIncidences().first(); 3565 incidence = mTodoList->selectedIncidences().first();
3566 } 3566 }
3567 } 3567 }
3568 if ( incidence && incidence->type() == "Event" ) { 3568 if ( incidence && incidence->typeID() == eventID ) {
3569 event = static_cast<Event *>(incidence); 3569 event = static_cast<Event *>(incidence);
3570 } 3570 }
3571 if ( incidence && incidence->type() == "Todo" ) { 3571 if ( incidence && incidence->typeID() == todoID ) {
3572 todo = static_cast<Todo *>(incidence); 3572 todo = static_cast<Todo *>(incidence);
3573 } 3573 }
3574 3574
3575 if (!event && !todo) { 3575 if (!event && !todo) {
3576 KMessageBox::sorry(this,i18n("No event selected.")); 3576 KMessageBox::sorry(this,i18n("No event selected."));
3577 return; 3577 return;
3578 } 3578 }
3579 3579
3580 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3580 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3581 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3581 KMessageBox::sorry(this,i18n("The event has no attendees."));
3582 return; 3582 return;
3583 } 3583 }
3584 3584
3585 Event *ev = 0; 3585 Event *ev = 0;
3586 if (event) ev = new Event(*event); 3586 if (event) ev = new Event(*event);
3587 Todo *to = 0; 3587 Todo *to = 0;
3588 if (todo) to = new Todo(*todo); 3588 if (todo) to = new Todo(*todo);
3589 3589
3590 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3590 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3591 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3591 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3592 if (!me) { 3592 if (!me) {
3593 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3593 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3594 return; 3594 return;
3595 } 3595 }
@@ -3751,87 +3751,87 @@ void CalendarView::adaptNavigationUnits()
3751} 3751}
3752 3752
3753void CalendarView::processMainViewSelection( Incidence *incidence ) 3753void CalendarView::processMainViewSelection( Incidence *incidence )
3754{ 3754{
3755 if ( incidence ) mTodoList->clearSelection(); 3755 if ( incidence ) mTodoList->clearSelection();
3756 processIncidenceSelection( incidence ); 3756 processIncidenceSelection( incidence );
3757} 3757}
3758 3758
3759void CalendarView::processTodoListSelection( Incidence *incidence ) 3759void CalendarView::processTodoListSelection( Incidence *incidence )
3760{ 3760{
3761 if ( incidence && mViewManager->currentView() ) { 3761 if ( incidence && mViewManager->currentView() ) {
3762 mViewManager->currentView()->clearSelection(); 3762 mViewManager->currentView()->clearSelection();
3763 } 3763 }
3764 processIncidenceSelection( incidence ); 3764 processIncidenceSelection( incidence );
3765} 3765}
3766 3766
3767void CalendarView::processIncidenceSelection( Incidence *incidence ) 3767void CalendarView::processIncidenceSelection( Incidence *incidence )
3768{ 3768{
3769 if ( incidence == mSelectedIncidence ) return; 3769 if ( incidence == mSelectedIncidence ) return;
3770 3770
3771 mSelectedIncidence = incidence; 3771 mSelectedIncidence = incidence;
3772 3772
3773 emit incidenceSelected( mSelectedIncidence ); 3773 emit incidenceSelected( mSelectedIncidence );
3774 3774
3775 if ( incidence && incidence->type() == "Event" ) { 3775 if ( incidence && incidence->typeID() == eventID ) {
3776 Event *event = static_cast<Event *>( incidence ); 3776 Event *event = static_cast<Event *>( incidence );
3777 if ( event->organizer() == KOPrefs::instance()->email() ) { 3777 if ( event->organizer() == KOPrefs::instance()->email() ) {
3778 emit organizerEventsSelected( true ); 3778 emit organizerEventsSelected( true );
3779 } else { 3779 } else {
3780 emit organizerEventsSelected(false); 3780 emit organizerEventsSelected(false);
3781 } 3781 }
3782 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3782 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3783 KOPrefs::instance()->email() ) ) { 3783 KOPrefs::instance()->email() ) ) {
3784 emit groupEventsSelected( true ); 3784 emit groupEventsSelected( true );
3785 } else { 3785 } else {
3786 emit groupEventsSelected(false); 3786 emit groupEventsSelected(false);
3787 } 3787 }
3788 return; 3788 return;
3789 } else { 3789 } else {
3790 if ( incidence && incidence->type() == "Todo" ) { 3790 if ( incidence && incidence->typeID() == todoID ) {
3791 emit todoSelected( true ); 3791 emit todoSelected( true );
3792 Todo *event = static_cast<Todo *>( incidence ); 3792 Todo *event = static_cast<Todo *>( incidence );
3793 if ( event->organizer() == KOPrefs::instance()->email() ) { 3793 if ( event->organizer() == KOPrefs::instance()->email() ) {
3794 emit organizerEventsSelected( true ); 3794 emit organizerEventsSelected( true );
3795 } else { 3795 } else {
3796 emit organizerEventsSelected(false); 3796 emit organizerEventsSelected(false);
3797 } 3797 }
3798 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3798 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3799 KOPrefs::instance()->email() ) ) { 3799 KOPrefs::instance()->email() ) ) {
3800 emit groupEventsSelected( true ); 3800 emit groupEventsSelected( true );
3801 } else { 3801 } else {
3802 emit groupEventsSelected(false); 3802 emit groupEventsSelected(false);
3803 } 3803 }
3804 return; 3804 return;
3805 } else { 3805 } else {
3806 emit todoSelected( false ); 3806 emit todoSelected( false );
3807 emit organizerEventsSelected(false); 3807 emit organizerEventsSelected(false);
3808 emit groupEventsSelected(false); 3808 emit groupEventsSelected(false);
3809 } 3809 }
3810 return; 3810 return;
3811 } 3811 }
3812 3812
3813 /* if ( incidence && incidence->type() == "Todo" ) { 3813 /* if ( incidence && incidence->typeID() == todoID ) {
3814 emit todoSelected( true ); 3814 emit todoSelected( true );
3815 } else { 3815 } else {
3816 emit todoSelected( false ); 3816 emit todoSelected( false );
3817 }*/ 3817 }*/
3818} 3818}
3819 3819
3820 3820
3821void CalendarView::checkClipboard() 3821void CalendarView::checkClipboard()
3822{ 3822{
3823#ifndef KORG_NODND 3823#ifndef KORG_NODND
3824 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3824 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3825 emit pasteEnabled(true); 3825 emit pasteEnabled(true);
3826 } else { 3826 } else {
3827 emit pasteEnabled(false); 3827 emit pasteEnabled(false);
3828 } 3828 }
3829#endif 3829#endif
3830} 3830}
3831 3831
3832void CalendarView::showDates(const DateList &selectedDates) 3832void CalendarView::showDates(const DateList &selectedDates)
3833{ 3833{
3834 // kdDebug() << "CalendarView::selectDates()" << endl; 3834 // kdDebug() << "CalendarView::selectDates()" << endl;
3835 3835
3836 3836
3837 if ( !mBlockShowDates ) { 3837 if ( !mBlockShowDates ) {
@@ -4044,54 +4044,54 @@ void CalendarView::toggleExpand()
4044{ 4044{
4045 // if ( mLeftFrame->isHidden() ) { 4045 // if ( mLeftFrame->isHidden() ) {
4046 // mLeftFrame->show(); 4046 // mLeftFrame->show();
4047 // emit calendarViewExpanded( false ); 4047 // emit calendarViewExpanded( false );
4048 // } else { 4048 // } else {
4049 // mLeftFrame->hide(); 4049 // mLeftFrame->hide();
4050 // emit calendarViewExpanded( true ); 4050 // emit calendarViewExpanded( true );
4051 // } 4051 // }
4052 //qDebug(" CalendarView::toggleExpand()"); 4052 //qDebug(" CalendarView::toggleExpand()");
4053 globalFlagBlockAgenda = 1; 4053 globalFlagBlockAgenda = 1;
4054 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4054 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4055 globalFlagBlockAgenda = 5; 4055 globalFlagBlockAgenda = 5;
4056 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4056 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4057 //mViewManager->showView( 0, true ); 4057 //mViewManager->showView( 0, true );
4058} 4058}
4059 4059
4060void CalendarView::calendarModified( bool modified, Calendar * ) 4060void CalendarView::calendarModified( bool modified, Calendar * )
4061{ 4061{
4062 setModified( modified ); 4062 setModified( modified );
4063} 4063}
4064 4064
4065Todo *CalendarView::selectedTodo() 4065Todo *CalendarView::selectedTodo()
4066{ 4066{
4067 Incidence *incidence = currentSelection(); 4067 Incidence *incidence = currentSelection();
4068 if ( incidence && incidence->type() == "Todo" ) { 4068 if ( incidence && incidence->typeID() == todoID ) {
4069 return static_cast<Todo *>( incidence ); 4069 return static_cast<Todo *>( incidence );
4070 } 4070 }
4071 4071
4072 incidence = mTodoList->selectedIncidences().first(); 4072 incidence = mTodoList->selectedIncidences().first();
4073 if ( incidence && incidence->type() == "Todo" ) { 4073 if ( incidence && incidence->typeID() == todoID ) {
4074 return static_cast<Todo *>( incidence ); 4074 return static_cast<Todo *>( incidence );
4075 } 4075 }
4076 4076
4077 return 0; 4077 return 0;
4078} 4078}
4079 4079
4080void CalendarView::dialogClosing(Incidence *in) 4080void CalendarView::dialogClosing(Incidence *in)
4081{ 4081{
4082 // mDialogList.remove(in); 4082 // mDialogList.remove(in);
4083} 4083}
4084 4084
4085void CalendarView::showIncidence() 4085void CalendarView::showIncidence()
4086{ 4086{
4087 mViewerCallerIsSearchDialog = false; 4087 mViewerCallerIsSearchDialog = false;
4088 Incidence *incidence = currentSelection(); 4088 Incidence *incidence = currentSelection();
4089 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4089 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4090 if ( incidence ) { 4090 if ( incidence ) {
4091 ShowIncidenceVisitor v; 4091 ShowIncidenceVisitor v;
4092 v.act( incidence, this ); 4092 v.act( incidence, this );
4093 } 4093 }
4094} 4094}
4095void CalendarView::editIncidenceDescription() 4095void CalendarView::editIncidenceDescription()
4096{ 4096{
4097 mFlagEditDescription = true; 4097 mFlagEditDescription = true;