author | zautrix <zautrix> | 2005-03-25 15:07:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 15:07:31 (UTC) |
commit | 3326831dbf6f962e97a978781361db5198f6a035 (patch) (unidiff) | |
tree | 9bf6e78ba06b0db2e321ee8f8b95e66b66cca852 | |
parent | 5a0130ffdbf03fa5b881f856b41d081e91e1958b (diff) | |
download | kdepimpi-3326831dbf6f962e97a978781361db5198f6a035.zip kdepimpi-3326831dbf6f962e97a978781361db5198f6a035.tar.gz kdepimpi-3326831dbf6f962e97a978781361db5198f6a035.tar.bz2 |
layout fix
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 42 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.h | 2 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 3 |
4 files changed, 33 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9a4e719..6ed6a1c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1153,1544 +1153,1544 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1153 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1153 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1154 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1154 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1155 | checkExternSyncEvent(eventLSyncSharp, inL); | 1155 | checkExternSyncEvent(eventLSyncSharp, inL); |
1156 | local->deleteIncidence( inL ); | 1156 | local->deleteIncidence( inL ); |
1157 | ++deletedEventL; | 1157 | ++deletedEventL; |
1158 | } else { | 1158 | } else { |
1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1160 | inL->removeID(mCurrentSyncDevice ); | 1160 | inL->removeID(mCurrentSyncDevice ); |
1161 | ++addedEventR; | 1161 | ++addedEventR; |
1162 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1162 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1163 | inL->setLastModified( modifiedCalendar ); | 1163 | inL->setLastModified( modifiedCalendar ); |
1164 | inR = inL->clone(); | 1164 | inR = inL->clone(); |
1165 | inR->setIDStr( ":" ); | 1165 | inR->setIDStr( ":" ); |
1166 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1166 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1167 | remote->addIncidence( inR ); | 1167 | remote->addIncidence( inR ); |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | } else { | 1170 | } else { |
1171 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1171 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1172 | checkExternSyncEvent(eventLSyncSharp, inL); | 1172 | checkExternSyncEvent(eventLSyncSharp, inL); |
1173 | local->deleteIncidence( inL ); | 1173 | local->deleteIncidence( inL ); |
1174 | ++deletedEventL; | 1174 | ++deletedEventL; |
1175 | } else { | 1175 | } else { |
1176 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1176 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1177 | ++addedEventR; | 1177 | ++addedEventR; |
1178 | inL->setLastModified( modifiedCalendar ); | 1178 | inL->setLastModified( modifiedCalendar ); |
1179 | inR = inL->clone(); | 1179 | inR = inL->clone(); |
1180 | inR->setIDStr( ":" ); | 1180 | inR->setIDStr( ":" ); |
1181 | remote->addIncidence( inR ); | 1181 | remote->addIncidence( inR ); |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | } else { | 1185 | } else { |
1186 | ++filteredOUT; | 1186 | ++filteredOUT; |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | inL = el.next(); | 1190 | inL = el.next(); |
1191 | } | 1191 | } |
1192 | int delFut = 0; | 1192 | int delFut = 0; |
1193 | int remRem = 0; | 1193 | int remRem = 0; |
1194 | if ( mSyncManager->mWriteBackInFuture ) { | 1194 | if ( mSyncManager->mWriteBackInFuture ) { |
1195 | er = remote->rawIncidences(); | 1195 | er = remote->rawIncidences(); |
1196 | remRem = er.count(); | 1196 | remRem = er.count(); |
1197 | inR = er.first(); | 1197 | inR = er.first(); |
1198 | QDateTime dt; | 1198 | QDateTime dt; |
1199 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1199 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1200 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1200 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1201 | while ( inR ) { | 1201 | while ( inR ) { |
1202 | if ( inR->type() == "Todo" ) { | 1202 | if ( inR->type() == "Todo" ) { |
1203 | Todo * t = (Todo*)inR; | 1203 | Todo * t = (Todo*)inR; |
1204 | if ( t->hasDueDate() ) | 1204 | if ( t->hasDueDate() ) |
1205 | dt = t->dtDue(); | 1205 | dt = t->dtDue(); |
1206 | else | 1206 | else |
1207 | dt = cur.addSecs( 62 ); | 1207 | dt = cur.addSecs( 62 ); |
1208 | } | 1208 | } |
1209 | else if (inR->type() == "Event" ) { | 1209 | else if (inR->type() == "Event" ) { |
1210 | bool ok; | 1210 | bool ok; |
1211 | dt = inR->getNextOccurence( cur, &ok ); | 1211 | dt = inR->getNextOccurence( cur, &ok ); |
1212 | if ( !ok ) | 1212 | if ( !ok ) |
1213 | dt = cur.addSecs( -62 ); | 1213 | dt = cur.addSecs( -62 ); |
1214 | } | 1214 | } |
1215 | else | 1215 | else |
1216 | dt = inR->dtStart(); | 1216 | dt = inR->dtStart(); |
1217 | if ( dt < cur || dt > end ) { | 1217 | if ( dt < cur || dt > end ) { |
1218 | remote->deleteIncidence( inR ); | 1218 | remote->deleteIncidence( inR ); |
1219 | ++delFut; | 1219 | ++delFut; |
1220 | } | 1220 | } |
1221 | inR = er.next(); | 1221 | inR = er.next(); |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | bar.hide(); | 1224 | bar.hide(); |
1225 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1225 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1226 | eventLSync->setReadOnly( false ); | 1226 | eventLSync->setReadOnly( false ); |
1227 | eventLSync->setDtStart( mLastCalendarSync ); | 1227 | eventLSync->setDtStart( mLastCalendarSync ); |
1228 | eventRSync->setDtStart( mLastCalendarSync ); | 1228 | eventRSync->setDtStart( mLastCalendarSync ); |
1229 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1229 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1230 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1230 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1231 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1231 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1232 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1232 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1233 | eventLSync->setReadOnly( true ); | 1233 | eventLSync->setReadOnly( true ); |
1234 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1234 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1235 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1235 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1236 | remote->addEvent( eventRSync ); | 1236 | remote->addEvent( eventRSync ); |
1237 | else | 1237 | else |
1238 | delete eventRSync; | 1238 | delete eventRSync; |
1239 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1239 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1240 | QString mes; | 1240 | QString mes; |
1241 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1241 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1242 | QString delmess; | 1242 | QString delmess; |
1243 | if ( delFut ) { | 1243 | if ( delFut ) { |
1244 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1244 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1245 | mes += delmess; | 1245 | mes += delmess; |
1246 | } | 1246 | } |
1247 | mes = i18n("Local calendar changed!\n") +mes; | 1247 | mes = i18n("Local calendar changed!\n") +mes; |
1248 | mCalendar->checkAlarmForIncidence( 0, true ); | 1248 | mCalendar->checkAlarmForIncidence( 0, true ); |
1249 | qDebug( mes ); | 1249 | qDebug( mes ); |
1250 | if ( mSyncManager->mShowSyncSummary ) { | 1250 | if ( mSyncManager->mShowSyncSummary ) { |
1251 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1251 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1252 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1252 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1253 | qDebug("KO: WB cancelled "); | 1253 | qDebug("KO: WB cancelled "); |
1254 | mSyncManager->mWriteBackFile = false; | 1254 | mSyncManager->mWriteBackFile = false; |
1255 | return syncOK; | 1255 | return syncOK; |
1256 | } | 1256 | } |
1257 | } | 1257 | } |
1258 | return syncOK; | 1258 | return syncOK; |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | void CalendarView::setSyncDevice( QString s ) | 1261 | void CalendarView::setSyncDevice( QString s ) |
1262 | { | 1262 | { |
1263 | mCurrentSyncDevice= s; | 1263 | mCurrentSyncDevice= s; |
1264 | } | 1264 | } |
1265 | void CalendarView::setSyncName( QString s ) | 1265 | void CalendarView::setSyncName( QString s ) |
1266 | { | 1266 | { |
1267 | mCurrentSyncName= s; | 1267 | mCurrentSyncName= s; |
1268 | } | 1268 | } |
1269 | bool CalendarView::syncCalendar(QString filename, int mode) | 1269 | bool CalendarView::syncCalendar(QString filename, int mode) |
1270 | { | 1270 | { |
1271 | //qDebug("syncCalendar %s ", filename.latin1()); | 1271 | //qDebug("syncCalendar %s ", filename.latin1()); |
1272 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1272 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1273 | CalendarLocal* calendar = new CalendarLocal(); | 1273 | CalendarLocal* calendar = new CalendarLocal(); |
1274 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1274 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1275 | FileStorage* storage = new FileStorage( calendar ); | 1275 | FileStorage* storage = new FileStorage( calendar ); |
1276 | bool syncOK = false; | 1276 | bool syncOK = false; |
1277 | storage->setFileName( filename ); | 1277 | storage->setFileName( filename ); |
1278 | // qDebug("loading ... "); | 1278 | // qDebug("loading ... "); |
1279 | if ( storage->load() ) { | 1279 | if ( storage->load() ) { |
1280 | getEventViewerDialog()->setSyncMode( true ); | 1280 | getEventViewerDialog()->setSyncMode( true ); |
1281 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1281 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1282 | getEventViewerDialog()->setSyncMode( false ); | 1282 | getEventViewerDialog()->setSyncMode( false ); |
1283 | if ( syncOK ) { | 1283 | if ( syncOK ) { |
1284 | if ( mSyncManager->mWriteBackFile ) | 1284 | if ( mSyncManager->mWriteBackFile ) |
1285 | { | 1285 | { |
1286 | storage->setSaveFormat( new ICalFormat() ); | 1286 | storage->setSaveFormat( new ICalFormat() ); |
1287 | storage->save(); | 1287 | storage->save(); |
1288 | } | 1288 | } |
1289 | } | 1289 | } |
1290 | setModified( true ); | 1290 | setModified( true ); |
1291 | } | 1291 | } |
1292 | delete storage; | 1292 | delete storage; |
1293 | delete calendar; | 1293 | delete calendar; |
1294 | if ( syncOK ) | 1294 | if ( syncOK ) |
1295 | updateView(); | 1295 | updateView(); |
1296 | return syncOK; | 1296 | return syncOK; |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | void CalendarView::syncExternal( int mode ) | 1299 | void CalendarView::syncExternal( int mode ) |
1300 | { | 1300 | { |
1301 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1301 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1302 | 1302 | ||
1303 | qApp->processEvents(); | 1303 | qApp->processEvents(); |
1304 | CalendarLocal* calendar = new CalendarLocal(); | 1304 | CalendarLocal* calendar = new CalendarLocal(); |
1305 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1305 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1306 | bool syncOK = false; | 1306 | bool syncOK = false; |
1307 | bool loadSuccess = false; | 1307 | bool loadSuccess = false; |
1308 | PhoneFormat* phoneFormat = 0; | 1308 | PhoneFormat* phoneFormat = 0; |
1309 | emit tempDisableBR(true); | 1309 | emit tempDisableBR(true); |
1310 | #ifndef DESKTOP_VERSION | 1310 | #ifndef DESKTOP_VERSION |
1311 | SharpFormat* sharpFormat = 0; | 1311 | SharpFormat* sharpFormat = 0; |
1312 | if ( mode == 0 ) { // sharp | 1312 | if ( mode == 0 ) { // sharp |
1313 | sharpFormat = new SharpFormat () ; | 1313 | sharpFormat = new SharpFormat () ; |
1314 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1314 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1315 | 1315 | ||
1316 | } else | 1316 | } else |
1317 | #endif | 1317 | #endif |
1318 | if ( mode == 1 ) { // phone | 1318 | if ( mode == 1 ) { // phone |
1319 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1319 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1320 | mSyncManager->mPhoneDevice, | 1320 | mSyncManager->mPhoneDevice, |
1321 | mSyncManager->mPhoneConnection, | 1321 | mSyncManager->mPhoneConnection, |
1322 | mSyncManager->mPhoneModel); | 1322 | mSyncManager->mPhoneModel); |
1323 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1323 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1324 | 1324 | ||
1325 | } else { | 1325 | } else { |
1326 | emit tempDisableBR(false); | 1326 | emit tempDisableBR(false); |
1327 | return; | 1327 | return; |
1328 | } | 1328 | } |
1329 | if ( loadSuccess ) { | 1329 | if ( loadSuccess ) { |
1330 | getEventViewerDialog()->setSyncMode( true ); | 1330 | getEventViewerDialog()->setSyncMode( true ); |
1331 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1331 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1332 | getEventViewerDialog()->setSyncMode( false ); | 1332 | getEventViewerDialog()->setSyncMode( false ); |
1333 | qApp->processEvents(); | 1333 | qApp->processEvents(); |
1334 | if ( syncOK ) { | 1334 | if ( syncOK ) { |
1335 | if ( mSyncManager->mWriteBackFile ) | 1335 | if ( mSyncManager->mWriteBackFile ) |
1336 | { | 1336 | { |
1337 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1337 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1338 | Incidence* inc = iL.first(); | 1338 | Incidence* inc = iL.first(); |
1339 | if ( phoneFormat ) { | 1339 | if ( phoneFormat ) { |
1340 | while ( inc ) { | 1340 | while ( inc ) { |
1341 | inc->removeID(mCurrentSyncDevice); | 1341 | inc->removeID(mCurrentSyncDevice); |
1342 | inc = iL.next(); | 1342 | inc = iL.next(); |
1343 | } | 1343 | } |
1344 | } | 1344 | } |
1345 | #ifndef DESKTOP_VERSION | 1345 | #ifndef DESKTOP_VERSION |
1346 | if ( sharpFormat ) | 1346 | if ( sharpFormat ) |
1347 | sharpFormat->save(calendar); | 1347 | sharpFormat->save(calendar); |
1348 | #endif | 1348 | #endif |
1349 | if ( phoneFormat ) | 1349 | if ( phoneFormat ) |
1350 | phoneFormat->save(calendar); | 1350 | phoneFormat->save(calendar); |
1351 | iL = calendar->rawIncidences(); | 1351 | iL = calendar->rawIncidences(); |
1352 | inc = iL.first(); | 1352 | inc = iL.first(); |
1353 | Incidence* loc; | 1353 | Incidence* loc; |
1354 | while ( inc ) { | 1354 | while ( inc ) { |
1355 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1355 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1356 | loc = mCalendar->incidence(inc->uid() ); | 1356 | loc = mCalendar->incidence(inc->uid() ); |
1357 | if ( loc ) { | 1357 | if ( loc ) { |
1358 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1358 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1359 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1359 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | inc = iL.next(); | 1362 | inc = iL.next(); |
1363 | } | 1363 | } |
1364 | Incidence* lse = getLastSyncEvent(); | 1364 | Incidence* lse = getLastSyncEvent(); |
1365 | if ( lse ) { | 1365 | if ( lse ) { |
1366 | lse->setReadOnly( false ); | 1366 | lse->setReadOnly( false ); |
1367 | lse->setDescription( "" ); | 1367 | lse->setDescription( "" ); |
1368 | lse->setReadOnly( true ); | 1368 | lse->setReadOnly( true ); |
1369 | } | 1369 | } |
1370 | } | 1370 | } |
1371 | } else { | 1371 | } else { |
1372 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1372 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1373 | } | 1373 | } |
1374 | setModified( true ); | 1374 | setModified( true ); |
1375 | } else { | 1375 | } else { |
1376 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1376 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1377 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1377 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1378 | question, i18n("Ok")) ; | 1378 | question, i18n("Ok")) ; |
1379 | 1379 | ||
1380 | } | 1380 | } |
1381 | delete calendar; | 1381 | delete calendar; |
1382 | updateView(); | 1382 | updateView(); |
1383 | emit tempDisableBR(false); | 1383 | emit tempDisableBR(false); |
1384 | return ;//syncOK; | 1384 | return ;//syncOK; |
1385 | 1385 | ||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | bool CalendarView::importBday() | 1388 | bool CalendarView::importBday() |
1389 | { | 1389 | { |
1390 | #ifndef KORG_NOKABC | 1390 | #ifndef KORG_NOKABC |
1391 | 1391 | ||
1392 | #ifdef DESKTOP_VERSION | 1392 | #ifdef DESKTOP_VERSION |
1393 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1393 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1394 | KABC::AddressBook::Iterator it; | 1394 | KABC::AddressBook::Iterator it; |
1395 | int count = 0; | 1395 | int count = 0; |
1396 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1396 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1397 | ++count; | 1397 | ++count; |
1398 | } | 1398 | } |
1399 | QProgressBar bar(count,0 ); | 1399 | QProgressBar bar(count,0 ); |
1400 | int w = 300; | 1400 | int w = 300; |
1401 | if ( QApplication::desktop()->width() < 320 ) | 1401 | if ( QApplication::desktop()->width() < 320 ) |
1402 | w = 220; | 1402 | w = 220; |
1403 | int h = bar.sizeHint().height() ; | 1403 | int h = bar.sizeHint().height() ; |
1404 | int dw = QApplication::desktop()->width(); | 1404 | int dw = QApplication::desktop()->width(); |
1405 | int dh = QApplication::desktop()->height(); | 1405 | int dh = QApplication::desktop()->height(); |
1406 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1406 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1407 | bar.show(); | 1407 | bar.show(); |
1408 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1408 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1409 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1410 | count = 0; | 1410 | count = 0; |
1411 | int addCount = 0; | 1411 | int addCount = 0; |
1412 | KCal::Attendee* a = 0; | 1412 | KCal::Attendee* a = 0; |
1413 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1413 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1414 | if ( ! bar.isVisible() ) | 1414 | if ( ! bar.isVisible() ) |
1415 | return false; | 1415 | return false; |
1416 | bar.setProgress( count++ ); | 1416 | bar.setProgress( count++ ); |
1417 | qApp->processEvents(); | 1417 | qApp->processEvents(); |
1418 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1418 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1419 | if ( (*it).birthday().date().isValid() ){ | 1419 | if ( (*it).birthday().date().isValid() ){ |
1420 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1420 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1421 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1421 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1422 | ++addCount; | 1422 | ++addCount; |
1423 | } | 1423 | } |
1424 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1424 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1425 | if ( anni.isValid() ){ | 1425 | if ( anni.isValid() ){ |
1426 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1426 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1427 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1427 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1428 | ++addCount; | 1428 | ++addCount; |
1429 | } | 1429 | } |
1430 | } | 1430 | } |
1431 | updateView(); | 1431 | updateView(); |
1432 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1432 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1433 | #else //DESKTOP_VERSION | 1433 | #else //DESKTOP_VERSION |
1434 | 1434 | ||
1435 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1435 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1436 | // the result should now arrive through method insertBirthdays | 1436 | // the result should now arrive through method insertBirthdays |
1437 | 1437 | ||
1438 | #endif //DESKTOP_VERSION | 1438 | #endif //DESKTOP_VERSION |
1439 | 1439 | ||
1440 | #endif //KORG_NOKABC | 1440 | #endif //KORG_NOKABC |
1441 | 1441 | ||
1442 | 1442 | ||
1443 | return true; | 1443 | return true; |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1446 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1447 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1447 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1448 | const QStringList& anniversaryList, const QStringList& realNameList, | 1448 | const QStringList& anniversaryList, const QStringList& realNameList, |
1449 | const QStringList& emailList, const QStringList& assembledNameList, | 1449 | const QStringList& emailList, const QStringList& assembledNameList, |
1450 | const QStringList& uidList) | 1450 | const QStringList& uidList) |
1451 | { | 1451 | { |
1452 | //qDebug("KO::CalendarView::insertBirthdays"); | 1452 | //qDebug("KO::CalendarView::insertBirthdays"); |
1453 | if (uid == this->name()) | 1453 | if (uid == this->name()) |
1454 | { | 1454 | { |
1455 | int count = birthdayList.count(); | 1455 | int count = birthdayList.count(); |
1456 | int addCount = 0; | 1456 | int addCount = 0; |
1457 | KCal::Attendee* a = 0; | 1457 | KCal::Attendee* a = 0; |
1458 | 1458 | ||
1459 | //qDebug("CalView 1 %i", count); | 1459 | //qDebug("CalView 1 %i", count); |
1460 | 1460 | ||
1461 | QProgressBar bar(count,0 ); | 1461 | QProgressBar bar(count,0 ); |
1462 | int w = 300; | 1462 | int w = 300; |
1463 | if ( QApplication::desktop()->width() < 320 ) | 1463 | if ( QApplication::desktop()->width() < 320 ) |
1464 | w = 220; | 1464 | w = 220; |
1465 | int h = bar.sizeHint().height() ; | 1465 | int h = bar.sizeHint().height() ; |
1466 | int dw = QApplication::desktop()->width(); | 1466 | int dw = QApplication::desktop()->width(); |
1467 | int dh = QApplication::desktop()->height(); | 1467 | int dh = QApplication::desktop()->height(); |
1468 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1468 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1469 | bar.show(); | 1469 | bar.show(); |
1470 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1470 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1471 | qApp->processEvents(); | 1471 | qApp->processEvents(); |
1472 | 1472 | ||
1473 | QDate birthday; | 1473 | QDate birthday; |
1474 | QDate anniversary; | 1474 | QDate anniversary; |
1475 | QString realName; | 1475 | QString realName; |
1476 | QString email; | 1476 | QString email; |
1477 | QString assembledName; | 1477 | QString assembledName; |
1478 | QString uid; | 1478 | QString uid; |
1479 | bool ok = true; | 1479 | bool ok = true; |
1480 | for ( int i = 0; i < count; i++) | 1480 | for ( int i = 0; i < count; i++) |
1481 | { | 1481 | { |
1482 | if ( ! bar.isVisible() ) | 1482 | if ( ! bar.isVisible() ) |
1483 | return; | 1483 | return; |
1484 | bar.setProgress( i ); | 1484 | bar.setProgress( i ); |
1485 | qApp->processEvents(); | 1485 | qApp->processEvents(); |
1486 | 1486 | ||
1487 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1487 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1488 | if (!ok) { | 1488 | if (!ok) { |
1489 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1489 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1492 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1493 | if (!ok) { | 1493 | if (!ok) { |
1494 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1494 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1495 | } | 1495 | } |
1496 | realName = realNameList[i]; | 1496 | realName = realNameList[i]; |
1497 | email = emailList[i]; | 1497 | email = emailList[i]; |
1498 | assembledName = assembledNameList[i]; | 1498 | assembledName = assembledNameList[i]; |
1499 | uid = uidList[i]; | 1499 | uid = uidList[i]; |
1500 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1500 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1501 | 1501 | ||
1502 | if ( birthday.isValid() ){ | 1502 | if ( birthday.isValid() ){ |
1503 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1503 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1504 | KCal::Attendee::ReqParticipant,uid) ; | 1504 | KCal::Attendee::ReqParticipant,uid) ; |
1505 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1505 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1506 | ++addCount; | 1506 | ++addCount; |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | if ( anniversary.isValid() ){ | 1509 | if ( anniversary.isValid() ){ |
1510 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1510 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1511 | KCal::Attendee::ReqParticipant,uid) ; | 1511 | KCal::Attendee::ReqParticipant,uid) ; |
1512 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1512 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1513 | ++addCount; | 1513 | ++addCount; |
1514 | } | 1514 | } |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | updateView(); | 1517 | updateView(); |
1518 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1518 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1519 | 1519 | ||
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | 1524 | ||
1525 | 1525 | ||
1526 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1526 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1527 | { | 1527 | { |
1528 | //qDebug("addAnni "); | 1528 | //qDebug("addAnni "); |
1529 | Event * ev = new Event(); | 1529 | Event * ev = new Event(); |
1530 | ev->setOrganizer(KOPrefs::instance()->email()); | 1530 | ev->setOrganizer(KOPrefs::instance()->email()); |
1531 | if ( a ) { | 1531 | if ( a ) { |
1532 | ev->addAttendee( a ); | 1532 | ev->addAttendee( a ); |
1533 | } | 1533 | } |
1534 | QString kind; | 1534 | QString kind; |
1535 | if ( birthday ) { | 1535 | if ( birthday ) { |
1536 | kind = i18n( "Birthday" ); | 1536 | kind = i18n( "Birthday" ); |
1537 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1537 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1538 | } | 1538 | } |
1539 | else { | 1539 | else { |
1540 | kind = i18n( "Anniversary" ); | 1540 | kind = i18n( "Anniversary" ); |
1541 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1541 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1542 | } | 1542 | } |
1543 | ev->setCategories( kind ); | 1543 | ev->setCategories( kind ); |
1544 | ev->setDtStart( QDateTime(date) ); | 1544 | ev->setDtStart( QDateTime(date) ); |
1545 | ev->setDtEnd( QDateTime(date) ); | 1545 | ev->setDtEnd( QDateTime(date) ); |
1546 | ev->setFloats( true ); | 1546 | ev->setFloats( true ); |
1547 | Recurrence * rec = ev->recurrence(); | 1547 | Recurrence * rec = ev->recurrence(); |
1548 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1548 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1549 | rec->addYearlyNum( date.month() ); | 1549 | rec->addYearlyNum( date.month() ); |
1550 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1550 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1551 | delete ev; | 1551 | delete ev; |
1552 | return false; | 1552 | return false; |
1553 | } | 1553 | } |
1554 | return true; | 1554 | return true; |
1555 | 1555 | ||
1556 | } | 1556 | } |
1557 | bool CalendarView::importQtopia( const QString &categories, | 1557 | bool CalendarView::importQtopia( const QString &categories, |
1558 | const QString &datebook, | 1558 | const QString &datebook, |
1559 | const QString &todolist ) | 1559 | const QString &todolist ) |
1560 | { | 1560 | { |
1561 | 1561 | ||
1562 | QtopiaFormat qtopiaFormat; | 1562 | QtopiaFormat qtopiaFormat; |
1563 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1563 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1564 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1564 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1565 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1565 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1566 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1566 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1567 | 1567 | ||
1568 | updateView(); | 1568 | updateView(); |
1569 | return true; | 1569 | return true; |
1570 | 1570 | ||
1571 | #if 0 | 1571 | #if 0 |
1572 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1572 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1573 | mCurrentSyncDevice = "qtopia-XML"; | 1573 | mCurrentSyncDevice = "qtopia-XML"; |
1574 | if ( mSyncManager->mAskForPreferences ) | 1574 | if ( mSyncManager->mAskForPreferences ) |
1575 | edit_sync_options(); | 1575 | edit_sync_options(); |
1576 | qApp->processEvents(); | 1576 | qApp->processEvents(); |
1577 | CalendarLocal* calendar = new CalendarLocal(); | 1577 | CalendarLocal* calendar = new CalendarLocal(); |
1578 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1578 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1579 | bool syncOK = false; | 1579 | bool syncOK = false; |
1580 | QtopiaFormat qtopiaFormat; | 1580 | QtopiaFormat qtopiaFormat; |
1581 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1581 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1582 | bool loadOk = true; | 1582 | bool loadOk = true; |
1583 | if ( !categories.isEmpty() ) | 1583 | if ( !categories.isEmpty() ) |
1584 | loadOk = qtopiaFormat.load( calendar, categories ); | 1584 | loadOk = qtopiaFormat.load( calendar, categories ); |
1585 | if ( loadOk && !datebook.isEmpty() ) | 1585 | if ( loadOk && !datebook.isEmpty() ) |
1586 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1586 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1587 | if ( loadOk && !todolist.isEmpty() ) | 1587 | if ( loadOk && !todolist.isEmpty() ) |
1588 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1588 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1589 | 1589 | ||
1590 | if ( loadOk ) { | 1590 | if ( loadOk ) { |
1591 | getEventViewerDialog()->setSyncMode( true ); | 1591 | getEventViewerDialog()->setSyncMode( true ); |
1592 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1592 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1593 | getEventViewerDialog()->setSyncMode( false ); | 1593 | getEventViewerDialog()->setSyncMode( false ); |
1594 | qApp->processEvents(); | 1594 | qApp->processEvents(); |
1595 | if ( syncOK ) { | 1595 | if ( syncOK ) { |
1596 | if ( mSyncManager->mWriteBackFile ) | 1596 | if ( mSyncManager->mWriteBackFile ) |
1597 | { | 1597 | { |
1598 | // write back XML file | 1598 | // write back XML file |
1599 | 1599 | ||
1600 | } | 1600 | } |
1601 | setModified( true ); | 1601 | setModified( true ); |
1602 | } | 1602 | } |
1603 | } else { | 1603 | } else { |
1604 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1604 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1605 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1605 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1606 | question, i18n("Ok")) ; | 1606 | question, i18n("Ok")) ; |
1607 | } | 1607 | } |
1608 | delete calendar; | 1608 | delete calendar; |
1609 | updateView(); | 1609 | updateView(); |
1610 | return syncOK; | 1610 | return syncOK; |
1611 | 1611 | ||
1612 | 1612 | ||
1613 | #endif | 1613 | #endif |
1614 | 1614 | ||
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | void CalendarView::setSyncEventsReadOnly() | 1617 | void CalendarView::setSyncEventsReadOnly() |
1618 | { | 1618 | { |
1619 | Event * ev; | 1619 | Event * ev; |
1620 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1620 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1621 | ev = eL.first(); | 1621 | ev = eL.first(); |
1622 | while ( ev ) { | 1622 | while ( ev ) { |
1623 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1623 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1624 | ev->setReadOnly( true ); | 1624 | ev->setReadOnly( true ); |
1625 | ev = eL.next(); | 1625 | ev = eL.next(); |
1626 | } | 1626 | } |
1627 | } | 1627 | } |
1628 | bool CalendarView::openCalendar(QString filename, bool merge) | 1628 | bool CalendarView::openCalendar(QString filename, bool merge) |
1629 | { | 1629 | { |
1630 | 1630 | ||
1631 | if (filename.isEmpty()) { | 1631 | if (filename.isEmpty()) { |
1632 | return false; | 1632 | return false; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | if (!QFile::exists(filename)) { | 1635 | if (!QFile::exists(filename)) { |
1636 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1636 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1637 | return false; | 1637 | return false; |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | globalFlagBlockAgenda = 1; | 1640 | globalFlagBlockAgenda = 1; |
1641 | if (!merge) mCalendar->close(); | 1641 | if (!merge) mCalendar->close(); |
1642 | 1642 | ||
1643 | mStorage->setFileName( filename ); | 1643 | mStorage->setFileName( filename ); |
1644 | 1644 | ||
1645 | if ( mStorage->load() ) { | 1645 | if ( mStorage->load() ) { |
1646 | if ( merge ) ;//setModified( true ); | 1646 | if ( merge ) ;//setModified( true ); |
1647 | else { | 1647 | else { |
1648 | //setModified( true ); | 1648 | //setModified( true ); |
1649 | mViewManager->setDocumentId( filename ); | 1649 | mViewManager->setDocumentId( filename ); |
1650 | mDialogManager->setDocumentId( filename ); | 1650 | mDialogManager->setDocumentId( filename ); |
1651 | mTodoList->setDocumentId( filename ); | 1651 | mTodoList->setDocumentId( filename ); |
1652 | } | 1652 | } |
1653 | globalFlagBlockAgenda = 2; | 1653 | globalFlagBlockAgenda = 2; |
1654 | // if ( getLastSyncEvent() ) | 1654 | // if ( getLastSyncEvent() ) |
1655 | // getLastSyncEvent()->setReadOnly( true ); | 1655 | // getLastSyncEvent()->setReadOnly( true ); |
1656 | mCalendar->reInitAlarmSettings(); | 1656 | mCalendar->reInitAlarmSettings(); |
1657 | setSyncEventsReadOnly(); | 1657 | setSyncEventsReadOnly(); |
1658 | updateUnmanagedViews(); | 1658 | updateUnmanagedViews(); |
1659 | updateView(); | 1659 | updateView(); |
1660 | if ( filename != MainWindow::defaultFileName() ) { | 1660 | if ( filename != MainWindow::defaultFileName() ) { |
1661 | saveCalendar( MainWindow::defaultFileName() ); | 1661 | saveCalendar( MainWindow::defaultFileName() ); |
1662 | } else { | 1662 | } else { |
1663 | QFileInfo finf ( MainWindow::defaultFileName()); | 1663 | QFileInfo finf ( MainWindow::defaultFileName()); |
1664 | if ( finf.exists() ) { | 1664 | if ( finf.exists() ) { |
1665 | setLoadedFileVersion( finf.lastModified () ); | 1665 | setLoadedFileVersion( finf.lastModified () ); |
1666 | } | 1666 | } |
1667 | } | 1667 | } |
1668 | return true; | 1668 | return true; |
1669 | } else { | 1669 | } else { |
1670 | // while failing to load, the calendar object could | 1670 | // while failing to load, the calendar object could |
1671 | // have become partially populated. Clear it out. | 1671 | // have become partially populated. Clear it out. |
1672 | if ( !merge ) { | 1672 | if ( !merge ) { |
1673 | mCalendar->close(); | 1673 | mCalendar->close(); |
1674 | mViewManager->setDocumentId( filename ); | 1674 | mViewManager->setDocumentId( filename ); |
1675 | mDialogManager->setDocumentId( filename ); | 1675 | mDialogManager->setDocumentId( filename ); |
1676 | mTodoList->setDocumentId( filename ); | 1676 | mTodoList->setDocumentId( filename ); |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1679 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1680 | 1680 | ||
1681 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1681 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1682 | globalFlagBlockAgenda = 2; | 1682 | globalFlagBlockAgenda = 2; |
1683 | mCalendar->reInitAlarmSettings(); | 1683 | mCalendar->reInitAlarmSettings(); |
1684 | setSyncEventsReadOnly(); | 1684 | setSyncEventsReadOnly(); |
1685 | updateUnmanagedViews(); | 1685 | updateUnmanagedViews(); |
1686 | updateView(); | 1686 | updateView(); |
1687 | } | 1687 | } |
1688 | return false; | 1688 | return false; |
1689 | } | 1689 | } |
1690 | void CalendarView::showOpenError() | 1690 | void CalendarView::showOpenError() |
1691 | { | 1691 | { |
1692 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1692 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1693 | } | 1693 | } |
1694 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1694 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1695 | { | 1695 | { |
1696 | loadedFileVersion = dt; | 1696 | loadedFileVersion = dt; |
1697 | } | 1697 | } |
1698 | bool CalendarView::checkFileChanged(QString fn) | 1698 | bool CalendarView::checkFileChanged(QString fn) |
1699 | { | 1699 | { |
1700 | QFileInfo finf ( fn ); | 1700 | QFileInfo finf ( fn ); |
1701 | if ( !finf.exists() ) | 1701 | if ( !finf.exists() ) |
1702 | return true; | 1702 | return true; |
1703 | QDateTime dt = finf.lastModified (); | 1703 | QDateTime dt = finf.lastModified (); |
1704 | if ( dt <= loadedFileVersion ) | 1704 | if ( dt <= loadedFileVersion ) |
1705 | return false; | 1705 | return false; |
1706 | return true; | 1706 | return true; |
1707 | 1707 | ||
1708 | } | 1708 | } |
1709 | void CalendarView::watchSavedFile() | 1709 | void CalendarView::watchSavedFile() |
1710 | { | 1710 | { |
1711 | QFileInfo finf ( MainWindow::defaultFileName()); | 1711 | QFileInfo finf ( MainWindow::defaultFileName()); |
1712 | if ( !finf.exists() ) | 1712 | if ( !finf.exists() ) |
1713 | return; | 1713 | return; |
1714 | QDateTime dt = finf.lastModified (); | 1714 | QDateTime dt = finf.lastModified (); |
1715 | if ( dt < loadedFileVersion ) { | 1715 | if ( dt < loadedFileVersion ) { |
1716 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1716 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1717 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1717 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1718 | return; | 1718 | return; |
1719 | } | 1719 | } |
1720 | loadedFileVersion = dt; | 1720 | loadedFileVersion = dt; |
1721 | } | 1721 | } |
1722 | 1722 | ||
1723 | bool CalendarView::checkFileVersion(QString fn) | 1723 | bool CalendarView::checkFileVersion(QString fn) |
1724 | { | 1724 | { |
1725 | QFileInfo finf ( fn ); | 1725 | QFileInfo finf ( fn ); |
1726 | if ( !finf.exists() ) | 1726 | if ( !finf.exists() ) |
1727 | return true; | 1727 | return true; |
1728 | QDateTime dt = finf.lastModified (); | 1728 | QDateTime dt = finf.lastModified (); |
1729 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1729 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1730 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1730 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1731 | if ( dt <= loadedFileVersion ) | 1731 | if ( dt <= loadedFileVersion ) |
1732 | return true; | 1732 | return true; |
1733 | 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)) , | 1733 | 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)) , |
1734 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1734 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1735 | i18n("Sync+save")); | 1735 | i18n("Sync+save")); |
1736 | 1736 | ||
1737 | if ( km == KMessageBox::Cancel ) | 1737 | if ( km == KMessageBox::Cancel ) |
1738 | return false; | 1738 | return false; |
1739 | if ( km == KMessageBox::Yes ) | 1739 | if ( km == KMessageBox::Yes ) |
1740 | return true; | 1740 | return true; |
1741 | 1741 | ||
1742 | setSyncDevice("deleteaftersync" ); | 1742 | setSyncDevice("deleteaftersync" ); |
1743 | mSyncManager->mAskForPreferences = true; | 1743 | mSyncManager->mAskForPreferences = true; |
1744 | mSyncManager->mSyncAlgoPrefs = 3; | 1744 | mSyncManager->mSyncAlgoPrefs = 3; |
1745 | mSyncManager->mWriteBackFile = false; | 1745 | mSyncManager->mWriteBackFile = false; |
1746 | mSyncManager->mWriteBackExistingOnly = false; | 1746 | mSyncManager->mWriteBackExistingOnly = false; |
1747 | mSyncManager->mShowSyncSummary = false; | 1747 | mSyncManager->mShowSyncSummary = false; |
1748 | syncCalendar( fn, 3 ); | 1748 | syncCalendar( fn, 3 ); |
1749 | Event * e = getLastSyncEvent(); | 1749 | Event * e = getLastSyncEvent(); |
1750 | mCalendar->deleteEvent ( e ); | 1750 | mCalendar->deleteEvent ( e ); |
1751 | updateView(); | 1751 | updateView(); |
1752 | return true; | 1752 | return true; |
1753 | } | 1753 | } |
1754 | 1754 | ||
1755 | bool CalendarView::saveCalendar( QString filename ) | 1755 | bool CalendarView::saveCalendar( QString filename ) |
1756 | { | 1756 | { |
1757 | 1757 | ||
1758 | // Store back all unsaved data into calendar object | 1758 | // Store back all unsaved data into calendar object |
1759 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1759 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1760 | if ( mViewManager->currentView() ) | 1760 | if ( mViewManager->currentView() ) |
1761 | mViewManager->currentView()->flushView(); | 1761 | mViewManager->currentView()->flushView(); |
1762 | 1762 | ||
1763 | 1763 | ||
1764 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1764 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1765 | mStorage->setSaveFormat( new ICalFormat() ); | 1765 | mStorage->setSaveFormat( new ICalFormat() ); |
1766 | mStorage->setFileName( filename ); | 1766 | mStorage->setFileName( filename ); |
1767 | bool success; | 1767 | bool success; |
1768 | success = mStorage->save(); | 1768 | success = mStorage->save(); |
1769 | if ( !success ) { | 1769 | if ( !success ) { |
1770 | return false; | 1770 | return false; |
1771 | } | 1771 | } |
1772 | if ( filename == MainWindow::defaultFileName() ) { | 1772 | if ( filename == MainWindow::defaultFileName() ) { |
1773 | setLoadedFileVersion( lfv ); | 1773 | setLoadedFileVersion( lfv ); |
1774 | watchSavedFile(); | 1774 | watchSavedFile(); |
1775 | } | 1775 | } |
1776 | return true; | 1776 | return true; |
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | void CalendarView::closeCalendar() | 1779 | void CalendarView::closeCalendar() |
1780 | { | 1780 | { |
1781 | 1781 | ||
1782 | // child windows no longer valid | 1782 | // child windows no longer valid |
1783 | emit closingDown(); | 1783 | emit closingDown(); |
1784 | 1784 | ||
1785 | mCalendar->close(); | 1785 | mCalendar->close(); |
1786 | setModified(false); | 1786 | setModified(false); |
1787 | updateView(); | 1787 | updateView(); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | void CalendarView::archiveCalendar() | 1790 | void CalendarView::archiveCalendar() |
1791 | { | 1791 | { |
1792 | mDialogManager->showArchiveDialog(); | 1792 | mDialogManager->showArchiveDialog(); |
1793 | } | 1793 | } |
1794 | 1794 | ||
1795 | 1795 | ||
1796 | void CalendarView::readSettings() | 1796 | void CalendarView::readSettings() |
1797 | { | 1797 | { |
1798 | 1798 | ||
1799 | 1799 | ||
1800 | // mViewManager->showAgendaView(); | 1800 | // mViewManager->showAgendaView(); |
1801 | QString str; | 1801 | QString str; |
1802 | //qDebug("CalendarView::readSettings() "); | 1802 | //qDebug("CalendarView::readSettings() "); |
1803 | // read settings from the KConfig, supplying reasonable | 1803 | // read settings from the KConfig, supplying reasonable |
1804 | // defaults where none are to be found | 1804 | // defaults where none are to be found |
1805 | KConfig *config = KOGlobals::config(); | 1805 | KConfig *config = KOGlobals::config(); |
1806 | #ifndef KORG_NOSPLITTER | 1806 | #ifndef KORG_NOSPLITTER |
1807 | config->setGroup("KOrganizer Geometry"); | 1807 | config->setGroup("KOrganizer Geometry"); |
1808 | 1808 | ||
1809 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1809 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1810 | if (sizes.count() != 2) { | 1810 | if (sizes.count() != 2) { |
1811 | sizes << mDateNavigator->minimumSizeHint().width(); | 1811 | sizes << mDateNavigator->minimumSizeHint().width(); |
1812 | sizes << 300; | 1812 | sizes << 300; |
1813 | } | 1813 | } |
1814 | mPanner->setSizes(sizes); | 1814 | mPanner->setSizes(sizes); |
1815 | 1815 | ||
1816 | sizes = config->readIntListEntry("Separator2"); | 1816 | sizes = config->readIntListEntry("Separator2"); |
1817 | if ( ( mResourceView && sizes.count() == 4 ) || | 1817 | if ( ( mResourceView && sizes.count() == 4 ) || |
1818 | ( !mResourceView && sizes.count() == 3 ) ) { | 1818 | ( !mResourceView && sizes.count() == 3 ) ) { |
1819 | mLeftSplitter->setSizes(sizes); | 1819 | mLeftSplitter->setSizes(sizes); |
1820 | } | 1820 | } |
1821 | #endif | 1821 | #endif |
1822 | globalFlagBlockAgenda = 1; | 1822 | globalFlagBlockAgenda = 1; |
1823 | mViewManager->showAgendaView(); | 1823 | mViewManager->showAgendaView(); |
1824 | //mViewManager->readSettings( config ); | 1824 | //mViewManager->readSettings( config ); |
1825 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1825 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1826 | readFilterSettings(config); | 1826 | readFilterSettings(config); |
1827 | 1827 | ||
1828 | #ifdef DESKTOP_VERSION | 1828 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1829 | config->setGroup("WidgetLayout"); |
1830 | QStringList list; | 1830 | QStringList list; |
1831 | list = config->readListEntry("MainLayout"); | 1831 | list = config->readListEntry("MainLayout"); |
1832 | int x,y,w,h; | 1832 | int x,y,w,h; |
1833 | if ( ! list.isEmpty() ) { | 1833 | if ( ! list.isEmpty() ) { |
1834 | x = list[0].toInt(); | 1834 | x = list[0].toInt(); |
1835 | y = list[1].toInt(); | 1835 | y = list[1].toInt(); |
1836 | w = list[2].toInt(); | 1836 | w = list[2].toInt(); |
1837 | h = list[3].toInt(); | 1837 | h = list[3].toInt(); |
1838 | topLevelWidget()->setGeometry(x,y,w,h); | 1838 | topLevelWidget()->setGeometry(x,y,w,h); |
1839 | 1839 | ||
1840 | } else { | 1840 | } else { |
1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1842 | } | 1842 | } |
1843 | list = config->readListEntry("EditEventLayout"); | 1843 | list = config->readListEntry("EditEventLayout"); |
1844 | if ( ! list.isEmpty() ) { | 1844 | if ( ! list.isEmpty() ) { |
1845 | x = list[0].toInt(); | 1845 | x = list[0].toInt(); |
1846 | y = list[1].toInt(); | 1846 | y = list[1].toInt(); |
1847 | w = list[2].toInt(); | 1847 | w = list[2].toInt(); |
1848 | h = list[3].toInt(); | 1848 | h = list[3].toInt(); |
1849 | mEventEditor->setGeometry(x,y,w,h); | 1849 | mEventEditor->setGeometry(x,y,w,h); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | list = config->readListEntry("EditTodoLayout"); | 1852 | list = config->readListEntry("EditTodoLayout"); |
1853 | if ( ! list.isEmpty() ) { | 1853 | if ( ! list.isEmpty() ) { |
1854 | x = list[0].toInt(); | 1854 | x = list[0].toInt(); |
1855 | y = list[1].toInt(); | 1855 | y = list[1].toInt(); |
1856 | w = list[2].toInt(); | 1856 | w = list[2].toInt(); |
1857 | h = list[3].toInt(); | 1857 | h = list[3].toInt(); |
1858 | mTodoEditor->setGeometry(x,y,w,h); | 1858 | mTodoEditor->setGeometry(x,y,w,h); |
1859 | 1859 | ||
1860 | } | 1860 | } |
1861 | list = config->readListEntry("ViewerLayout"); | 1861 | list = config->readListEntry("ViewerLayout"); |
1862 | if ( ! list.isEmpty() ) { | 1862 | if ( ! list.isEmpty() ) { |
1863 | x = list[0].toInt(); | 1863 | x = list[0].toInt(); |
1864 | y = list[1].toInt(); | 1864 | y = list[1].toInt(); |
1865 | w = list[2].toInt(); | 1865 | w = list[2].toInt(); |
1866 | h = list[3].toInt(); | 1866 | h = list[3].toInt(); |
1867 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1867 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | config->setGroup( "Views" ); | 1870 | config->setGroup( "Views" ); |
1871 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1871 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1872 | 1872 | ||
1873 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1873 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1874 | 1874 | ||
1875 | int resetval = 0; | 1875 | int resetval = 0; |
1876 | int maxVal = 0; | 1876 | int maxVal = 0; |
1877 | if (sizes.count() != 3) { | 1877 | if (sizes.count() != 3) { |
1878 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1878 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1879 | resetval = mDateNavigator->sizeHint().width()+2; | 1879 | resetval = mDateNavigator->sizeHint().width()+2; |
1880 | } else { | 1880 | } else { |
1881 | resetval = mDateNavigator->sizeHint().height()+2; | 1881 | resetval = mDateNavigator->sizeHint().height()+2; |
1882 | } | 1882 | } |
1883 | } | 1883 | } |
1884 | if ( resetval ) { | 1884 | if ( resetval ) { |
1885 | sizes.clear(); | 1885 | sizes.clear(); |
1886 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1886 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1887 | maxVal = QApplication::desktop()->width() -10; | 1887 | maxVal = QApplication::desktop()->width() -10; |
1888 | } else { | 1888 | } else { |
1889 | maxVal = QApplication::desktop()->height()-10; | 1889 | maxVal = QApplication::desktop()->height()-10; |
1890 | } | 1890 | } |
1891 | sizes << resetval; | 1891 | sizes << resetval; |
1892 | if ( maxVal < resetval + resetval) | 1892 | if ( maxVal < resetval + resetval) |
1893 | resetval = maxVal - resetval; | 1893 | resetval = maxVal - resetval; |
1894 | sizes << resetval; | 1894 | sizes << resetval; |
1895 | sizes << 100; | 1895 | sizes << 100; |
1896 | } | 1896 | } |
1897 | mLeftFrame->setSizes(sizes); | 1897 | mLeftFrame->setSizes(sizes); |
1898 | sizes = config->readIntListEntry("Main Splitter Frame"); | 1898 | sizes = config->readIntListEntry("Main Splitter Frame"); |
1899 | resetval = 0; | 1899 | resetval = 0; |
1900 | maxVal = 0; | 1900 | maxVal = 0; |
1901 | if (sizes.count() != 2) { | 1901 | if (sizes.count() != 2) { |
1902 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 1902 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
1903 | resetval = mDateNavigator->sizeHint().width()+2; | 1903 | resetval = mDateNavigator->sizeHint().width()+2; |
1904 | } else { | 1904 | } else { |
1905 | resetval = mDateNavigator->sizeHint().height()+2; | 1905 | resetval = mDateNavigator->sizeHint().height()+2; |
1906 | } | 1906 | } |
1907 | } | 1907 | } |
1908 | if ( resetval ) { | 1908 | if ( resetval ) { |
1909 | sizes.clear(); | 1909 | sizes.clear(); |
1910 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 1910 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
1911 | maxVal = QApplication::desktop()->width() -10; | 1911 | maxVal = QApplication::desktop()->width() -10; |
1912 | } else { | 1912 | } else { |
1913 | maxVal = QApplication::desktop()->height()-10; | 1913 | maxVal = QApplication::desktop()->height()-10; |
1914 | } | 1914 | } |
1915 | sizes << resetval; | 1915 | sizes << resetval; |
1916 | if ( maxVal < resetval + resetval) | 1916 | if ( maxVal < resetval + resetval) |
1917 | resetval = maxVal - resetval; | 1917 | resetval = maxVal - resetval; |
1918 | sizes << resetval; | 1918 | sizes << resetval; |
1919 | } | 1919 | } |
1920 | mMainFrame->setSizes(sizes); | 1920 | mMainFrame->setSizes(sizes); |
1921 | |||
1922 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1921 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1923 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1922 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1924 | else mNavigator->selectDates( dateCount ); | 1923 | else mNavigator->selectDates( dateCount ); |
1925 | // mViewManager->readSettings( config ); | 1924 | // mViewManager->readSettings( config ); |
1926 | updateConfig(); | 1925 | updateConfig(); |
1927 | globalFlagBlockAgenda = 2; | 1926 | globalFlagBlockAgenda = 2; |
1928 | mViewManager->readSettings( config ); | 1927 | mViewManager->readSettings( config ); |
1928 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | ||
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | 1931 | ||
1932 | void CalendarView::writeSettings() | 1932 | void CalendarView::writeSettings() |
1933 | { | 1933 | { |
1934 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1934 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1935 | 1935 | ||
1936 | KConfig *config = KOGlobals::config(); | 1936 | KConfig *config = KOGlobals::config(); |
1937 | 1937 | ||
1938 | mViewManager->writeSettings( config ); | 1938 | mViewManager->writeSettings( config ); |
1939 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1939 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1940 | mDialogManager->writeSettings( config ); | 1940 | mDialogManager->writeSettings( config ); |
1941 | //KOPrefs::instance()->usrWriteConfig(); | 1941 | //KOPrefs::instance()->usrWriteConfig(); |
1942 | KOPrefs::instance()->writeConfig(); | 1942 | KOPrefs::instance()->writeConfig(); |
1943 | 1943 | ||
1944 | writeFilterSettings(config); | 1944 | writeFilterSettings(config); |
1945 | 1945 | ||
1946 | config->setGroup( "Views" ); | 1946 | config->setGroup( "Views" ); |
1947 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1947 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1948 | 1948 | ||
1949 | QValueList<int> listINT = mLeftFrame->sizes(); | 1949 | QValueList<int> listINT = mLeftFrame->sizes(); |
1950 | config->writeEntry("Left Splitter Frame",listINT); | 1950 | config->writeEntry("Left Splitter Frame",listINT); |
1951 | QValueList<int> listINT2 = mMainFrame->sizes(); | 1951 | QValueList<int> listINT2 = mMainFrame->sizes(); |
1952 | config->writeEntry("Main Splitter Frame",listINT2); | 1952 | config->writeEntry("Main Splitter Frame",listINT2); |
1953 | #ifdef DESKTOP_VERSION | 1953 | #ifdef DESKTOP_VERSION |
1954 | config->setGroup("WidgetLayout"); | 1954 | config->setGroup("WidgetLayout"); |
1955 | QStringList list ;//= config->readListEntry("MainLayout"); | 1955 | QStringList list ;//= config->readListEntry("MainLayout"); |
1956 | int x,y,w,h; | 1956 | int x,y,w,h; |
1957 | QWidget* wid; | 1957 | QWidget* wid; |
1958 | wid = topLevelWidget(); | 1958 | wid = topLevelWidget(); |
1959 | x = wid->geometry().x(); | 1959 | x = wid->geometry().x(); |
1960 | y = wid->geometry().y(); | 1960 | y = wid->geometry().y(); |
1961 | w = wid->width(); | 1961 | w = wid->width(); |
1962 | h = wid->height(); | 1962 | h = wid->height(); |
1963 | list.clear(); | 1963 | list.clear(); |
1964 | list << QString::number( x ); | 1964 | list << QString::number( x ); |
1965 | list << QString::number( y ); | 1965 | list << QString::number( y ); |
1966 | list << QString::number( w ); | 1966 | list << QString::number( w ); |
1967 | list << QString::number( h ); | 1967 | list << QString::number( h ); |
1968 | config->writeEntry("MainLayout",list ); | 1968 | config->writeEntry("MainLayout",list ); |
1969 | 1969 | ||
1970 | wid = mEventEditor; | 1970 | wid = mEventEditor; |
1971 | x = wid->geometry().x(); | 1971 | x = wid->geometry().x(); |
1972 | y = wid->geometry().y(); | 1972 | y = wid->geometry().y(); |
1973 | w = wid->width(); | 1973 | w = wid->width(); |
1974 | h = wid->height(); | 1974 | h = wid->height(); |
1975 | list.clear(); | 1975 | list.clear(); |
1976 | list << QString::number( x ); | 1976 | list << QString::number( x ); |
1977 | list << QString::number( y ); | 1977 | list << QString::number( y ); |
1978 | list << QString::number( w ); | 1978 | list << QString::number( w ); |
1979 | list << QString::number( h ); | 1979 | list << QString::number( h ); |
1980 | config->writeEntry("EditEventLayout",list ); | 1980 | config->writeEntry("EditEventLayout",list ); |
1981 | 1981 | ||
1982 | wid = mTodoEditor; | 1982 | wid = mTodoEditor; |
1983 | x = wid->geometry().x(); | 1983 | x = wid->geometry().x(); |
1984 | y = wid->geometry().y(); | 1984 | y = wid->geometry().y(); |
1985 | w = wid->width(); | 1985 | w = wid->width(); |
1986 | h = wid->height(); | 1986 | h = wid->height(); |
1987 | list.clear(); | 1987 | list.clear(); |
1988 | list << QString::number( x ); | 1988 | list << QString::number( x ); |
1989 | list << QString::number( y ); | 1989 | list << QString::number( y ); |
1990 | list << QString::number( w ); | 1990 | list << QString::number( w ); |
1991 | list << QString::number( h ); | 1991 | list << QString::number( h ); |
1992 | config->writeEntry("EditTodoLayout",list ); | 1992 | config->writeEntry("EditTodoLayout",list ); |
1993 | wid = getEventViewerDialog(); | 1993 | wid = getEventViewerDialog(); |
1994 | x = wid->geometry().x(); | 1994 | x = wid->geometry().x(); |
1995 | y = wid->geometry().y(); | 1995 | y = wid->geometry().y(); |
1996 | w = wid->width(); | 1996 | w = wid->width(); |
1997 | h = wid->height(); | 1997 | h = wid->height(); |
1998 | list.clear(); | 1998 | list.clear(); |
1999 | list << QString::number( x ); | 1999 | list << QString::number( x ); |
2000 | list << QString::number( y ); | 2000 | list << QString::number( y ); |
2001 | list << QString::number( w ); | 2001 | list << QString::number( w ); |
2002 | list << QString::number( h ); | 2002 | list << QString::number( h ); |
2003 | config->writeEntry("ViewerLayout",list ); | 2003 | config->writeEntry("ViewerLayout",list ); |
2004 | wid = mDialogManager->getSearchDialog(); | 2004 | wid = mDialogManager->getSearchDialog(); |
2005 | if ( wid ) { | 2005 | if ( wid ) { |
2006 | x = wid->geometry().x(); | 2006 | x = wid->geometry().x(); |
2007 | y = wid->geometry().y(); | 2007 | y = wid->geometry().y(); |
2008 | w = wid->width(); | 2008 | w = wid->width(); |
2009 | h = wid->height(); | 2009 | h = wid->height(); |
2010 | list.clear(); | 2010 | list.clear(); |
2011 | list << QString::number( x ); | 2011 | list << QString::number( x ); |
2012 | list << QString::number( y ); | 2012 | list << QString::number( y ); |
2013 | list << QString::number( w ); | 2013 | list << QString::number( w ); |
2014 | list << QString::number( h ); | 2014 | list << QString::number( h ); |
2015 | config->writeEntry("SearchLayout",list ); | 2015 | config->writeEntry("SearchLayout",list ); |
2016 | } | 2016 | } |
2017 | #endif | 2017 | #endif |
2018 | 2018 | ||
2019 | 2019 | ||
2020 | config->sync(); | 2020 | config->sync(); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | void CalendarView::readFilterSettings(KConfig *config) | 2023 | void CalendarView::readFilterSettings(KConfig *config) |
2024 | { | 2024 | { |
2025 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2025 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2026 | 2026 | ||
2027 | mFilters.clear(); | 2027 | mFilters.clear(); |
2028 | 2028 | ||
2029 | config->setGroup("General"); | 2029 | config->setGroup("General"); |
2030 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2030 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2031 | 2031 | ||
2032 | QStringList::ConstIterator it = filterList.begin(); | 2032 | QStringList::ConstIterator it = filterList.begin(); |
2033 | QStringList::ConstIterator end = filterList.end(); | 2033 | QStringList::ConstIterator end = filterList.end(); |
2034 | while(it != end) { | 2034 | while(it != end) { |
2035 | // kdDebug() << " filter: " << (*it) << endl; | 2035 | // kdDebug() << " filter: " << (*it) << endl; |
2036 | 2036 | ||
2037 | CalFilter *filter; | 2037 | CalFilter *filter; |
2038 | filter = new CalFilter(*it); | 2038 | filter = new CalFilter(*it); |
2039 | config->setGroup("Filter_" + (*it)); | 2039 | config->setGroup("Filter_" + (*it)); |
2040 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2040 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2041 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2041 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2042 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2042 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2043 | mFilters.append(filter); | 2043 | mFilters.append(filter); |
2044 | 2044 | ||
2045 | ++it; | 2045 | ++it; |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | if (mFilters.count() == 0) { | 2048 | if (mFilters.count() == 0) { |
2049 | CalFilter *filter = new CalFilter(i18n("Default")); | 2049 | CalFilter *filter = new CalFilter(i18n("Default")); |
2050 | mFilters.append(filter); | 2050 | mFilters.append(filter); |
2051 | } | 2051 | } |
2052 | mFilterView->updateFilters(); | 2052 | mFilterView->updateFilters(); |
2053 | config->setGroup("FilterView"); | 2053 | config->setGroup("FilterView"); |
2054 | 2054 | ||
2055 | mFilterView->blockSignals(true); | 2055 | mFilterView->blockSignals(true); |
2056 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2056 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2057 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2057 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2058 | mFilterView->blockSignals(false); | 2058 | mFilterView->blockSignals(false); |
2059 | // We do it manually to avoid it being done twice by the above calls | 2059 | // We do it manually to avoid it being done twice by the above calls |
2060 | updateFilter(); | 2060 | updateFilter(); |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void CalendarView::writeFilterSettings(KConfig *config) | 2063 | void CalendarView::writeFilterSettings(KConfig *config) |
2064 | { | 2064 | { |
2065 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2065 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2066 | 2066 | ||
2067 | QStringList filterList; | 2067 | QStringList filterList; |
2068 | 2068 | ||
2069 | CalFilter *filter = mFilters.first(); | 2069 | CalFilter *filter = mFilters.first(); |
2070 | while(filter) { | 2070 | while(filter) { |
2071 | // kdDebug() << " fn: " << filter->name() << endl; | 2071 | // kdDebug() << " fn: " << filter->name() << endl; |
2072 | filterList << filter->name(); | 2072 | filterList << filter->name(); |
2073 | config->setGroup("Filter_" + filter->name()); | 2073 | config->setGroup("Filter_" + filter->name()); |
2074 | config->writeEntry("Criteria",filter->criteria()); | 2074 | config->writeEntry("Criteria",filter->criteria()); |
2075 | config->writeEntry("CategoryList",filter->categoryList()); | 2075 | config->writeEntry("CategoryList",filter->categoryList()); |
2076 | filter = mFilters.next(); | 2076 | filter = mFilters.next(); |
2077 | } | 2077 | } |
2078 | config->setGroup("General"); | 2078 | config->setGroup("General"); |
2079 | config->writeEntry("CalendarFilters",filterList); | 2079 | config->writeEntry("CalendarFilters",filterList); |
2080 | 2080 | ||
2081 | config->setGroup("FilterView"); | 2081 | config->setGroup("FilterView"); |
2082 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2082 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2083 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2083 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2084 | } | 2084 | } |
2085 | 2085 | ||
2086 | 2086 | ||
2087 | void CalendarView::goToday() | 2087 | void CalendarView::goToday() |
2088 | { | 2088 | { |
2089 | if ( mViewManager->currentView()->isMonthView() ) | 2089 | if ( mViewManager->currentView()->isMonthView() ) |
2090 | mNavigator->selectTodayMonth(); | 2090 | mNavigator->selectTodayMonth(); |
2091 | else | 2091 | else |
2092 | mNavigator->selectToday(); | 2092 | mNavigator->selectToday(); |
2093 | } | 2093 | } |
2094 | 2094 | ||
2095 | void CalendarView::goNext() | 2095 | void CalendarView::goNext() |
2096 | { | 2096 | { |
2097 | mNavigator->selectNext(); | 2097 | mNavigator->selectNext(); |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void CalendarView::goPrevious() | 2100 | void CalendarView::goPrevious() |
2101 | { | 2101 | { |
2102 | mNavigator->selectPrevious(); | 2102 | mNavigator->selectPrevious(); |
2103 | } | 2103 | } |
2104 | void CalendarView::goNextMonth() | 2104 | void CalendarView::goNextMonth() |
2105 | { | 2105 | { |
2106 | mNavigator->selectNextMonth(); | 2106 | mNavigator->selectNextMonth(); |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::goPreviousMonth() | 2109 | void CalendarView::goPreviousMonth() |
2110 | { | 2110 | { |
2111 | mNavigator->selectPreviousMonth(); | 2111 | mNavigator->selectPreviousMonth(); |
2112 | } | 2112 | } |
2113 | void CalendarView::writeLocale() | 2113 | void CalendarView::writeLocale() |
2114 | { | 2114 | { |
2115 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2115 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2116 | #if 0 | 2116 | #if 0 |
2117 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2117 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2118 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2118 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2119 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2119 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2120 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2120 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2121 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2121 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2122 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2122 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2123 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2123 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2124 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2124 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2125 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2125 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2126 | KOPrefs::instance()->mDaylightsavingStart, | 2126 | KOPrefs::instance()->mDaylightsavingStart, |
2127 | KOPrefs::instance()->mDaylightsavingEnd ); | 2127 | KOPrefs::instance()->mDaylightsavingEnd ); |
2128 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2128 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2129 | #endif | 2129 | #endif |
2130 | } | 2130 | } |
2131 | void CalendarView::updateConfig() | 2131 | void CalendarView::updateConfig() |
2132 | { | 2132 | { |
2133 | writeLocale(); | 2133 | writeLocale(); |
2134 | if ( KOPrefs::instance()->mUseAppColors ) | 2134 | if ( KOPrefs::instance()->mUseAppColors ) |
2135 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2135 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2136 | emit configChanged(); | 2136 | emit configChanged(); |
2137 | mTodoList->updateConfig(); | 2137 | mTodoList->updateConfig(); |
2138 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2138 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2139 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2139 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2140 | // To make the "fill window" configurations work | 2140 | // To make the "fill window" configurations work |
2141 | //mViewManager->raiseCurrentView(); | 2141 | //mViewManager->raiseCurrentView(); |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | 2144 | ||
2145 | void CalendarView::eventChanged(Event *event) | 2145 | void CalendarView::eventChanged(Event *event) |
2146 | { | 2146 | { |
2147 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2147 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2148 | //updateUnmanagedViews(); | 2148 | //updateUnmanagedViews(); |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | void CalendarView::eventAdded(Event *event) | 2151 | void CalendarView::eventAdded(Event *event) |
2152 | { | 2152 | { |
2153 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2153 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2154 | } | 2154 | } |
2155 | 2155 | ||
2156 | void CalendarView::eventToBeDeleted(Event *) | 2156 | void CalendarView::eventToBeDeleted(Event *) |
2157 | { | 2157 | { |
2158 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2158 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2159 | } | 2159 | } |
2160 | 2160 | ||
2161 | void CalendarView::eventDeleted() | 2161 | void CalendarView::eventDeleted() |
2162 | { | 2162 | { |
2163 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2163 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2164 | } | 2164 | } |
2165 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2165 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2166 | { | 2166 | { |
2167 | changeIncidenceDisplay((Incidence *)which, action); | 2167 | changeIncidenceDisplay((Incidence *)which, action); |
2168 | mDateNavigator->updateView(); //LR | 2168 | mDateNavigator->updateView(); //LR |
2169 | //mDialogManager->updateSearchDialog(); | 2169 | //mDialogManager->updateSearchDialog(); |
2170 | 2170 | ||
2171 | if (which) { | 2171 | if (which) { |
2172 | mViewManager->updateWNview(); | 2172 | mViewManager->updateWNview(); |
2173 | //mTodoList->updateView(); | 2173 | //mTodoList->updateView(); |
2174 | } | 2174 | } |
2175 | 2175 | ||
2176 | } | 2176 | } |
2177 | 2177 | ||
2178 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2178 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2179 | { | 2179 | { |
2180 | updateUnmanagedViews(); | 2180 | updateUnmanagedViews(); |
2181 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2181 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2182 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2182 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2183 | mCalendar->checkAlarmForIncidence( 0, true ); | 2183 | mCalendar->checkAlarmForIncidence( 0, true ); |
2184 | if ( mEventViewerDialog ) | 2184 | if ( mEventViewerDialog ) |
2185 | mEventViewerDialog->hide(); | 2185 | mEventViewerDialog->hide(); |
2186 | } | 2186 | } |
2187 | else | 2187 | else |
2188 | mCalendar->checkAlarmForIncidence( which , false ); | 2188 | mCalendar->checkAlarmForIncidence( which , false ); |
2189 | } | 2189 | } |
2190 | 2190 | ||
2191 | // most of the changeEventDisplays() right now just call the view's | 2191 | // most of the changeEventDisplays() right now just call the view's |
2192 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2192 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2193 | void CalendarView::changeEventDisplay(Event *which, int action) | 2193 | void CalendarView::changeEventDisplay(Event *which, int action) |
2194 | { | 2194 | { |
2195 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2195 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2196 | changeIncidenceDisplay((Incidence *)which, action); | 2196 | changeIncidenceDisplay((Incidence *)which, action); |
2197 | mDateNavigator->updateView(); | 2197 | mDateNavigator->updateView(); |
2198 | //mDialogManager->updateSearchDialog(); | 2198 | //mDialogManager->updateSearchDialog(); |
2199 | 2199 | ||
2200 | if (which) { | 2200 | if (which) { |
2201 | // If there is an event view visible update the display | 2201 | // If there is an event view visible update the display |
2202 | mViewManager->currentView()->changeEventDisplay(which,action); | 2202 | mViewManager->currentView()->changeEventDisplay(which,action); |
2203 | // TODO: check, if update needed | 2203 | // TODO: check, if update needed |
2204 | // if (which->getTodoStatus()) { | 2204 | // if (which->getTodoStatus()) { |
2205 | mTodoList->updateView(); | 2205 | mTodoList->updateView(); |
2206 | // } | 2206 | // } |
2207 | } else { | 2207 | } else { |
2208 | mViewManager->currentView()->updateView(); | 2208 | mViewManager->currentView()->updateView(); |
2209 | } | 2209 | } |
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | 2212 | ||
2213 | void CalendarView::updateTodoViews() | 2213 | void CalendarView::updateTodoViews() |
2214 | { | 2214 | { |
2215 | mTodoList->updateView(); | 2215 | mTodoList->updateView(); |
2216 | mViewManager->currentView()->updateView(); | 2216 | mViewManager->currentView()->updateView(); |
2217 | 2217 | ||
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | 2220 | ||
2221 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2221 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2222 | { | 2222 | { |
2223 | mTodoList->updateView(); | 2223 | mTodoList->updateView(); |
2224 | mViewManager->updateView(start, end); | 2224 | mViewManager->updateView(start, end); |
2225 | //mDateNavigator->updateView(); | 2225 | //mDateNavigator->updateView(); |
2226 | } | 2226 | } |
2227 | 2227 | ||
2228 | void CalendarView::updateView() | 2228 | void CalendarView::updateView() |
2229 | { | 2229 | { |
2230 | DateList tmpList = mNavigator->selectedDates(); | 2230 | DateList tmpList = mNavigator->selectedDates(); |
2231 | 2231 | ||
2232 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2232 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2233 | mTodoList->updateView(); | 2233 | mTodoList->updateView(); |
2234 | // We assume that the navigator only selects consecutive days. | 2234 | // We assume that the navigator only selects consecutive days. |
2235 | updateView( tmpList.first(), tmpList.last() ); | 2235 | updateView( tmpList.first(), tmpList.last() ); |
2236 | } | 2236 | } |
2237 | 2237 | ||
2238 | void CalendarView::updateUnmanagedViews() | 2238 | void CalendarView::updateUnmanagedViews() |
2239 | { | 2239 | { |
2240 | mDateNavigator->updateDayMatrix(); | 2240 | mDateNavigator->updateDayMatrix(); |
2241 | } | 2241 | } |
2242 | 2242 | ||
2243 | int CalendarView::msgItemDelete(const QString name) | 2243 | int CalendarView::msgItemDelete(const QString name) |
2244 | { | 2244 | { |
2245 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2245 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2246 | i18n("This item will be\npermanently deleted."), | 2246 | i18n("This item will be\npermanently deleted."), |
2247 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2247 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2248 | } | 2248 | } |
2249 | 2249 | ||
2250 | 2250 | ||
2251 | void CalendarView::edit_cut() | 2251 | void CalendarView::edit_cut() |
2252 | { | 2252 | { |
2253 | Event *anEvent=0; | 2253 | Event *anEvent=0; |
2254 | 2254 | ||
2255 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2255 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2256 | 2256 | ||
2257 | if (mViewManager->currentView()->isEventView()) { | 2257 | if (mViewManager->currentView()->isEventView()) { |
2258 | if ( incidence && incidence->type() == "Event" ) { | 2258 | if ( incidence && incidence->type() == "Event" ) { |
2259 | anEvent = static_cast<Event *>(incidence); | 2259 | anEvent = static_cast<Event *>(incidence); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | if (!anEvent) { | 2263 | if (!anEvent) { |
2264 | KNotifyClient::beep(); | 2264 | KNotifyClient::beep(); |
2265 | return; | 2265 | return; |
2266 | } | 2266 | } |
2267 | DndFactory factory( mCalendar ); | 2267 | DndFactory factory( mCalendar ); |
2268 | factory.cutIncidence(anEvent); | 2268 | factory.cutIncidence(anEvent); |
2269 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2269 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2270 | } | 2270 | } |
2271 | 2271 | ||
2272 | void CalendarView::edit_copy() | 2272 | void CalendarView::edit_copy() |
2273 | { | 2273 | { |
2274 | Event *anEvent=0; | 2274 | Event *anEvent=0; |
2275 | 2275 | ||
2276 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2276 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2277 | 2277 | ||
2278 | if (mViewManager->currentView()->isEventView()) { | 2278 | if (mViewManager->currentView()->isEventView()) { |
2279 | if ( incidence && incidence->type() == "Event" ) { | 2279 | if ( incidence && incidence->type() == "Event" ) { |
2280 | anEvent = static_cast<Event *>(incidence); | 2280 | anEvent = static_cast<Event *>(incidence); |
2281 | } | 2281 | } |
2282 | } | 2282 | } |
2283 | 2283 | ||
2284 | if (!anEvent) { | 2284 | if (!anEvent) { |
2285 | KNotifyClient::beep(); | 2285 | KNotifyClient::beep(); |
2286 | return; | 2286 | return; |
2287 | } | 2287 | } |
2288 | DndFactory factory( mCalendar ); | 2288 | DndFactory factory( mCalendar ); |
2289 | factory.copyIncidence(anEvent); | 2289 | factory.copyIncidence(anEvent); |
2290 | } | 2290 | } |
2291 | 2291 | ||
2292 | void CalendarView::edit_paste() | 2292 | void CalendarView::edit_paste() |
2293 | { | 2293 | { |
2294 | QDate date = mNavigator->selectedDates().first(); | 2294 | QDate date = mNavigator->selectedDates().first(); |
2295 | 2295 | ||
2296 | DndFactory factory( mCalendar ); | 2296 | DndFactory factory( mCalendar ); |
2297 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2297 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2298 | 2298 | ||
2299 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2299 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | void CalendarView::edit_options() | 2302 | void CalendarView::edit_options() |
2303 | { | 2303 | { |
2304 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2304 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2305 | emit save(); | 2305 | emit save(); |
2306 | emit saveStopTimer(); | 2306 | emit saveStopTimer(); |
2307 | mDialogManager->showOptionsDialog(); | 2307 | mDialogManager->showOptionsDialog(); |
2308 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2308 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2309 | emit saveStopTimer(); | 2309 | emit saveStopTimer(); |
2310 | 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!"), | 2310 | 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!"), |
2311 | i18n("Timezone settings"),i18n("Reload"))) { | 2311 | i18n("Timezone settings"),i18n("Reload"))) { |
2312 | qDebug("KO: TZ reload cancelled "); | 2312 | qDebug("KO: TZ reload cancelled "); |
2313 | return; | 2313 | return; |
2314 | } | 2314 | } |
2315 | qDebug("KO: Timezone change "); | 2315 | qDebug("KO: Timezone change "); |
2316 | openCalendar( MainWindow::defaultFileName() ); | 2316 | openCalendar( MainWindow::defaultFileName() ); |
2317 | setModified(true); | 2317 | setModified(true); |
2318 | } | 2318 | } |
2319 | else | 2319 | else |
2320 | qDebug("KO: No tz change "); | 2320 | qDebug("KO: No tz change "); |
2321 | 2321 | ||
2322 | } | 2322 | } |
2323 | 2323 | ||
2324 | 2324 | ||
2325 | void CalendarView::slotSelectPickerDate( QDate d) | 2325 | void CalendarView::slotSelectPickerDate( QDate d) |
2326 | { | 2326 | { |
2327 | mDateFrame->hide(); | 2327 | mDateFrame->hide(); |
2328 | if ( mDatePickerMode == 1 ) { | 2328 | if ( mDatePickerMode == 1 ) { |
2329 | mNavigator->slotDaySelect( d ); | 2329 | mNavigator->slotDaySelect( d ); |
2330 | } else if ( mDatePickerMode == 2 ) { | 2330 | } else if ( mDatePickerMode == 2 ) { |
2331 | if ( mMoveIncidence->type() == "Todo" ) { | 2331 | if ( mMoveIncidence->type() == "Todo" ) { |
2332 | Todo * to = (Todo *) mMoveIncidence; | 2332 | Todo * to = (Todo *) mMoveIncidence; |
2333 | QTime tim; | 2333 | QTime tim; |
2334 | int len = 0; | 2334 | int len = 0; |
2335 | if ( to->hasStartDate() && to->hasDueDate() ) | 2335 | if ( to->hasStartDate() && to->hasDueDate() ) |
2336 | len = to->dtStart().secsTo( to->dtDue()); | 2336 | len = to->dtStart().secsTo( to->dtDue()); |
2337 | if ( to->hasDueDate() ) | 2337 | if ( to->hasDueDate() ) |
2338 | tim = to->dtDue().time(); | 2338 | tim = to->dtDue().time(); |
2339 | else { | 2339 | else { |
2340 | tim = QTime ( 0,0,0 ); | 2340 | tim = QTime ( 0,0,0 ); |
2341 | to->setFloats( true ); | 2341 | to->setFloats( true ); |
2342 | to->setHasDueDate( true ); | 2342 | to->setHasDueDate( true ); |
2343 | } | 2343 | } |
2344 | QDateTime dt ( d,tim ); | 2344 | QDateTime dt ( d,tim ); |
2345 | to->setDtDue( dt ); | 2345 | to->setDtDue( dt ); |
2346 | 2346 | ||
2347 | if ( to->hasStartDate() ) { | 2347 | if ( to->hasStartDate() ) { |
2348 | if ( len>0 ) | 2348 | if ( len>0 ) |
2349 | to->setDtStart(to->dtDue().addSecs( -len )); | 2349 | to->setDtStart(to->dtDue().addSecs( -len )); |
2350 | else | 2350 | else |
2351 | if (to->dtStart() > to->dtDue() ) | 2351 | if (to->dtStart() > to->dtDue() ) |
2352 | to->setDtStart(to->dtDue().addDays( -3 )); | 2352 | to->setDtStart(to->dtDue().addDays( -3 )); |
2353 | } | 2353 | } |
2354 | 2354 | ||
2355 | todoChanged( to ); | 2355 | todoChanged( to ); |
2356 | } else { | 2356 | } else { |
2357 | if ( mMoveIncidence->doesRecur() ) { | 2357 | if ( mMoveIncidence->doesRecur() ) { |
2358 | #if 0 | 2358 | #if 0 |
2359 | // PENDING implement this | 2359 | // PENDING implement this |
2360 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2360 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2361 | mCalendar()->addIncidence( newInc ); | 2361 | mCalendar()->addIncidence( newInc ); |
2362 | if ( mMoveIncidence->type() == "Todo" ) | 2362 | if ( mMoveIncidence->type() == "Todo" ) |
2363 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2363 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2364 | else | 2364 | else |
2365 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2365 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2366 | mMoveIncidence = newInc; | 2366 | mMoveIncidence = newInc; |
2367 | 2367 | ||
2368 | #endif | 2368 | #endif |
2369 | } | 2369 | } |
2370 | QTime tim = mMoveIncidence->dtStart().time(); | 2370 | QTime tim = mMoveIncidence->dtStart().time(); |
2371 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2371 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2372 | QDateTime dt ( d,tim ); | 2372 | QDateTime dt ( d,tim ); |
2373 | mMoveIncidence->setDtStart( dt ); | 2373 | mMoveIncidence->setDtStart( dt ); |
2374 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2374 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2375 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2375 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2376 | } | 2376 | } |
2377 | 2377 | ||
2378 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2378 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2379 | } | 2379 | } |
2380 | } | 2380 | } |
2381 | 2381 | ||
2382 | void CalendarView::removeCategories() | 2382 | void CalendarView::removeCategories() |
2383 | { | 2383 | { |
2384 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2384 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2385 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2385 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2386 | QStringList catIncList; | 2386 | QStringList catIncList; |
2387 | QStringList newCatList; | 2387 | QStringList newCatList; |
2388 | Incidence* inc = incList.first(); | 2388 | Incidence* inc = incList.first(); |
2389 | int i; | 2389 | int i; |
2390 | int count = 0; | 2390 | int count = 0; |
2391 | while ( inc ) { | 2391 | while ( inc ) { |
2392 | newCatList.clear(); | 2392 | newCatList.clear(); |
2393 | catIncList = inc->categories() ; | 2393 | catIncList = inc->categories() ; |
2394 | for( i = 0; i< catIncList.count(); ++i ) { | 2394 | for( i = 0; i< catIncList.count(); ++i ) { |
2395 | if ( catList.contains (catIncList[i])) | 2395 | if ( catList.contains (catIncList[i])) |
2396 | newCatList.append( catIncList[i] ); | 2396 | newCatList.append( catIncList[i] ); |
2397 | } | 2397 | } |
2398 | newCatList.sort(); | 2398 | newCatList.sort(); |
2399 | inc->setCategories( newCatList.join(",") ); | 2399 | inc->setCategories( newCatList.join(",") ); |
2400 | inc = incList.next(); | 2400 | inc = incList.next(); |
2401 | } | 2401 | } |
2402 | } | 2402 | } |
2403 | 2403 | ||
2404 | int CalendarView::addCategories() | 2404 | int CalendarView::addCategories() |
2405 | { | 2405 | { |
2406 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2406 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2407 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2407 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2408 | QStringList catIncList; | 2408 | QStringList catIncList; |
2409 | Incidence* inc = incList.first(); | 2409 | Incidence* inc = incList.first(); |
2410 | int i; | 2410 | int i; |
2411 | int count = 0; | 2411 | int count = 0; |
2412 | while ( inc ) { | 2412 | while ( inc ) { |
2413 | catIncList = inc->categories() ; | 2413 | catIncList = inc->categories() ; |
2414 | for( i = 0; i< catIncList.count(); ++i ) { | 2414 | for( i = 0; i< catIncList.count(); ++i ) { |
2415 | if ( !catList.contains (catIncList[i])) { | 2415 | if ( !catList.contains (catIncList[i])) { |
2416 | catList.append( catIncList[i] ); | 2416 | catList.append( catIncList[i] ); |
2417 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2417 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2418 | ++count; | 2418 | ++count; |
2419 | } | 2419 | } |
2420 | } | 2420 | } |
2421 | inc = incList.next(); | 2421 | inc = incList.next(); |
2422 | } | 2422 | } |
2423 | catList.sort(); | 2423 | catList.sort(); |
2424 | KOPrefs::instance()->mCustomCategories = catList; | 2424 | KOPrefs::instance()->mCustomCategories = catList; |
2425 | return count; | 2425 | return count; |
2426 | } | 2426 | } |
2427 | 2427 | ||
2428 | void CalendarView::manageCategories() | 2428 | void CalendarView::manageCategories() |
2429 | { | 2429 | { |
2430 | KOCatPrefs* cp = new KOCatPrefs(); | 2430 | KOCatPrefs* cp = new KOCatPrefs(); |
2431 | cp->show(); | 2431 | cp->show(); |
2432 | int w =cp->sizeHint().width() ; | 2432 | int w =cp->sizeHint().width() ; |
2433 | int h = cp->sizeHint().height() ; | 2433 | int h = cp->sizeHint().height() ; |
2434 | int dw = QApplication::desktop()->width(); | 2434 | int dw = QApplication::desktop()->width(); |
2435 | int dh = QApplication::desktop()->height(); | 2435 | int dh = QApplication::desktop()->height(); |
2436 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2436 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2437 | if ( !cp->exec() ) { | 2437 | if ( !cp->exec() ) { |
2438 | delete cp; | 2438 | delete cp; |
2439 | return; | 2439 | return; |
2440 | } | 2440 | } |
2441 | int count = 0; | 2441 | int count = 0; |
2442 | if ( cp->addCat() ) { | 2442 | if ( cp->addCat() ) { |
2443 | count = addCategories(); | 2443 | count = addCategories(); |
2444 | if ( count ) { | 2444 | if ( count ) { |
2445 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2445 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2446 | writeSettings(); | 2446 | writeSettings(); |
2447 | } else | 2447 | } else |
2448 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2448 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2449 | } else { | 2449 | } else { |
2450 | removeCategories(); | 2450 | removeCategories(); |
2451 | updateView(); | 2451 | updateView(); |
2452 | } | 2452 | } |
2453 | delete cp; | 2453 | delete cp; |
2454 | } | 2454 | } |
2455 | 2455 | ||
2456 | void CalendarView::beamIncidence(Incidence * Inc) | 2456 | void CalendarView::beamIncidence(Incidence * Inc) |
2457 | { | 2457 | { |
2458 | QPtrList<Incidence> delSel ; | 2458 | QPtrList<Incidence> delSel ; |
2459 | delSel.append(Inc); | 2459 | delSel.append(Inc); |
2460 | beamIncidenceList( delSel ); | 2460 | beamIncidenceList( delSel ); |
2461 | } | 2461 | } |
2462 | void CalendarView::beamCalendar() | 2462 | void CalendarView::beamCalendar() |
2463 | { | 2463 | { |
2464 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2464 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2465 | //qDebug("beamCalendar() "); | 2465 | //qDebug("beamCalendar() "); |
2466 | beamIncidenceList( delSel ); | 2466 | beamIncidenceList( delSel ); |
2467 | } | 2467 | } |
2468 | void CalendarView::beamFilteredCalendar() | 2468 | void CalendarView::beamFilteredCalendar() |
2469 | { | 2469 | { |
2470 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2470 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2471 | //qDebug("beamFilteredCalendar() "); | 2471 | //qDebug("beamFilteredCalendar() "); |
2472 | beamIncidenceList( delSel ); | 2472 | beamIncidenceList( delSel ); |
2473 | } | 2473 | } |
2474 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2474 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2475 | { | 2475 | { |
2476 | if ( beamDialog->exec () == QDialog::Rejected ) | 2476 | if ( beamDialog->exec () == QDialog::Rejected ) |
2477 | return; | 2477 | return; |
2478 | #ifdef DESKTOP_VERSION | 2478 | #ifdef DESKTOP_VERSION |
2479 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2479 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2480 | #else | 2480 | #else |
2481 | QString fn = "/tmp/kopibeamfile"; | 2481 | QString fn = "/tmp/kopibeamfile"; |
2482 | #endif | 2482 | #endif |
2483 | QString mes; | 2483 | QString mes; |
2484 | bool createbup = true; | 2484 | bool createbup = true; |
2485 | if ( createbup ) { | 2485 | if ( createbup ) { |
2486 | QString description = "\n"; | 2486 | QString description = "\n"; |
2487 | CalendarLocal* cal = new CalendarLocal(); | 2487 | CalendarLocal* cal = new CalendarLocal(); |
2488 | if ( beamDialog->beamLocal() ) | 2488 | if ( beamDialog->beamLocal() ) |
2489 | cal->setLocalTime(); | 2489 | cal->setLocalTime(); |
2490 | else | 2490 | else |
2491 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2491 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2492 | Incidence *incidence = delSel.first(); | 2492 | Incidence *incidence = delSel.first(); |
2493 | bool addText = false; | 2493 | bool addText = false; |
2494 | if ( delSel.count() < 10 ) | 2494 | if ( delSel.count() < 10 ) |
2495 | addText = true; | 2495 | addText = true; |
2496 | else { | 2496 | else { |
2497 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2497 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2498 | } | 2498 | } |
2499 | while ( incidence ) { | 2499 | while ( incidence ) { |
2500 | Incidence *in = incidence->clone(); | 2500 | Incidence *in = incidence->clone(); |
2501 | if ( ! in->summary().isEmpty() ) { | 2501 | if ( ! in->summary().isEmpty() ) { |
2502 | in->setDescription(""); | 2502 | in->setDescription(""); |
2503 | } else { | 2503 | } else { |
2504 | in->setSummary( in->description().left(20)); | 2504 | in->setSummary( in->description().left(20)); |
2505 | in->setDescription(""); | 2505 | in->setDescription(""); |
2506 | } | 2506 | } |
2507 | if ( addText ) | 2507 | if ( addText ) |
2508 | description += in->summary() + "\n"; | 2508 | description += in->summary() + "\n"; |
2509 | cal->addIncidence( in ); | 2509 | cal->addIncidence( in ); |
2510 | incidence = delSel.next(); | 2510 | incidence = delSel.next(); |
2511 | } | 2511 | } |
2512 | if ( beamDialog->beamVcal() ) { | 2512 | if ( beamDialog->beamVcal() ) { |
2513 | fn += ".vcs"; | 2513 | fn += ".vcs"; |
2514 | FileStorage storage( cal, fn, new VCalFormat ); | 2514 | FileStorage storage( cal, fn, new VCalFormat ); |
2515 | storage.save(); | 2515 | storage.save(); |
2516 | } else { | 2516 | } else { |
2517 | fn += ".ics"; | 2517 | fn += ".ics"; |
2518 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2518 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2519 | storage.save(); | 2519 | storage.save(); |
2520 | } | 2520 | } |
2521 | delete cal; | 2521 | delete cal; |
2522 | mes = i18n("KO/Pi: Ready for beaming"); | 2522 | mes = i18n("KO/Pi: Ready for beaming"); |
2523 | topLevelWidget()->setCaption(mes); | 2523 | topLevelWidget()->setCaption(mes); |
2524 | KApplication::convert2latin1( fn ); | 2524 | KApplication::convert2latin1( fn ); |
2525 | #ifndef DESKTOP_VERSION | 2525 | #ifndef DESKTOP_VERSION |
2526 | Ir *ir = new Ir( this ); | 2526 | Ir *ir = new Ir( this ); |
2527 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2527 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2528 | ir->send( fn, description, "text/x-vCalendar" ); | 2528 | ir->send( fn, description, "text/x-vCalendar" ); |
2529 | #endif | 2529 | #endif |
2530 | } | 2530 | } |
2531 | } | 2531 | } |
2532 | void CalendarView::beamDone( Ir *ir ) | 2532 | void CalendarView::beamDone( Ir *ir ) |
2533 | { | 2533 | { |
2534 | #ifndef DESKTOP_VERSION | 2534 | #ifndef DESKTOP_VERSION |
2535 | delete ir; | 2535 | delete ir; |
2536 | #endif | 2536 | #endif |
2537 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2537 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2538 | topLevelWidget()->raise(); | 2538 | topLevelWidget()->raise(); |
2539 | } | 2539 | } |
2540 | 2540 | ||
2541 | void CalendarView::moveIncidence(Incidence * inc ) | 2541 | void CalendarView::moveIncidence(Incidence * inc ) |
2542 | { | 2542 | { |
2543 | if ( !inc ) return; | 2543 | if ( !inc ) return; |
2544 | showDatePickerPopup(); | 2544 | showDatePickerPopup(); |
2545 | mDatePickerMode = 2; | 2545 | mDatePickerMode = 2; |
2546 | mMoveIncidence = inc ; | 2546 | mMoveIncidence = inc ; |
2547 | QDate da; | 2547 | QDate da; |
2548 | if ( mMoveIncidence->type() == "Todo" ) { | 2548 | if ( mMoveIncidence->type() == "Todo" ) { |
2549 | Todo * to = (Todo *) mMoveIncidence; | 2549 | Todo * to = (Todo *) mMoveIncidence; |
2550 | if ( to->hasDueDate() ) | 2550 | if ( to->hasDueDate() ) |
2551 | da = to->dtDue().date(); | 2551 | da = to->dtDue().date(); |
2552 | else | 2552 | else |
2553 | da = QDate::currentDate(); | 2553 | da = QDate::currentDate(); |
2554 | } else { | 2554 | } else { |
2555 | da = mMoveIncidence->dtStart().date(); | 2555 | da = mMoveIncidence->dtStart().date(); |
2556 | } | 2556 | } |
2557 | //PENDING set date for recurring incidence to date of recurrence | 2557 | //PENDING set date for recurring incidence to date of recurrence |
2558 | //mMoveIncidenceOldDate; | 2558 | //mMoveIncidenceOldDate; |
2559 | mDatePicker->setDate( da ); | 2559 | mDatePicker->setDate( da ); |
2560 | } | 2560 | } |
2561 | void CalendarView::showDatePickerPopup() | 2561 | void CalendarView::showDatePickerPopup() |
2562 | { | 2562 | { |
2563 | if ( mDateFrame->isVisible() ) | 2563 | if ( mDateFrame->isVisible() ) |
2564 | mDateFrame->hide(); | 2564 | mDateFrame->hide(); |
2565 | else { | 2565 | else { |
2566 | int offX = 0, offY = 0; | 2566 | int offX = 0, offY = 0; |
2567 | #ifdef DESKTOP_VERSION | 2567 | #ifdef DESKTOP_VERSION |
2568 | int w =mDatePicker->sizeHint().width() ; | 2568 | int w =mDatePicker->sizeHint().width() ; |
2569 | int h = mDatePicker->sizeHint().height() ; | 2569 | int h = mDatePicker->sizeHint().height() ; |
2570 | int dw = topLevelWidget()->width(); | 2570 | int dw = topLevelWidget()->width(); |
2571 | int dh = topLevelWidget()->height(); | 2571 | int dh = topLevelWidget()->height(); |
2572 | offX = topLevelWidget()->x(); | 2572 | offX = topLevelWidget()->x(); |
2573 | offY = topLevelWidget()->y(); | 2573 | offY = topLevelWidget()->y(); |
2574 | #else | 2574 | #else |
2575 | int w =mDatePicker->sizeHint().width() ; | 2575 | int w =mDatePicker->sizeHint().width() ; |
2576 | int h = mDatePicker->sizeHint().height() ; | 2576 | int h = mDatePicker->sizeHint().height() ; |
2577 | int dw = QApplication::desktop()->width(); | 2577 | int dw = QApplication::desktop()->width(); |
2578 | int dh = QApplication::desktop()->height(); | 2578 | int dh = QApplication::desktop()->height(); |
2579 | #endif | 2579 | #endif |
2580 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2580 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2581 | mDateFrame->show(); | 2581 | mDateFrame->show(); |
2582 | } | 2582 | } |
2583 | } | 2583 | } |
2584 | void CalendarView::showDatePicker( ) | 2584 | void CalendarView::showDatePicker( ) |
2585 | { | 2585 | { |
2586 | showDatePickerPopup(); | 2586 | showDatePickerPopup(); |
2587 | mDatePickerMode = 1; | 2587 | mDatePickerMode = 1; |
2588 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2588 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2589 | } | 2589 | } |
2590 | 2590 | ||
2591 | void CalendarView::showEventEditor() | 2591 | void CalendarView::showEventEditor() |
2592 | { | 2592 | { |
2593 | #ifdef DESKTOP_VERSION | 2593 | #ifdef DESKTOP_VERSION |
2594 | int x,y,w,h; | 2594 | int x,y,w,h; |
2595 | x = mEventEditor->geometry().x(); | 2595 | x = mEventEditor->geometry().x(); |
2596 | y = mEventEditor->geometry().y(); | 2596 | y = mEventEditor->geometry().y(); |
2597 | w = mEventEditor->width(); | 2597 | w = mEventEditor->width(); |
2598 | h = mEventEditor->height(); | 2598 | h = mEventEditor->height(); |
2599 | mEventEditor->show(); | 2599 | mEventEditor->show(); |
2600 | mEventEditor->setGeometry(x,y,w,h); | 2600 | mEventEditor->setGeometry(x,y,w,h); |
2601 | #else | 2601 | #else |
2602 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2602 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2603 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2603 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2604 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2604 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2605 | qApp->processEvents(); | 2605 | qApp->processEvents(); |
2606 | delete mEventEditor; | 2606 | delete mEventEditor; |
2607 | mEventEditor = mDialogManager->getEventEditor(); | 2607 | mEventEditor = mDialogManager->getEventEditor(); |
2608 | topLevelWidget()->setCaption( i18n("") ); | 2608 | topLevelWidget()->setCaption( i18n("") ); |
2609 | } | 2609 | } |
2610 | mEventEditor->showMaximized(); | 2610 | mEventEditor->showMaximized(); |
2611 | #endif | 2611 | #endif |
2612 | } | 2612 | } |
2613 | void CalendarView::showTodoEditor() | 2613 | void CalendarView::showTodoEditor() |
2614 | { | 2614 | { |
2615 | #ifdef DESKTOP_VERSION | 2615 | #ifdef DESKTOP_VERSION |
2616 | int x,y,w,h; | 2616 | int x,y,w,h; |
2617 | x = mTodoEditor->geometry().x(); | 2617 | x = mTodoEditor->geometry().x(); |
2618 | y = mTodoEditor->geometry().y(); | 2618 | y = mTodoEditor->geometry().y(); |
2619 | w = mTodoEditor->width(); | 2619 | w = mTodoEditor->width(); |
2620 | h = mTodoEditor->height(); | 2620 | h = mTodoEditor->height(); |
2621 | mTodoEditor->show(); | 2621 | mTodoEditor->show(); |
2622 | mTodoEditor->setGeometry(x,y,w,h); | 2622 | mTodoEditor->setGeometry(x,y,w,h); |
2623 | #else | 2623 | #else |
2624 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2624 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2625 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2625 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2626 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2626 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2627 | qApp->processEvents(); | 2627 | qApp->processEvents(); |
2628 | delete mTodoEditor; | 2628 | delete mTodoEditor; |
2629 | mTodoEditor = mDialogManager->getTodoEditor(); | 2629 | mTodoEditor = mDialogManager->getTodoEditor(); |
2630 | topLevelWidget()->setCaption( i18n("") ); | 2630 | topLevelWidget()->setCaption( i18n("") ); |
2631 | } | 2631 | } |
2632 | mTodoEditor->showMaximized(); | 2632 | mTodoEditor->showMaximized(); |
2633 | #endif | 2633 | #endif |
2634 | } | 2634 | } |
2635 | 2635 | ||
2636 | void CalendarView::cloneIncidence() | 2636 | void CalendarView::cloneIncidence() |
2637 | { | 2637 | { |
2638 | Incidence *incidence = currentSelection(); | 2638 | Incidence *incidence = currentSelection(); |
2639 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2639 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2640 | if ( incidence ) { | 2640 | if ( incidence ) { |
2641 | cloneIncidence(incidence); | 2641 | cloneIncidence(incidence); |
2642 | } | 2642 | } |
2643 | } | 2643 | } |
2644 | void CalendarView::moveIncidence() | 2644 | void CalendarView::moveIncidence() |
2645 | { | 2645 | { |
2646 | Incidence *incidence = currentSelection(); | 2646 | Incidence *incidence = currentSelection(); |
2647 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2647 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2648 | if ( incidence ) { | 2648 | if ( incidence ) { |
2649 | moveIncidence(incidence); | 2649 | moveIncidence(incidence); |
2650 | } | 2650 | } |
2651 | } | 2651 | } |
2652 | void CalendarView::beamIncidence() | 2652 | void CalendarView::beamIncidence() |
2653 | { | 2653 | { |
2654 | Incidence *incidence = currentSelection(); | 2654 | Incidence *incidence = currentSelection(); |
2655 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2655 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2656 | if ( incidence ) { | 2656 | if ( incidence ) { |
2657 | beamIncidence(incidence); | 2657 | beamIncidence(incidence); |
2658 | } | 2658 | } |
2659 | } | 2659 | } |
2660 | void CalendarView::toggleCancelIncidence() | 2660 | void CalendarView::toggleCancelIncidence() |
2661 | { | 2661 | { |
2662 | Incidence *incidence = currentSelection(); | 2662 | Incidence *incidence = currentSelection(); |
2663 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2663 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2664 | if ( incidence ) { | 2664 | if ( incidence ) { |
2665 | cancelIncidence(incidence); | 2665 | cancelIncidence(incidence); |
2666 | } | 2666 | } |
2667 | } | 2667 | } |
2668 | 2668 | ||
2669 | 2669 | ||
2670 | void CalendarView::cancelIncidence(Incidence * inc ) | 2670 | void CalendarView::cancelIncidence(Incidence * inc ) |
2671 | { | 2671 | { |
2672 | inc->setCancelled( ! inc->cancelled() ); | 2672 | inc->setCancelled( ! inc->cancelled() ); |
2673 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2673 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2674 | updateView(); | 2674 | updateView(); |
2675 | } | 2675 | } |
2676 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2676 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2677 | { | 2677 | { |
2678 | Incidence * newInc = orgInc->clone(); | 2678 | Incidence * newInc = orgInc->clone(); |
2679 | newInc->recreate(); | 2679 | newInc->recreate(); |
2680 | 2680 | ||
2681 | if ( newInc->type() == "Todo" ) { | 2681 | if ( newInc->type() == "Todo" ) { |
2682 | Todo* t = (Todo*) newInc; | 2682 | Todo* t = (Todo*) newInc; |
2683 | showTodoEditor(); | 2683 | showTodoEditor(); |
2684 | mTodoEditor->editTodo( t ); | 2684 | mTodoEditor->editTodo( t ); |
2685 | if ( mTodoEditor->exec() ) { | 2685 | if ( mTodoEditor->exec() ) { |
2686 | mCalendar->addTodo( t ); | 2686 | mCalendar->addTodo( t ); |
2687 | updateView(); | 2687 | updateView(); |
2688 | } else { | 2688 | } else { |
2689 | delete t; | 2689 | delete t; |
2690 | } | 2690 | } |
2691 | } | 2691 | } |
2692 | else { | 2692 | else { |
2693 | Event* e = (Event*) newInc; | 2693 | Event* e = (Event*) newInc; |
2694 | showEventEditor(); | 2694 | showEventEditor(); |
2695 | mEventEditor->editEvent( e ); | 2695 | mEventEditor->editEvent( e ); |
2696 | if ( mEventEditor->exec() ) { | 2696 | if ( mEventEditor->exec() ) { |
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 2290c53..11dc592 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,415 +1,429 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
39 | const char *name ) | 39 | const char *name ) |
40 | : QWidget( parent, name ), mCalendar( 0 ), | 40 | : QWidget( parent, name ), mCalendar( 0 ), |
41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
42 | { | 42 | { |
43 | mResizeEnabled = false; | ||
43 | mExtraViews.setAutoDelete( true ); | 44 | mExtraViews.setAutoDelete( true ); |
44 | 45 | ||
45 | mNavigatorView = new KDateNavigator( this, name ); | 46 | mNavigatorView = new KDateNavigator( this, name ); |
46 | 47 | mNavigatorView->hide(); | |
47 | connectNavigatorView( mNavigatorView ); | 48 | connectNavigatorView( mNavigatorView ); |
48 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 49 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
49 | mLastDisplayedDN = 0; | 50 | mLastDisplayedDN = 0; |
50 | mUpdateTimer; | 51 | mUpdateTimer; |
51 | mUpdateTimer = new QTimer( this ); | 52 | mUpdateTimer = new QTimer( this ); |
52 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); | 53 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); |
53 | mFirstSelectedDate = QDate::currentDate(); | 54 | mFirstSelectedDate = QDate::currentDate(); |
54 | mSelectedDateCount = 1; | 55 | mSelectedDateCount = 1; |
55 | } | 56 | } |
56 | 57 | ||
57 | DateNavigatorContainer::~DateNavigatorContainer() | 58 | DateNavigatorContainer::~DateNavigatorContainer() |
58 | { | 59 | { |
59 | } | 60 | } |
60 | 61 | ||
61 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 62 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
62 | { | 63 | { |
63 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 64 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
64 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 65 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
65 | #if 0 | 66 | #if 0 |
66 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 67 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
67 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 68 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
68 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 69 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
69 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 70 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
70 | #endif | 71 | #endif |
71 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 72 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
72 | SIGNAL( weekClicked( const QDate & ) ) ); | 73 | SIGNAL( weekClicked( const QDate & ) ) ); |
73 | 74 | ||
74 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 75 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
75 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 76 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
76 | 77 | ||
77 | connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); | 78 | connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); |
78 | connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); | 79 | connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); |
79 | connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); | 80 | connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); |
80 | connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); | 81 | connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); |
81 | 82 | ||
82 | connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 83 | connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
83 | } | 84 | } |
84 | void DateNavigatorContainer::slotgoNextYear() | 85 | void DateNavigatorContainer::slotgoNextYear() |
85 | { | 86 | { |
86 | jumpMonth( 12 ); | 87 | jumpMonth( 12 ); |
87 | emit goNextYear(); | 88 | emit goNextYear(); |
88 | 89 | ||
89 | } | 90 | } |
90 | void DateNavigatorContainer::slotgoPrevYear() | 91 | void DateNavigatorContainer::slotgoPrevYear() |
91 | { | 92 | { |
92 | jumpMonth( -12 ); | 93 | jumpMonth( -12 ); |
93 | emit goPrevYear(); | 94 | emit goPrevYear(); |
94 | 95 | ||
95 | } | 96 | } |
96 | void DateNavigatorContainer::slotgoPrevMonth() | 97 | void DateNavigatorContainer::slotgoPrevMonth() |
97 | { | 98 | { |
98 | jumpMonth( -1 ); | 99 | jumpMonth( -1 ); |
99 | emit goPrevMonth(); | 100 | emit goPrevMonth(); |
100 | 101 | ||
101 | } | 102 | } |
102 | void DateNavigatorContainer::slotgoNextMonth() | 103 | void DateNavigatorContainer::slotgoNextMonth() |
103 | { | 104 | { |
104 | jumpMonth( 1 ); | 105 | jumpMonth( 1 ); |
105 | emit goNextMonth(); | 106 | emit goNextMonth(); |
106 | } | 107 | } |
107 | void DateNavigatorContainer::jumpMonth( int month ) | 108 | void DateNavigatorContainer::jumpMonth( int month ) |
108 | { | 109 | { |
109 | 110 | ||
110 | QDate baseDate = mNavigatorView->baseDate(); | 111 | QDate baseDate = mNavigatorView->baseDate(); |
111 | computeMonthSelected( baseDate.month() + month, false ); | 112 | computeMonthSelected( baseDate.month() + month, false ); |
112 | } | 113 | } |
113 | void DateNavigatorContainer::slotMonthSelected( int month ) | 114 | void DateNavigatorContainer::slotMonthSelected( int month ) |
114 | { | 115 | { |
115 | computeMonthSelected( month, true ); | 116 | computeMonthSelected( month, true ); |
116 | } | 117 | } |
117 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) | 118 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) |
118 | { | 119 | { |
119 | //qDebug("slotMonthSelected %d ", month); | 120 | //qDebug("slotMonthSelected %d ", month); |
120 | QDate baseDate = mNavigatorView->baseDate(); | 121 | QDate baseDate = mNavigatorView->baseDate(); |
121 | if ( baseDate.month() == month ) | 122 | if ( baseDate.month() == month ) |
122 | return; | 123 | return; |
123 | //qDebug("month %d %d ",baseDate.month(),month); | 124 | //qDebug("month %d %d ",baseDate.month(),month); |
124 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); | 125 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); |
125 | date = date.addDays( -(baseDate.month()-month ) *30 ); | 126 | date = date.addDays( -(baseDate.month()-month ) *30 ); |
126 | QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); | 127 | QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); |
127 | 128 | ||
128 | //qDebug("NEW BASE %s", newBase.toString().latin1()); | 129 | //qDebug("NEW BASE %s", newBase.toString().latin1()); |
129 | mNavigatorView->setBaseDate( newBase ); | 130 | mNavigatorView->setBaseDate( newBase ); |
130 | QDate last = lastAvailableDate(); | 131 | QDate last = lastAvailableDate(); |
131 | QDate first = firstAvailableDate(); | 132 | QDate first = firstAvailableDate(); |
132 | 133 | ||
133 | QDate selFirst = mFirstSelectedDate; | 134 | QDate selFirst = mFirstSelectedDate; |
134 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 135 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
135 | if ( selFirst >= first && selLast <= last ) { | 136 | if ( selFirst >= first && selLast <= last ) { |
136 | setBaseDates(); | 137 | setBaseDates(); |
137 | if ( forceEmit ) | 138 | if ( forceEmit ) |
138 | updateDayMatrixDates(); | 139 | updateDayMatrixDates(); |
139 | } | 140 | } |
140 | else { | 141 | else { |
141 | setBaseDates(); | 142 | setBaseDates(); |
142 | if ( forceEmit ) | 143 | if ( forceEmit ) |
143 | updateDayMatrixDates(); | 144 | updateDayMatrixDates(); |
144 | if ( forceEmit ) | 145 | if ( forceEmit ) |
145 | emit monthSelected( month ); | 146 | emit monthSelected( month ); |
146 | } | 147 | } |
147 | } | 148 | } |
148 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 149 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
149 | { | 150 | { |
150 | mCalendar = cal; | 151 | mCalendar = cal; |
151 | mNavigatorView->setCalendar( cal ); | 152 | mNavigatorView->setCalendar( cal ); |
152 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 153 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
153 | KDateNavigator *n = mExtraViews.at( i ); | 154 | KDateNavigator *n = mExtraViews.at( i ); |
154 | n->setCalendar( cal ); | 155 | n->setCalendar( cal ); |
155 | } | 156 | } |
156 | } | 157 | } |
157 | void DateNavigatorContainer::checkUpdateDayMatrixDates() | 158 | void DateNavigatorContainer::checkUpdateDayMatrixDates() |
158 | { | 159 | { |
159 | //qDebug("KODNC: wid %d hei %d ", width(), height()); | 160 | //qDebug("KODNC: wid %d hei %d ", width(), height()); |
160 | mUpdateTimer->stop(); | 161 | mUpdateTimer->stop(); |
161 | //return; | 162 | //return; |
162 | if ( width() < 3 || height() < 3 ) | 163 | if ( width() < 3 || height() < 3 ) |
163 | return; | 164 | return; |
164 | static int lastWid = 0; | 165 | static int lastWid = 0; |
165 | static int lastHei = 0; | 166 | static int lastHei = 0; |
166 | if ( lastWid == width() && height() == lastHei ) { | 167 | if ( lastWid == width() && height() == lastHei ) { |
167 | qDebug("KODNC: No layout computing needed. "); | 168 | qDebug("KODNC: No layout computing needed. "); |
168 | } else { | 169 | } else { |
169 | lastWid = width(); | 170 | lastWid = width(); |
170 | lastHei = height(); | 171 | lastHei = height(); |
171 | 172 | ||
172 | QSize minSize = mNavigatorView->yourSizeHint(); | 173 | QSize minSize = mNavigatorView->yourSizeHint(); |
173 | 174 | ||
174 | int verticalCount = size().height() / minSize.height(); | 175 | int verticalCount = size().height() / minSize.height(); |
175 | int horizontalCount = size().width() / minSize.width(); | 176 | int horizontalCount = size().width() / minSize.width(); |
176 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 177 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
177 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 178 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
178 | bool fontchange = false; | 179 | bool fontchange = false; |
179 | if ( horizontalCount == 1) | 180 | if ( horizontalCount == 1) |
180 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); | 181 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); |
181 | QFont fo; | 182 | QFont fo; |
182 | if ( horizontalCount != mHorizontalCount || | 183 | if ( horizontalCount != mHorizontalCount || |
183 | verticalCount != mVerticalCount ) { | 184 | verticalCount != mVerticalCount ) { |
184 | uint count = horizontalCount * verticalCount; | 185 | uint count = horizontalCount * verticalCount; |
185 | if ( count == 0 ) { | 186 | if ( count == 0 ) { |
186 | bool ok; | 187 | bool ok; |
187 | fo = mNavigatorView->yourFontHint( size() , &ok ); | 188 | fo = mNavigatorView->yourFontHint( size() , &ok ); |
188 | //mNavigatorView->resize( size() ); | 189 | //mNavigatorView->resize( size() ); |
189 | //if ( ! ok ) | 190 | //if ( ! ok ) |
190 | // return; | 191 | // return; |
191 | int butt = 2; | 192 | int butt = 2; |
192 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); | 193 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); |
193 | if ( horizontalCount <= 1 ) | 194 | if ( horizontalCount <= 1 ) |
194 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); | 195 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); |
195 | else | 196 | else |
196 | minSize = mNavigatorView->sizeHintTwoButtons(); | 197 | minSize = mNavigatorView->sizeHintTwoButtons(); |
197 | verticalCount = size().height() / minSize.height(); | 198 | verticalCount = size().height() / minSize.height(); |
198 | horizontalCount = size().width() / minSize.width(); | 199 | horizontalCount = size().width() / minSize.width(); |
199 | if ( horizontalCount == 0 ) | 200 | if ( horizontalCount == 0 ) |
200 | horizontalCount = 1; | 201 | horizontalCount = 1; |
201 | if ( verticalCount == 0 ) | 202 | if ( verticalCount == 0 ) |
202 | verticalCount = 1; | 203 | verticalCount = 1; |
203 | fontchange = true; | 204 | fontchange = true; |
204 | count = horizontalCount * verticalCount; | 205 | count = horizontalCount * verticalCount; |
205 | } else { | 206 | } else { |
206 | if ( mNavigatorView->fontChanged() ) { | 207 | if ( mNavigatorView->fontChanged() ) { |
207 | fontchange = true; | 208 | fontchange = true; |
208 | fo = KOPrefs::instance()->mDateNavigatorFont; | 209 | fo = KOPrefs::instance()->mDateNavigatorFont; |
209 | mNavigatorView->changeFont( fo ); | 210 | mNavigatorView->changeFont( fo ); |
210 | mNavigatorView->unsetFontChanged(); | 211 | mNavigatorView->unsetFontChanged(); |
211 | } | 212 | } |
212 | } | 213 | } |
213 | 214 | ||
214 | mLastDisplayedDN = horizontalCount*verticalCount-1; | 215 | mLastDisplayedDN = horizontalCount*verticalCount-1; |
215 | while ( count > ( mExtraViews.count() + 1 ) ) { | 216 | while ( count > ( mExtraViews.count() + 1 ) ) { |
216 | KDateNavigator *n = new KDateNavigator( this ); | 217 | KDateNavigator *n = new KDateNavigator( this ); |
217 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 218 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
218 | mExtraViews.append( n ); | 219 | mExtraViews.append( n ); |
219 | n->setCalendar( mCalendar ); | 220 | n->setCalendar( mCalendar ); |
220 | connectNavigatorView( n ); | 221 | connectNavigatorView( n ); |
221 | n->show(); | 222 | // n->show(); |
222 | } | ||
223 | int iii = 0; | ||
224 | while ( iii < ( mExtraViews.count() ) ) { | ||
225 | if ( iii < count-1 ) | ||
226 | mExtraViews.at( iii )->show(); | ||
227 | else | ||
228 | mExtraViews.at( iii )->hide(); | ||
229 | ++iii; | ||
230 | } | 223 | } |
224 | |||
231 | 225 | ||
232 | setBaseDates(); | 226 | setBaseDates(); |
233 | if ( fontchange ) { | 227 | if ( fontchange ) { |
234 | //mNavigatorView->changeFont( fo ); | 228 | //mNavigatorView->changeFont( fo ); |
235 | uint i; | 229 | uint i; |
236 | for( i = 0; i < mExtraViews.count(); ++i ) { | 230 | for( i = 0; i < mExtraViews.count(); ++i ) { |
237 | KDateNavigator *view = mExtraViews.at( i ); | 231 | KDateNavigator *view = mExtraViews.at( i ); |
238 | view->changeFont( fo ); | 232 | view->changeFont( fo ); |
239 | } | 233 | } |
240 | } | 234 | } |
241 | mHorizontalCount = horizontalCount; | 235 | mHorizontalCount = horizontalCount; |
242 | mVerticalCount = verticalCount; | 236 | mVerticalCount = verticalCount; |
243 | 237 | ||
244 | } | 238 | } |
245 | 239 | ||
246 | int theight = height() / mVerticalCount; | 240 | int theight = height() / mVerticalCount; |
247 | int twidth = width() / mHorizontalCount; | 241 | int twidth = width() / mHorizontalCount; |
248 | 242 | ||
249 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 243 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
250 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); | 244 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); |
251 | else bar->showButtons( true, true ); | 245 | else bar->showButtons( true, true ); |
252 | 246 | ||
253 | mNavigatorView->setGeometry(0, | 247 | mNavigatorView->setGeometry(0, |
254 | 0, twidth, theight ); | 248 | 0, twidth, theight ); |
255 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 249 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
256 | int x = ( i + 1 ) % mHorizontalCount; | 250 | int x = ( i + 1 ) % mHorizontalCount; |
257 | int y = ( i + 1 ) / mHorizontalCount; | 251 | int y = ( i + 1 ) / mHorizontalCount; |
258 | 252 | ||
259 | KDateNavigator *view = mExtraViews.at( i ); | 253 | KDateNavigator *view = mExtraViews.at( i ); |
260 | bar = view->navigatorBar(); | 254 | bar = view->navigatorBar(); |
261 | if ( y > 0 ) bar->showButtons( false, false ); | 255 | if ( y > 0 ) bar->showButtons( false, false ); |
262 | else { | 256 | else { |
263 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); | 257 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); |
264 | else bar->showButtons( false, false ); | 258 | else bar->showButtons( false, false ); |
265 | } | 259 | } |
266 | view->setGeometry( x * twidth, | 260 | view->setGeometry( x * twidth, |
267 | y * theight, twidth, theight ); | 261 | y * theight, twidth, theight ); |
268 | } | 262 | } |
263 | int iii = 0; | ||
264 | int ccc = mHorizontalCount * mVerticalCount; | ||
265 | mNavigatorView->show(); | ||
266 | while ( iii < ( mExtraViews.count() ) ) { | ||
267 | if ( iii < ccc-1 ) | ||
268 | mExtraViews.at( iii )->show(); | ||
269 | else | ||
270 | mExtraViews.at( iii )->hide(); | ||
271 | ++iii; | ||
272 | } | ||
269 | } | 273 | } |
270 | 274 | ||
271 | QDate last = lastAvailableDate(); | 275 | QDate last = lastAvailableDate(); |
272 | QDate first = firstAvailableDate(); | 276 | QDate first = firstAvailableDate(); |
273 | 277 | ||
274 | QDate selFirst = mFirstSelectedDate; | 278 | QDate selFirst = mFirstSelectedDate; |
275 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 279 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
276 | if ( selFirst >= first && selLast <= last ) { | 280 | if ( selFirst >= first && selLast <= last ) { |
277 | updateDayMatrixDates(); | 281 | updateDayMatrixDates(); |
278 | } | 282 | } |
279 | else { | 283 | else { |
280 | updateDayMatrixDates(); | 284 | updateDayMatrixDates(); |
281 | emit monthSelected( mFirstSelectedDate.month() ); | 285 | emit monthSelected( mFirstSelectedDate.month() ); |
282 | } | 286 | } |
283 | } | 287 | } |
284 | void DateNavigatorContainer::updateDayMatrixDates() | 288 | void DateNavigatorContainer::updateDayMatrixDates() |
285 | { | 289 | { |
286 | QDate fDate = mFirstSelectedDate; | 290 | QDate fDate = mFirstSelectedDate; |
287 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); | 291 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); |
288 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); | 292 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); |
289 | mNavigatorView->dayMatrix()->repaint( false ); | 293 | mNavigatorView->dayMatrix()->repaint( false ); |
290 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 294 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
291 | KDateNavigator *n = mExtraViews.at( i ); | 295 | KDateNavigator *n = mExtraViews.at( i ); |
292 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { | 296 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { |
293 | n->dayMatrix()->repaint( false ); | 297 | n->dayMatrix()->repaint( false ); |
294 | } | 298 | } |
295 | } | 299 | } |
296 | } | 300 | } |
297 | 301 | ||
298 | void DateNavigatorContainer::updateDayMatrix() | 302 | void DateNavigatorContainer::updateDayMatrix() |
299 | { | 303 | { |
300 | mNavigatorView->updateDayMatrix(); | 304 | mNavigatorView->updateDayMatrix(); |
301 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 305 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
302 | KDateNavigator *n = mExtraViews.at( i ); | 306 | KDateNavigator *n = mExtraViews.at( i ); |
303 | n->updateDayMatrix(); | 307 | n->updateDayMatrix(); |
304 | } | 308 | } |
305 | } | 309 | } |
306 | 310 | ||
307 | void DateNavigatorContainer::updateToday() | 311 | void DateNavigatorContainer::updateToday() |
308 | { | 312 | { |
309 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 313 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
310 | #if 0 | 314 | #if 0 |
311 | mNavigatorView->updateToday(); | 315 | mNavigatorView->updateToday(); |
312 | KDateNavigator *n; | 316 | KDateNavigator *n; |
313 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 317 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
314 | n->updateToday(); | 318 | n->updateToday(); |
315 | } | 319 | } |
316 | #endif | 320 | #endif |
317 | } | 321 | } |
318 | 322 | ||
319 | void DateNavigatorContainer::updateView() | 323 | void DateNavigatorContainer::updateView() |
320 | { | 324 | { |
321 | mNavigatorView->updateView(); | 325 | mNavigatorView->updateView(); |
322 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 326 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
323 | KDateNavigator *n = mExtraViews.at( i ); | 327 | KDateNavigator *n = mExtraViews.at( i ); |
324 | n->updateView(); | 328 | n->updateView(); |
325 | } | 329 | } |
326 | } | 330 | } |
327 | 331 | ||
328 | void DateNavigatorContainer::updateConfig() | 332 | void DateNavigatorContainer::updateConfig() |
329 | { | 333 | { |
330 | mNavigatorView->updateConfig(); | 334 | mNavigatorView->updateConfig(); |
331 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 335 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
332 | KDateNavigator *n = mExtraViews.at( i ); | 336 | KDateNavigator *n = mExtraViews.at( i ); |
333 | n->updateConfig(); | 337 | n->updateConfig(); |
334 | } | 338 | } |
335 | } | 339 | } |
336 | QDate DateNavigatorContainer::lastAvailableDate() const | 340 | QDate DateNavigatorContainer::lastAvailableDate() const |
337 | { | 341 | { |
338 | QDate date = mNavigatorView->baseDate(); | 342 | QDate date = mNavigatorView->baseDate(); |
339 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); | 343 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); |
340 | int iii = mLastDisplayedDN; | 344 | int iii = mLastDisplayedDN; |
341 | if ( mLastDisplayedDN ) | 345 | if ( mLastDisplayedDN ) |
342 | last = last.addDays( 1); | 346 | last = last.addDays( 1); |
343 | while ( iii ) { | 347 | while ( iii ) { |
344 | last = last.addDays( last.daysInMonth ()); | 348 | last = last.addDays( last.daysInMonth ()); |
345 | //qDebug("DATE %s ", last.toString().latin1() ); | 349 | //qDebug("DATE %s ", last.toString().latin1() ); |
346 | --iii; | 350 | --iii; |
347 | } | 351 | } |
348 | if ( mLastDisplayedDN ) | 352 | if ( mLastDisplayedDN ) |
349 | last = last.addDays( -1); | 353 | last = last.addDays( -1); |
350 | return last; | 354 | return last; |
351 | } | 355 | } |
352 | QDate DateNavigatorContainer::firstAvailableDate() const | 356 | QDate DateNavigatorContainer::firstAvailableDate() const |
353 | { | 357 | { |
354 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); | 358 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); |
355 | } | 359 | } |
356 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 360 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
357 | { | 361 | { |
358 | mFirstSelectedDate = dateList.first() ; | 362 | mFirstSelectedDate = dateList.first() ; |
359 | mSelectedDateCount = dateList.count() ; | 363 | mSelectedDateCount = dateList.count() ; |
360 | if ( !mLastDisplayedDN ) { | 364 | if ( !mLastDisplayedDN ) { |
361 | mNavigatorView->selectDates( dateList ); | 365 | mNavigatorView->selectDates( dateList ); |
362 | return; | 366 | return; |
363 | } | 367 | } |
364 | QDate fDate = dateList.first(); | 368 | QDate fDate = dateList.first(); |
365 | QDate lDate = dateList.last(); | 369 | QDate lDate = dateList.last(); |
366 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); | 370 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); |
367 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | 371 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); |
368 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { | 372 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { |
369 | updateDayMatrixDates(); | 373 | updateDayMatrixDates(); |
370 | return; | 374 | return; |
371 | } | 375 | } |
372 | mNavigatorView->selectDates( dateList ); | 376 | mNavigatorView->selectDates( dateList ); |
373 | setBaseDates(); | 377 | setBaseDates(); |
374 | if ( mLastDisplayedDN ) { | 378 | if ( mLastDisplayedDN ) { |
375 | KDateNavigator *view = mExtraViews.at( 0 ); | 379 | KDateNavigator *view = mExtraViews.at( 0 ); |
376 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 380 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
377 | view->dayMatrix()->repaint( false ); | 381 | view->dayMatrix()->repaint( false ); |
378 | if ( mLastDisplayedDN > 1 ) { | 382 | if ( mLastDisplayedDN > 1 ) { |
379 | KDateNavigator *view = mExtraViews.at( 1 ); | 383 | KDateNavigator *view = mExtraViews.at( 1 ); |
380 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 384 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
381 | view->dayMatrix()->repaint( false ); | 385 | view->dayMatrix()->repaint( false ); |
382 | } | 386 | } |
383 | } | 387 | } |
384 | } | 388 | } |
385 | 389 | ||
386 | void DateNavigatorContainer::setBaseDates() | 390 | void DateNavigatorContainer::setBaseDates() |
387 | { | 391 | { |
388 | QDate baseDate = mNavigatorView->baseDate(); | 392 | QDate baseDate = mNavigatorView->baseDate(); |
389 | bool doRepaint = true; | 393 | bool doRepaint = true; |
390 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 394 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
391 | KDateNavigator *n = mExtraViews.at( i ); | 395 | KDateNavigator *n = mExtraViews.at( i ); |
392 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 396 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
393 | n->setBaseDate( baseDate, doRepaint ); | 397 | n->setBaseDate( baseDate, doRepaint ); |
394 | } | 398 | } |
395 | } | 399 | } |
396 | 400 | void DateNavigatorContainer::setResizeEnabled() | |
401 | { | ||
402 | mResizeEnabled = true; | ||
403 | //qDebug("DateNavigatorContainer::setResizeEnabled "); | ||
404 | checkUpdateDayMatrixDates(); | ||
405 | } | ||
397 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 406 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
398 | { | 407 | { |
399 | 408 | ||
400 | 409 | //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); | |
401 | //qDebug("COUNT %d ", mExtraViews.count()); | 410 | //qDebug("COUNT %d ", mExtraViews.count()); |
402 | 411 | if ( ! mResizeEnabled ) { | |
403 | mUpdateTimer->start( 250 ); | 412 | //qDebug("NOT ResizeEnabled"); |
413 | return; | ||
414 | } | ||
415 | else | ||
416 | mUpdateTimer->start( 250 ); | ||
417 | |||
404 | //updateDayMatrixDates(); | 418 | //updateDayMatrixDates(); |
405 | } | 419 | } |
406 | 420 | ||
407 | QSize DateNavigatorContainer::minimumSizeHint() const | 421 | QSize DateNavigatorContainer::minimumSizeHint() const |
408 | { | 422 | { |
409 | return mNavigatorView->minimumSizeHint(); | 423 | return mNavigatorView->minimumSizeHint(); |
410 | } | 424 | } |
411 | 425 | ||
412 | QSize DateNavigatorContainer::sizeHint() const | 426 | QSize DateNavigatorContainer::sizeHint() const |
413 | { | 427 | { |
414 | return mNavigatorView->yourSizeHint(); | 428 | return mNavigatorView->yourSizeHint(); |
415 | } | 429 | } |
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h index d2f397d..ac9745d 100644 --- a/korganizer/datenavigatorcontainer.h +++ b/korganizer/datenavigatorcontainer.h | |||
@@ -1,106 +1,108 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | #ifndef DATENAVIGATORCONTAINER_H | 25 | #ifndef DATENAVIGATORCONTAINER_H |
26 | #define DATENAVIGATORCONTAINER_H | 26 | #define DATENAVIGATORCONTAINER_H |
27 | 27 | ||
28 | class KDateNavigator; | 28 | class KDateNavigator; |
29 | 29 | ||
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <libkcal/calendar.h> | 32 | #include <libkcal/calendar.h> |
33 | using namespace KCal; | 33 | using namespace KCal; |
34 | 34 | ||
35 | class DateNavigatorContainer: public QWidget | 35 | class DateNavigatorContainer: public QWidget |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | public: | 38 | public: |
39 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); | 39 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); |
40 | ~DateNavigatorContainer(); | 40 | ~DateNavigatorContainer(); |
41 | 41 | ||
42 | /** | 42 | /** |
43 | Associate date navigator with a calendar. It is used by KODayMatrix. | 43 | Associate date navigator with a calendar. It is used by KODayMatrix. |
44 | */ | 44 | */ |
45 | void setCalendar( Calendar * ); | 45 | void setCalendar( Calendar * ); |
46 | 46 | ||
47 | QSize minimumSizeHint() const; | 47 | QSize minimumSizeHint() const; |
48 | QSize sizeHint() const; | 48 | QSize sizeHint() const; |
49 | KDateNavigator * navigatorView() { return mNavigatorView;} | 49 | KDateNavigator * navigatorView() { return mNavigatorView;} |
50 | QDate lastAvailableDate() const ; | 50 | QDate lastAvailableDate() const ; |
51 | QDate firstAvailableDate() const ; | 51 | QDate firstAvailableDate() const ; |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void selectDates( const KCal::DateList & ); | 54 | void selectDates( const KCal::DateList & ); |
55 | void updateView(); | 55 | void updateView(); |
56 | void updateConfig(); | 56 | void updateConfig(); |
57 | void updateDayMatrix(); | 57 | void updateDayMatrix(); |
58 | void updateDayMatrixDates(); | 58 | void updateDayMatrixDates(); |
59 | void checkUpdateDayMatrixDates(); | 59 | void checkUpdateDayMatrixDates(); |
60 | void updateToday(); | 60 | void updateToday(); |
61 | void slotMonthSelected( int month ); | 61 | void slotMonthSelected( int month ); |
62 | void slotgoNextMonth(); | 62 | void slotgoNextMonth(); |
63 | void slotgoPrevMonth(); | 63 | void slotgoPrevMonth(); |
64 | void slotgoNextYear(); | 64 | void slotgoNextYear(); |
65 | void slotgoPrevYear(); | 65 | void slotgoPrevYear(); |
66 | void setResizeEnabled(); | ||
66 | 67 | ||
67 | signals: | 68 | signals: |
68 | void datesSelected( const KCal::DateList & ); | 69 | void datesSelected( const KCal::DateList & ); |
69 | void incidenceDropped( Incidence *, const QDate & ); | 70 | void incidenceDropped( Incidence *, const QDate & ); |
70 | void incidenceDroppedMove( Incidence *, const QDate & ); | 71 | void incidenceDroppedMove( Incidence *, const QDate & ); |
71 | void weekClicked( const QDate &); | 72 | void weekClicked( const QDate &); |
72 | 73 | ||
73 | void goPrevious(); | 74 | void goPrevious(); |
74 | void goNext(); | 75 | void goNext(); |
75 | 76 | ||
76 | void goNextMonth(); | 77 | void goNextMonth(); |
77 | void goPrevMonth(); | 78 | void goPrevMonth(); |
78 | void goNextYear(); | 79 | void goNextYear(); |
79 | void goPrevYear(); | 80 | void goPrevYear(); |
80 | 81 | ||
81 | void monthSelected( int month ); | 82 | void monthSelected( int month ); |
82 | 83 | ||
83 | protected: | 84 | protected: |
84 | void computeMonthSelected( int month , bool forceEmit ); | 85 | void computeMonthSelected( int month , bool forceEmit ); |
85 | void jumpMonth( int month ); | 86 | void jumpMonth( int month ); |
86 | void resizeEvent( QResizeEvent * ); | 87 | void resizeEvent( QResizeEvent * ); |
87 | 88 | ||
88 | void setBaseDates(); | 89 | void setBaseDates(); |
89 | void connectNavigatorView( KDateNavigator *v ); | 90 | void connectNavigatorView( KDateNavigator *v ); |
90 | 91 | ||
91 | private: | 92 | private: |
93 | bool mResizeEnabled; | ||
92 | QTimer* mUpdateTimer; | 94 | QTimer* mUpdateTimer; |
93 | int mLastDisplayedDN; | 95 | int mLastDisplayedDN; |
94 | QDate mFirstSelectedDate; | 96 | QDate mFirstSelectedDate; |
95 | int mSelectedDateCount; | 97 | int mSelectedDateCount; |
96 | KDateNavigator *mNavigatorView; | 98 | KDateNavigator *mNavigatorView; |
97 | 99 | ||
98 | KCal::Calendar *mCalendar; | 100 | KCal::Calendar *mCalendar; |
99 | 101 | ||
100 | QPtrList<KDateNavigator> mExtraViews; | 102 | QPtrList<KDateNavigator> mExtraViews; |
101 | 103 | ||
102 | int mHorizontalCount; | 104 | int mHorizontalCount; |
103 | int mVerticalCount; | 105 | int mVerticalCount; |
104 | }; | 106 | }; |
105 | 107 | ||
106 | #endif | 108 | #endif |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 0cb767f..5eccfd6 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,466 +1,467 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | headings[i]->installEventFilter(this); | 86 | headings[i]->installEventFilter(this); |
87 | 87 | ||
88 | topLayout->addWidget(headings[i],1,i+1); | 88 | topLayout->addWidget(headings[i],1,i+1); |
89 | } | 89 | } |
90 | 90 | ||
91 | // Create the weeknumber labels | 91 | // Create the weeknumber labels |
92 | for( i = 0; i < 6; i++ ) { | 92 | for( i = 0; i < 6; i++ ) { |
93 | weeknos[i] = new QLabel(this); | 93 | weeknos[i] = new QLabel(this); |
94 | weeknos[i]->setAlignment(AlignCenter); | 94 | weeknos[i]->setAlignment(AlignCenter); |
95 | //weeknos[i]->setFont(QFont("Arial", 10)); | 95 | //weeknos[i]->setFont(QFont("Arial", 10)); |
96 | if(!m_bShowWeekNums) { | 96 | if(!m_bShowWeekNums) { |
97 | weeknos[i]->hide(); | 97 | weeknos[i]->hide(); |
98 | } | 98 | } |
99 | weeknos[i]->installEventFilter(this); | 99 | weeknos[i]->installEventFilter(this); |
100 | 100 | ||
101 | topLayout->addWidget(weeknos[i],i+2,0); | 101 | topLayout->addWidget(weeknos[i],i+2,0); |
102 | } | 102 | } |
103 | 103 | ||
104 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 104 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
105 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 105 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
106 | daymatrix->setLineWidth(1); | 106 | daymatrix->setLineWidth(1); |
107 | 107 | ||
108 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 108 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
109 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 109 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
110 | 110 | ||
111 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 111 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
112 | SIGNAL( eventDropped( Event * ) ) ); | 112 | SIGNAL( eventDropped( Event * ) ) ); |
113 | 113 | ||
114 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 114 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
115 | 115 | ||
116 | // read settings from configuration file. | 116 | // read settings from configuration file. |
117 | updateConfig(); | 117 | updateConfig(); |
118 | enableRollover(FollowMonth); | 118 | enableRollover(FollowMonth); |
119 | mySizeHint = sizeHintTwoButtons(); | 119 | mySizeHint = sizeHintTwoButtons(); |
120 | myFullSizeHint = sizeHintTwoButtons( 4 ); | 120 | myFullSizeHint = sizeHintTwoButtons( 4 ); |
121 | mFontChanged = false; | 121 | mFontChanged = false; |
122 | resize ( 3,3 ); | 122 | //resize ( 3,3 ); |
123 | 123 | ||
124 | } | 124 | } |
125 | void KDateNavigator::changeFont ( QFont fo ) | 125 | void KDateNavigator::changeFont ( QFont fo ) |
126 | { | 126 | { |
127 | setFont( fo ); | 127 | setFont( fo ); |
128 | mNavigatorBar->resetFont( fo ); | 128 | mNavigatorBar->resetFont( fo ); |
129 | } | 129 | } |
130 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 130 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
131 | { | 131 | { |
132 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 132 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
133 | *b = false; | 133 | *b = false; |
134 | int fontPoint = fo.pointSize(); | 134 | int fontPoint = fo.pointSize(); |
135 | while ( fontPoint > 5 ) { | 135 | while ( fontPoint > 5 ) { |
136 | --fontPoint; | 136 | --fontPoint; |
137 | fo.setPointSize( fontPoint ); | 137 | fo.setPointSize( fontPoint ); |
138 | setFont( fo ); | 138 | setFont( fo ); |
139 | mFontChanged = true; | 139 | mFontChanged = true; |
140 | mNavigatorBar->resetFont( fo ); | 140 | mNavigatorBar->resetFont( fo ); |
141 | QSize sh = sizeHintTwoButtons( 2 ); | 141 | QSize sh = sizeHintTwoButtons( 2 ); |
142 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 142 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
143 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 143 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
144 | if ( si.width() / sh.width() == 1 ) { | 144 | if ( si.width() / sh.width() == 1 ) { |
145 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 145 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
146 | continue; | 146 | continue; |
147 | } | 147 | } |
148 | *b = true; | 148 | *b = true; |
149 | //qDebug("fooooooooooooooooooooooouuuuund "); | 149 | //qDebug("fooooooooooooooooooooooouuuuund "); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | 153 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); |
154 | return fo; | 154 | return fo; |
155 | } | 155 | } |
156 | QSize KDateNavigator::sizeHint() const | 156 | QSize KDateNavigator::sizeHint() const |
157 | { | 157 | { |
158 | QFontMetrics fm ( font() ); | 158 | QFontMetrics fm ( font() ); |
159 | QSize day = daymatrix->sizeHint(); | 159 | QSize day = daymatrix->sizeHint(); |
160 | QSize nav = mNavigatorBar->sizeHint(); | 160 | QSize nav = mNavigatorBar->sizeHint(); |
161 | int wid = fm.width( "30") + day.width()+3; | 161 | int wid = fm.width( "30") + day.width()+3; |
162 | int hei = fm.height() +day.height()+nav.height()+2; | 162 | int hei = fm.height() +day.height()+nav.height()+2; |
163 | if ( wid < nav.width() ) | 163 | if ( wid < nav.width() ) |
164 | wid = nav.width() ; | 164 | wid = nav.width() ; |
165 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 165 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
166 | return QSize ( wid, hei ); | 166 | return QSize ( wid, hei ); |
167 | } | 167 | } |
168 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 168 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
169 | { | 169 | { |
170 | QFontMetrics fm ( font() ); | 170 | QFontMetrics fm ( font() ); |
171 | QSize day = daymatrix->sizeHint(); | 171 | QSize day = daymatrix->sizeHint(); |
172 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 172 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
173 | int wid = fm.width( "30") + day.width()+3; | 173 | int wid = fm.width( "30") + day.width()+3; |
174 | int hei = fm.height() +day.height()+nav.height()+2; | 174 | int hei = fm.height() +day.height()+nav.height()+2; |
175 | if ( wid < nav.width() ) | 175 | if ( wid < nav.width() ) |
176 | wid = nav.width() ; | 176 | wid = nav.width() ; |
177 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 177 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
178 | return QSize ( wid, hei ); | 178 | return QSize ( wid, hei ); |
179 | } | 179 | } |
180 | void KDateNavigator::slotMonthSelected( int m ) | 180 | void KDateNavigator::slotMonthSelected( int m ) |
181 | { | 181 | { |
182 | if ( m_MthYr.month() <= mMonthSignalOffset) | 182 | if ( m_MthYr.month() <= mMonthSignalOffset) |
183 | m += 12; | 183 | m += 12; |
184 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 184 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
185 | emit monthSelected( m - mMonthSignalOffset ); | 185 | emit monthSelected( m - mMonthSignalOffset ); |
186 | 186 | ||
187 | } | 187 | } |
188 | void KDateNavigator::setCalendar( Calendar *cal ) | 188 | void KDateNavigator::setCalendar( Calendar *cal ) |
189 | { | 189 | { |
190 | daymatrix->setCalendar( cal ); | 190 | daymatrix->setCalendar( cal ); |
191 | } | 191 | } |
192 | 192 | ||
193 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 193 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
194 | { | 194 | { |
195 | m_MthYr = date; | 195 | m_MthYr = date; |
196 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 196 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
197 | 197 | ||
198 | updateDates(); | 198 | updateDates(); |
199 | updateView(); | 199 | updateView(); |
200 | 200 | ||
201 | KCal::DateList dates; | 201 | KCal::DateList dates; |
202 | dates.append( date ); | 202 | dates.append( date ); |
203 | mNavigatorBar->selectDates( dates ); | 203 | mNavigatorBar->selectDates( dates ); |
204 | 204 | ||
205 | daymatrix->clearSelection(); | 205 | daymatrix->clearSelection(); |
206 | if ( doRepaint ) | 206 | if ( doRepaint ) |
207 | daymatrix->repaint( false ); | 207 | daymatrix->repaint( false ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void KDateNavigator::enableRollover(RolloverType r) | 210 | void KDateNavigator::enableRollover(RolloverType r) |
211 | { | 211 | { |
212 | switch(r) | 212 | switch(r) |
213 | { | 213 | { |
214 | case None : | 214 | case None : |
215 | if (updateTimer) | 215 | if (updateTimer) |
216 | { | 216 | { |
217 | updateTimer->stop(); | 217 | updateTimer->stop(); |
218 | delete updateTimer; | 218 | delete updateTimer; |
219 | updateTimer=0L; | 219 | updateTimer=0L; |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | case FollowDay : | 222 | case FollowDay : |
223 | case FollowMonth : | 223 | case FollowMonth : |
224 | if (!updateTimer) | 224 | if (!updateTimer) |
225 | { | 225 | { |
226 | updateTimer = new QTimer(this); | 226 | updateTimer = new QTimer(this); |
227 | QObject::connect(updateTimer,SIGNAL(timeout()), | 227 | QObject::connect(updateTimer,SIGNAL(timeout()), |
228 | this,SLOT(possiblyPastMidnight())); | 228 | this,SLOT(possiblyPastMidnight())); |
229 | } | 229 | } |
230 | updateTimer->start(0,true); | 230 | updateTimer->start(0,true); |
231 | lastDayChecked = QDate::currentDate(); | 231 | lastDayChecked = QDate::currentDate(); |
232 | } | 232 | } |
233 | updateRollover=r; | 233 | updateRollover=r; |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | KDateNavigator::~KDateNavigator() | 237 | KDateNavigator::~KDateNavigator() |
238 | { | 238 | { |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void KDateNavigator::passedMidnight() | 242 | void KDateNavigator::passedMidnight() |
243 | { | 243 | { |
244 | QDate today = QDate::currentDate(); | 244 | QDate today = QDate::currentDate(); |
245 | bool emitMonth = false; | 245 | bool emitMonth = false; |
246 | 246 | ||
247 | if (today.month() != lastDayChecked.month()) | 247 | if (today.month() != lastDayChecked.month()) |
248 | { | 248 | { |
249 | if (updateRollover==FollowMonth && | 249 | if (updateRollover==FollowMonth && |
250 | daymatrix->isEndOfMonth()) { | 250 | daymatrix->isEndOfMonth()) { |
251 | goNextMonth(); | 251 | goNextMonth(); |
252 | emitMonth=true; | 252 | emitMonth=true; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | daymatrix->recalculateToday(); | 255 | daymatrix->recalculateToday(); |
256 | daymatrix->repaint( false ); | 256 | daymatrix->repaint( false ); |
257 | emit dayPassed(today); | 257 | emit dayPassed(today); |
258 | if (emitMonth) { emit monthPassed(today); } | 258 | if (emitMonth) { emit monthPassed(today); } |
259 | } | 259 | } |
260 | 260 | ||
261 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 261 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
262 | { | 262 | { |
263 | if (lastDayChecked!=QDate::currentDate()) | 263 | if (lastDayChecked!=QDate::currentDate()) |
264 | { | 264 | { |
265 | passedMidnight(); | 265 | passedMidnight(); |
266 | lastDayChecked=QDate::currentDate(); | 266 | lastDayChecked=QDate::currentDate(); |
267 | } | 267 | } |
268 | // Set the timer to go off 1 second after midnight | 268 | // Set the timer to go off 1 second after midnight |
269 | // or after 8 minutes, whichever comes first. | 269 | // or after 8 minutes, whichever comes first. |
270 | if (updateTimer) | 270 | if (updateTimer) |
271 | { | 271 | { |
272 | QTime now = QTime::currentTime(); | 272 | QTime now = QTime::currentTime(); |
273 | QTime midnight = QTime(23,59,59); | 273 | QTime midnight = QTime(23,59,59); |
274 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 274 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
275 | 275 | ||
276 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 276 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
277 | //.arg(now.toString()).arg(midnight.toString())); | 277 | //.arg(now.toString()).arg(midnight.toString())); |
278 | 278 | ||
279 | updateTimer->stop(); | 279 | updateTimer->stop(); |
280 | updateTimer->start(msecsWait,true); | 280 | updateTimer->start(msecsWait,true); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | void KDateNavigator::updateDates() | 284 | void KDateNavigator::updateDates() |
285 | { | 285 | { |
286 | // Find the first day of the week of the current month. | 286 | // Find the first day of the week of the current month. |
287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
290 | //int di = d1 - d2 + 1; | 290 | //int di = d1 - d2 + 1; |
291 | dayone = dayone.addDays( -d2 + 1 ); | 291 | dayone = dayone.addDays( -d2 + 1 ); |
292 | 292 | ||
293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
294 | 294 | ||
295 | // If month begins on Monday and Monday is first day of week, | 295 | // If month begins on Monday and Monday is first day of week, |
296 | // month should begin on second line. Sunday doesn't have this problem. | 296 | // month should begin on second line. Sunday doesn't have this problem. |
297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
299 | 299 | ||
300 | // update the matrix dates | 300 | // update the matrix dates |
301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
302 | 302 | ||
303 | 303 | ||
304 | daymatrix->updateView(dayone.addDays(index)); | 304 | daymatrix->updateView(dayone.addDays(index)); |
305 | //each updateDates is followed by an updateView -> repaint is issued there ! | 305 | //each updateDates is followed by an updateView -> repaint is issued there ! |
306 | // daymatrix->repaint(); | 306 | // daymatrix->repaint(); |
307 | } | 307 | } |
308 | 308 | ||
309 | void KDateNavigator::updateDayMatrix() | 309 | void KDateNavigator::updateDayMatrix() |
310 | { | 310 | { |
311 | daymatrix->updateView(); | 311 | daymatrix->updateView(); |
312 | //daymatrix->repaint(); | 312 | //daymatrix->repaint(); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void KDateNavigator::updateView() | 316 | void KDateNavigator::updateView() |
317 | { | 317 | { |
318 | 318 | ||
319 | setUpdatesEnabled( false ); | 319 | setUpdatesEnabled( false ); |
320 | 320 | ||
321 | int i; | 321 | int i; |
322 | 322 | ||
323 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 323 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
324 | daymatrix->updateView(); | 324 | daymatrix->updateView(); |
325 | 325 | ||
326 | // set the week numbers. | 326 | // set the week numbers. |
327 | for(i = 0; i < 6; i++) { | 327 | for(i = 0; i < 6; i++) { |
328 | QString weeknum; | 328 | QString weeknum; |
329 | // remember, according to ISO 8601, the first week of the year is the | 329 | // remember, according to ISO 8601, the first week of the year is the |
330 | // first week that contains a thursday. Thus we must subtract off 4, | 330 | // first week that contains a thursday. Thus we must subtract off 4, |
331 | // not just 1. | 331 | // not just 1. |
332 | 332 | ||
333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
335 | 335 | ||
336 | int add = 0; | 336 | int add = 0; |
337 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 337 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
338 | ++add; | 338 | ++add; |
339 | if (dayOfYear % 7 != 0) | 339 | if (dayOfYear % 7 != 0) |
340 | weeknum.setNum(dayOfYear / 7 + 1+add); | 340 | weeknum.setNum(dayOfYear / 7 + 1+add); |
341 | else | 341 | else |
342 | weeknum.setNum(dayOfYear / 7 +add); | 342 | weeknum.setNum(dayOfYear / 7 +add); |
343 | weeknos[i]->setText(weeknum); | 343 | weeknos[i]->setText(weeknum); |
344 | } | 344 | } |
345 | 345 | ||
346 | setUpdatesEnabled( true ); | 346 | setUpdatesEnabled( true ); |
347 | // kdDebug() << "updateView() -> repaint()" << endl; | 347 | // kdDebug() << "updateView() -> repaint()" << endl; |
348 | repaint(); | 348 | repaint(); |
349 | // daymatrix->repaint(); | 349 | // daymatrix->repaint(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void KDateNavigator::updateConfig() | 352 | void KDateNavigator::updateConfig() |
353 | { | 353 | { |
354 | int day; | 354 | int day; |
355 | for(int i=0; i<7; i++) { | 355 | for(int i=0; i<7; i++) { |
356 | // take the first letter of the day name to be the abbreviation | 356 | // take the first letter of the day name to be the abbreviation |
357 | if (KGlobal::locale()->weekStartsMonday()) { | 357 | if (KGlobal::locale()->weekStartsMonday()) { |
358 | day = i+1; | 358 | day = i+1; |
359 | } else { | 359 | } else { |
360 | if (i==0) day = 7; | 360 | if (i==0) day = 7; |
361 | else day = i; | 361 | else day = i; |
362 | } | 362 | } |
363 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 363 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
364 | true ); | 364 | true ); |
365 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 365 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
366 | headings[i]->setText( dayName ); | 366 | headings[i]->setText( dayName ); |
367 | } | 367 | } |
368 | updateDates(); | 368 | updateDates(); |
369 | updateView(); | 369 | updateView(); |
370 | } | 370 | } |
371 | 371 | ||
372 | void KDateNavigator::setShowWeekNums(bool enabled) | 372 | void KDateNavigator::setShowWeekNums(bool enabled) |
373 | { | 373 | { |
374 | qDebug("KDateNavigator::setShowWeekNums***************************** "); | ||
374 | m_bShowWeekNums = enabled; | 375 | m_bShowWeekNums = enabled; |
375 | for(int i=0; i<6; i++) { | 376 | for(int i=0; i<6; i++) { |
376 | if(enabled) | 377 | if(enabled) |
377 | weeknos[i]->show(); | 378 | weeknos[i]->show(); |
378 | else | 379 | else |
379 | weeknos[i]->hide(); | 380 | weeknos[i]->hide(); |
380 | } | 381 | } |
381 | resize(size()); | 382 | resize(size()); |
382 | } | 383 | } |
383 | 384 | ||
384 | void KDateNavigator::selectDates(const DateList& dateList) | 385 | void KDateNavigator::selectDates(const DateList& dateList) |
385 | { | 386 | { |
386 | 387 | ||
387 | if (dateList.count() > 0) { | 388 | if (dateList.count() > 0) { |
388 | mNavigatorBar->selectDates( dateList ); | 389 | mNavigatorBar->selectDates( dateList ); |
389 | mSelectedDates = dateList; | 390 | mSelectedDates = dateList; |
390 | 391 | ||
391 | // set our record of the month and year that this datetbl is | 392 | // set our record of the month and year that this datetbl is |
392 | // displaying. | 393 | // displaying. |
393 | m_MthYr = mSelectedDates.first(); | 394 | m_MthYr = mSelectedDates.first(); |
394 | 395 | ||
395 | 396 | ||
396 | // set our record of the first day of the week of the current | 397 | // set our record of the first day of the week of the current |
397 | // month. This needs to be done before calling dayToIndex, since it | 398 | // month. This needs to be done before calling dayToIndex, since it |
398 | // relies on this information being up to date. | 399 | // relies on this information being up to date. |
399 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 400 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
400 | m_fstDayOfWk = dayone.dayOfWeek(); | 401 | m_fstDayOfWk = dayone.dayOfWeek(); |
401 | 402 | ||
402 | updateDates(); | 403 | updateDates(); |
403 | 404 | ||
404 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 405 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
405 | 406 | ||
406 | updateView(); | 407 | updateView(); |
407 | } | 408 | } |
408 | } | 409 | } |
409 | 410 | ||
410 | int KDateNavigator::dayNum(int row, int col) | 411 | int KDateNavigator::dayNum(int row, int col) |
411 | { | 412 | { |
412 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 413 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
413 | } | 414 | } |
414 | 415 | ||
415 | int KDateNavigator::dayToIndex(int dayNum) | 416 | int KDateNavigator::dayToIndex(int dayNum) |
416 | { | 417 | { |
417 | int row, col; | 418 | int row, col; |
418 | 419 | ||
419 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 420 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
420 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 421 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
421 | row++; | 422 | row++; |
422 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 423 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
423 | return row * 7 + col; | 424 | return row * 7 + col; |
424 | } | 425 | } |
425 | 426 | ||
426 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 427 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
427 | { | 428 | { |
428 | if(e->delta()>0) emit goPrevious(); | 429 | if(e->delta()>0) emit goPrevious(); |
429 | else emit goNext(); | 430 | else emit goNext(); |
430 | 431 | ||
431 | e->accept(); | 432 | e->accept(); |
432 | } | 433 | } |
433 | 434 | ||
434 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 435 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
435 | { | 436 | { |
436 | if (e->type() == QEvent::MouseButtonPress) { | 437 | if (e->type() == QEvent::MouseButtonPress) { |
437 | int i; | 438 | int i; |
438 | for(i=0;i<6;++i) { | 439 | for(i=0;i<6;++i) { |
439 | if (o == weeknos[i]) { | 440 | if (o == weeknos[i]) { |
440 | QDate weekstart = daymatrix->getDate(i*7); | 441 | QDate weekstart = daymatrix->getDate(i*7); |
441 | emit weekClicked(weekstart); | 442 | emit weekClicked(weekstart); |
442 | break; | 443 | break; |
443 | } | 444 | } |
444 | } | 445 | } |
445 | for(i=0;i<7;++i) { | 446 | for(i=0;i<7;++i) { |
446 | if (o == headings[i]) { | 447 | if (o == headings[i]) { |
447 | KCal::DateList selDays; | 448 | KCal::DateList selDays; |
448 | QDate date = daymatrix->getDate(14); | 449 | QDate date = daymatrix->getDate(14); |
449 | int dio = date.daysInMonth(); | 450 | int dio = date.daysInMonth(); |
450 | int j; | 451 | int j; |
451 | int ye = date.year(); | 452 | int ye = date.year(); |
452 | int mo = date.month(); | 453 | int mo = date.month(); |
453 | for ( j = 1; j <= dio; ++j ) { | 454 | for ( j = 1; j <= dio; ++j ) { |
454 | selDays.append( QDate( ye, mo, j ) ); | 455 | selDays.append( QDate( ye, mo, j ) ); |
455 | } | 456 | } |
456 | emit datesSelected( selDays ); | 457 | emit datesSelected( selDays ); |
457 | break; | 458 | break; |
458 | } | 459 | } |
459 | } | 460 | } |
460 | return true; | 461 | return true; |
461 | } else { | 462 | } else { |
462 | return false; | 463 | return false; |
463 | } | 464 | } |
464 | } | 465 | } |
465 | 466 | ||
466 | //#include "kdatenavigator.moc" | 467 | //#include "kdatenavigator.moc" |