summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
-rw-r--r--korganizer/datenavigator.cpp6
-rw-r--r--korganizer/datenavigator.h1
-rw-r--r--korganizer/interfaces/korganizer/baseview.h1
-rw-r--r--korganizer/komonthview.h1
5 files changed, 13 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3908dbb..47cd488 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1226,1537 +1226,1540 @@ bool CalendarView::syncCalendar(QString filename, int mode)
1226 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1226 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1227 FileStorage* storage = new FileStorage( calendar ); 1227 FileStorage* storage = new FileStorage( calendar );
1228 bool syncOK = false; 1228 bool syncOK = false;
1229 storage->setFileName( filename ); 1229 storage->setFileName( filename );
1230 // qDebug("loading ... "); 1230 // qDebug("loading ... ");
1231 if ( storage->load() ) { 1231 if ( storage->load() ) {
1232 getEventViewerDialog()->setSyncMode( true ); 1232 getEventViewerDialog()->setSyncMode( true );
1233 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1233 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1234 getEventViewerDialog()->setSyncMode( false ); 1234 getEventViewerDialog()->setSyncMode( false );
1235 if ( syncOK ) { 1235 if ( syncOK ) {
1236 if ( mSyncManager->mWriteBackFile ) 1236 if ( mSyncManager->mWriteBackFile )
1237 { 1237 {
1238 storage->setSaveFormat( new ICalFormat() ); 1238 storage->setSaveFormat( new ICalFormat() );
1239 storage->save(); 1239 storage->save();
1240 } 1240 }
1241 } 1241 }
1242 setModified( true ); 1242 setModified( true );
1243 } 1243 }
1244 delete storage; 1244 delete storage;
1245 delete calendar; 1245 delete calendar;
1246 if ( syncOK ) 1246 if ( syncOK )
1247 updateView(); 1247 updateView();
1248 return syncOK; 1248 return syncOK;
1249} 1249}
1250 1250
1251void CalendarView::syncExternal( int mode ) 1251void CalendarView::syncExternal( int mode )
1252{ 1252{
1253 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1253 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1254 1254
1255 qApp->processEvents(); 1255 qApp->processEvents();
1256 CalendarLocal* calendar = new CalendarLocal(); 1256 CalendarLocal* calendar = new CalendarLocal();
1257 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1257 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1258 bool syncOK = false; 1258 bool syncOK = false;
1259 bool loadSuccess = false; 1259 bool loadSuccess = false;
1260 PhoneFormat* phoneFormat = 0; 1260 PhoneFormat* phoneFormat = 0;
1261 emit tempDisableBR(true); 1261 emit tempDisableBR(true);
1262#ifndef DESKTOP_VERSION 1262#ifndef DESKTOP_VERSION
1263 SharpFormat* sharpFormat = 0; 1263 SharpFormat* sharpFormat = 0;
1264 if ( mode == 0 ) { // sharp 1264 if ( mode == 0 ) { // sharp
1265 sharpFormat = new SharpFormat () ; 1265 sharpFormat = new SharpFormat () ;
1266 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1266 loadSuccess = sharpFormat->load( calendar, mCalendar );
1267 1267
1268 } else 1268 } else
1269#endif 1269#endif
1270 if ( mode == 1 ) { // phone 1270 if ( mode == 1 ) { // phone
1271 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1271 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1272 mSyncManager->mPhoneDevice, 1272 mSyncManager->mPhoneDevice,
1273 mSyncManager->mPhoneConnection, 1273 mSyncManager->mPhoneConnection,
1274 mSyncManager->mPhoneModel); 1274 mSyncManager->mPhoneModel);
1275 loadSuccess = phoneFormat->load( calendar,mCalendar); 1275 loadSuccess = phoneFormat->load( calendar,mCalendar);
1276 1276
1277 } else { 1277 } else {
1278 emit tempDisableBR(false); 1278 emit tempDisableBR(false);
1279 return; 1279 return;
1280 } 1280 }
1281 if ( loadSuccess ) { 1281 if ( loadSuccess ) {
1282 getEventViewerDialog()->setSyncMode( true ); 1282 getEventViewerDialog()->setSyncMode( true );
1283 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1283 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1284 getEventViewerDialog()->setSyncMode( false ); 1284 getEventViewerDialog()->setSyncMode( false );
1285 qApp->processEvents(); 1285 qApp->processEvents();
1286 if ( syncOK ) { 1286 if ( syncOK ) {
1287 if ( mSyncManager->mWriteBackFile ) 1287 if ( mSyncManager->mWriteBackFile )
1288 { 1288 {
1289 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1289 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1290 Incidence* inc = iL.first(); 1290 Incidence* inc = iL.first();
1291 if ( phoneFormat ) { 1291 if ( phoneFormat ) {
1292 while ( inc ) { 1292 while ( inc ) {
1293 inc->removeID(mCurrentSyncDevice); 1293 inc->removeID(mCurrentSyncDevice);
1294 inc = iL.next(); 1294 inc = iL.next();
1295 } 1295 }
1296 } 1296 }
1297#ifndef DESKTOP_VERSION 1297#ifndef DESKTOP_VERSION
1298 if ( sharpFormat ) 1298 if ( sharpFormat )
1299 sharpFormat->save(calendar); 1299 sharpFormat->save(calendar);
1300#endif 1300#endif
1301 if ( phoneFormat ) 1301 if ( phoneFormat )
1302 phoneFormat->save(calendar); 1302 phoneFormat->save(calendar);
1303 iL = calendar->rawIncidences(); 1303 iL = calendar->rawIncidences();
1304 inc = iL.first(); 1304 inc = iL.first();
1305 Incidence* loc; 1305 Incidence* loc;
1306 while ( inc ) { 1306 while ( inc ) {
1307 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1307 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1308 loc = mCalendar->incidence(inc->uid() ); 1308 loc = mCalendar->incidence(inc->uid() );
1309 if ( loc ) { 1309 if ( loc ) {
1310 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1310 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1311 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1311 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1312 } 1312 }
1313 } 1313 }
1314 inc = iL.next(); 1314 inc = iL.next();
1315 } 1315 }
1316 Incidence* lse = getLastSyncEvent(); 1316 Incidence* lse = getLastSyncEvent();
1317 if ( lse ) { 1317 if ( lse ) {
1318 lse->setReadOnly( false ); 1318 lse->setReadOnly( false );
1319 lse->setDescription( "" ); 1319 lse->setDescription( "" );
1320 lse->setReadOnly( true ); 1320 lse->setReadOnly( true );
1321 } 1321 }
1322 } 1322 }
1323 } else { 1323 } else {
1324 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1324 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1325 } 1325 }
1326 setModified( true ); 1326 setModified( true );
1327 } else { 1327 } else {
1328 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1328 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1329 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1329 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1330 question, i18n("Ok")) ; 1330 question, i18n("Ok")) ;
1331 1331
1332 } 1332 }
1333 delete calendar; 1333 delete calendar;
1334 updateView(); 1334 updateView();
1335 emit tempDisableBR(false); 1335 emit tempDisableBR(false);
1336 return ;//syncOK; 1336 return ;//syncOK;
1337 1337
1338} 1338}
1339 1339
1340bool CalendarView::importBday() 1340bool CalendarView::importBday()
1341{ 1341{
1342#ifndef KORG_NOKABC 1342#ifndef KORG_NOKABC
1343 1343
1344#ifdef DESKTOP_VERSION 1344#ifdef DESKTOP_VERSION
1345 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1345 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1346 KABC::AddressBook::Iterator it; 1346 KABC::AddressBook::Iterator it;
1347 int count = 0; 1347 int count = 0;
1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1349 ++count; 1349 ++count;
1350 } 1350 }
1351 QProgressBar bar(count,0 ); 1351 QProgressBar bar(count,0 );
1352 int w = 300; 1352 int w = 300;
1353 if ( QApplication::desktop()->width() < 320 ) 1353 if ( QApplication::desktop()->width() < 320 )
1354 w = 220; 1354 w = 220;
1355 int h = bar.sizeHint().height() ; 1355 int h = bar.sizeHint().height() ;
1356 int dw = QApplication::desktop()->width(); 1356 int dw = QApplication::desktop()->width();
1357 int dh = QApplication::desktop()->height(); 1357 int dh = QApplication::desktop()->height();
1358 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1358 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1359 bar.show(); 1359 bar.show();
1360 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1360 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1361 qApp->processEvents(); 1361 qApp->processEvents();
1362 count = 0; 1362 count = 0;
1363 int addCount = 0; 1363 int addCount = 0;
1364 KCal::Attendee* a = 0; 1364 KCal::Attendee* a = 0;
1365 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1365 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1366 if ( ! bar.isVisible() ) 1366 if ( ! bar.isVisible() )
1367 return false; 1367 return false;
1368 bar.setProgress( count++ ); 1368 bar.setProgress( count++ );
1369 qApp->processEvents(); 1369 qApp->processEvents();
1370 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1370 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1371 if ( (*it).birthday().date().isValid() ){ 1371 if ( (*it).birthday().date().isValid() ){
1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1373 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1373 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1374 ++addCount; 1374 ++addCount;
1375 } 1375 }
1376 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1376 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1377 if ( anni.isValid() ){ 1377 if ( anni.isValid() ){
1378 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1378 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1379 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1379 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1380 ++addCount; 1380 ++addCount;
1381 } 1381 }
1382 } 1382 }
1383 updateView(); 1383 updateView();
1384 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1384 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1385#else //DESKTOP_VERSION 1385#else //DESKTOP_VERSION
1386 1386
1387 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1387 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1388 // the result should now arrive through method insertBirthdays 1388 // the result should now arrive through method insertBirthdays
1389 1389
1390#endif //DESKTOP_VERSION 1390#endif //DESKTOP_VERSION
1391 1391
1392#endif //KORG_NOKABC 1392#endif //KORG_NOKABC
1393 1393
1394 1394
1395 return true; 1395 return true;
1396} 1396}
1397 1397
1398// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1398// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1399void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1399void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1400 const QStringList& anniversaryList, const QStringList& realNameList, 1400 const QStringList& anniversaryList, const QStringList& realNameList,
1401 const QStringList& emailList, const QStringList& assembledNameList, 1401 const QStringList& emailList, const QStringList& assembledNameList,
1402 const QStringList& uidList) 1402 const QStringList& uidList)
1403{ 1403{
1404 qDebug("CalendarView::insertBirthdays"); 1404 qDebug("CalendarView::insertBirthdays");
1405 if (uid == this->name()) 1405 if (uid == this->name())
1406 { 1406 {
1407 int count = birthdayList.count(); 1407 int count = birthdayList.count();
1408 int addCount = 0; 1408 int addCount = 0;
1409 KCal::Attendee* a = 0; 1409 KCal::Attendee* a = 0;
1410 1410
1411 qDebug("CalView 1 %i", count); 1411 qDebug("CalView 1 %i", count);
1412 1412
1413 QProgressBar bar(count,0 ); 1413 QProgressBar bar(count,0 );
1414 int w = 300; 1414 int w = 300;
1415 if ( QApplication::desktop()->width() < 320 ) 1415 if ( QApplication::desktop()->width() < 320 )
1416 w = 220; 1416 w = 220;
1417 int h = bar.sizeHint().height() ; 1417 int h = bar.sizeHint().height() ;
1418 int dw = QApplication::desktop()->width(); 1418 int dw = QApplication::desktop()->width();
1419 int dh = QApplication::desktop()->height(); 1419 int dh = QApplication::desktop()->height();
1420 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1420 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1421 bar.show(); 1421 bar.show();
1422 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1422 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1423 qApp->processEvents(); 1423 qApp->processEvents();
1424 1424
1425 QDate birthday; 1425 QDate birthday;
1426 QDate anniversary; 1426 QDate anniversary;
1427 QString realName; 1427 QString realName;
1428 QString email; 1428 QString email;
1429 QString assembledName; 1429 QString assembledName;
1430 QString uid; 1430 QString uid;
1431 bool ok = true; 1431 bool ok = true;
1432 for ( int i = 0; i < count; i++) 1432 for ( int i = 0; i < count; i++)
1433 { 1433 {
1434 if ( ! bar.isVisible() ) 1434 if ( ! bar.isVisible() )
1435 return; 1435 return;
1436 bar.setProgress( i ); 1436 bar.setProgress( i );
1437 qApp->processEvents(); 1437 qApp->processEvents();
1438 1438
1439 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1439 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1440 if (!ok) { 1440 if (!ok) {
1441 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1441 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1442 } 1442 }
1443 1443
1444 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1444 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1445 if (!ok) { 1445 if (!ok) {
1446 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1446 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1447 } 1447 }
1448 realName = realNameList[i]; 1448 realName = realNameList[i];
1449 email = emailList[i]; 1449 email = emailList[i];
1450 assembledName = assembledNameList[i]; 1450 assembledName = assembledNameList[i];
1451 uid = uidList[i]; 1451 uid = uidList[i];
1452 //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() ); 1452 //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() );
1453 1453
1454 if ( birthday.isValid() ){ 1454 if ( birthday.isValid() ){
1455 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1455 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1456 KCal::Attendee::ReqParticipant,uid) ; 1456 KCal::Attendee::ReqParticipant,uid) ;
1457 if ( addAnniversary( birthday, assembledName, a, true ) ) 1457 if ( addAnniversary( birthday, assembledName, a, true ) )
1458 ++addCount; 1458 ++addCount;
1459 } 1459 }
1460 1460
1461 if ( anniversary.isValid() ){ 1461 if ( anniversary.isValid() ){
1462 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1462 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1463 KCal::Attendee::ReqParticipant,uid) ; 1463 KCal::Attendee::ReqParticipant,uid) ;
1464 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1464 if ( addAnniversary( anniversary, assembledName, a, false ) )
1465 ++addCount; 1465 ++addCount;
1466 } 1466 }
1467 } 1467 }
1468 1468
1469 updateView(); 1469 updateView();
1470 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1470 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1471 1471
1472 } 1472 }
1473 1473
1474} 1474}
1475 1475
1476 1476
1477 1477
1478bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1478bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1479{ 1479{
1480 //qDebug("addAnni "); 1480 //qDebug("addAnni ");
1481 Event * ev = new Event(); 1481 Event * ev = new Event();
1482 if ( a ) { 1482 if ( a ) {
1483 ev->addAttendee( a ); 1483 ev->addAttendee( a );
1484 } 1484 }
1485 QString kind; 1485 QString kind;
1486 if ( birthday ) 1486 if ( birthday )
1487 kind = i18n( "Birthday" ); 1487 kind = i18n( "Birthday" );
1488 else 1488 else
1489 kind = i18n( "Anniversary" ); 1489 kind = i18n( "Anniversary" );
1490 ev->setSummary( name + " - " + kind ); 1490 ev->setSummary( name + " - " + kind );
1491 ev->setOrganizer(a->email()); 1491 ev->setOrganizer(a->email());
1492 ev->setCategories( kind ); 1492 ev->setCategories( kind );
1493 ev->setDtStart( QDateTime(date) ); 1493 ev->setDtStart( QDateTime(date) );
1494 ev->setDtEnd( QDateTime(date) ); 1494 ev->setDtEnd( QDateTime(date) );
1495 ev->setFloats( true ); 1495 ev->setFloats( true );
1496 Recurrence * rec = ev->recurrence(); 1496 Recurrence * rec = ev->recurrence();
1497 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1497 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1498 rec->addYearlyNum( date.month() ); 1498 rec->addYearlyNum( date.month() );
1499 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1499 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1500 delete ev; 1500 delete ev;
1501 return false; 1501 return false;
1502 } 1502 }
1503 return true; 1503 return true;
1504 1504
1505} 1505}
1506bool CalendarView::importQtopia( const QString &categories, 1506bool CalendarView::importQtopia( const QString &categories,
1507 const QString &datebook, 1507 const QString &datebook,
1508 const QString &todolist ) 1508 const QString &todolist )
1509{ 1509{
1510 1510
1511 QtopiaFormat qtopiaFormat; 1511 QtopiaFormat qtopiaFormat;
1512 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1512 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1513 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1513 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1514 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1514 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1515 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1515 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1516 1516
1517 updateView(); 1517 updateView();
1518 return true; 1518 return true;
1519 1519
1520#if 0 1520#if 0
1521 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1521 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1522 mCurrentSyncDevice = "qtopia-XML"; 1522 mCurrentSyncDevice = "qtopia-XML";
1523 if ( mSyncManager->mAskForPreferences ) 1523 if ( mSyncManager->mAskForPreferences )
1524 edit_sync_options(); 1524 edit_sync_options();
1525 qApp->processEvents(); 1525 qApp->processEvents();
1526 CalendarLocal* calendar = new CalendarLocal(); 1526 CalendarLocal* calendar = new CalendarLocal();
1527 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1527 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1528 bool syncOK = false; 1528 bool syncOK = false;
1529 QtopiaFormat qtopiaFormat; 1529 QtopiaFormat qtopiaFormat;
1530 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1530 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1531 bool loadOk = true; 1531 bool loadOk = true;
1532 if ( !categories.isEmpty() ) 1532 if ( !categories.isEmpty() )
1533 loadOk = qtopiaFormat.load( calendar, categories ); 1533 loadOk = qtopiaFormat.load( calendar, categories );
1534 if ( loadOk && !datebook.isEmpty() ) 1534 if ( loadOk && !datebook.isEmpty() )
1535 loadOk = qtopiaFormat.load( calendar, datebook ); 1535 loadOk = qtopiaFormat.load( calendar, datebook );
1536 if ( loadOk && !todolist.isEmpty() ) 1536 if ( loadOk && !todolist.isEmpty() )
1537 loadOk = qtopiaFormat.load( calendar, todolist ); 1537 loadOk = qtopiaFormat.load( calendar, todolist );
1538 1538
1539 if ( loadOk ) { 1539 if ( loadOk ) {
1540 getEventViewerDialog()->setSyncMode( true ); 1540 getEventViewerDialog()->setSyncMode( true );
1541 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1541 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1542 getEventViewerDialog()->setSyncMode( false ); 1542 getEventViewerDialog()->setSyncMode( false );
1543 qApp->processEvents(); 1543 qApp->processEvents();
1544 if ( syncOK ) { 1544 if ( syncOK ) {
1545 if ( mSyncManager->mWriteBackFile ) 1545 if ( mSyncManager->mWriteBackFile )
1546 { 1546 {
1547 // write back XML file 1547 // write back XML file
1548 1548
1549 } 1549 }
1550 setModified( true ); 1550 setModified( true );
1551 } 1551 }
1552 } else { 1552 } else {
1553 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1553 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1554 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1554 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1555 question, i18n("Ok")) ; 1555 question, i18n("Ok")) ;
1556 } 1556 }
1557 delete calendar; 1557 delete calendar;
1558 updateView(); 1558 updateView();
1559 return syncOK; 1559 return syncOK;
1560 1560
1561 1561
1562#endif 1562#endif
1563 1563
1564} 1564}
1565 1565
1566void CalendarView::setSyncEventsReadOnly() 1566void CalendarView::setSyncEventsReadOnly()
1567{ 1567{
1568 Event * ev; 1568 Event * ev;
1569 QPtrList<Event> eL = mCalendar->rawEvents(); 1569 QPtrList<Event> eL = mCalendar->rawEvents();
1570 ev = eL.first(); 1570 ev = eL.first();
1571 while ( ev ) { 1571 while ( ev ) {
1572 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1572 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1573 ev->setReadOnly( true ); 1573 ev->setReadOnly( true );
1574 ev = eL.next(); 1574 ev = eL.next();
1575 } 1575 }
1576} 1576}
1577bool CalendarView::openCalendar(QString filename, bool merge) 1577bool CalendarView::openCalendar(QString filename, bool merge)
1578{ 1578{
1579 1579
1580 if (filename.isEmpty()) { 1580 if (filename.isEmpty()) {
1581 return false; 1581 return false;
1582 } 1582 }
1583 1583
1584 if (!QFile::exists(filename)) { 1584 if (!QFile::exists(filename)) {
1585 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1585 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1586 return false; 1586 return false;
1587 } 1587 }
1588 1588
1589 globalFlagBlockAgenda = 1; 1589 globalFlagBlockAgenda = 1;
1590 if (!merge) mCalendar->close(); 1590 if (!merge) mCalendar->close();
1591 1591
1592 mStorage->setFileName( filename ); 1592 mStorage->setFileName( filename );
1593 1593
1594 if ( mStorage->load() ) { 1594 if ( mStorage->load() ) {
1595 if ( merge ) ;//setModified( true ); 1595 if ( merge ) ;//setModified( true );
1596 else { 1596 else {
1597 //setModified( true ); 1597 //setModified( true );
1598 mViewManager->setDocumentId( filename ); 1598 mViewManager->setDocumentId( filename );
1599 mDialogManager->setDocumentId( filename ); 1599 mDialogManager->setDocumentId( filename );
1600 mTodoList->setDocumentId( filename ); 1600 mTodoList->setDocumentId( filename );
1601 } 1601 }
1602 globalFlagBlockAgenda = 2; 1602 globalFlagBlockAgenda = 2;
1603 // if ( getLastSyncEvent() ) 1603 // if ( getLastSyncEvent() )
1604 // getLastSyncEvent()->setReadOnly( true ); 1604 // getLastSyncEvent()->setReadOnly( true );
1605 mCalendar->reInitAlarmSettings(); 1605 mCalendar->reInitAlarmSettings();
1606 setSyncEventsReadOnly(); 1606 setSyncEventsReadOnly();
1607 updateUnmanagedViews(); 1607 updateUnmanagedViews();
1608 updateView(); 1608 updateView();
1609 if ( filename != MainWindow::defaultFileName() ) { 1609 if ( filename != MainWindow::defaultFileName() ) {
1610 saveCalendar( MainWindow::defaultFileName() ); 1610 saveCalendar( MainWindow::defaultFileName() );
1611 } else { 1611 } else {
1612 QFileInfo finf ( MainWindow::defaultFileName()); 1612 QFileInfo finf ( MainWindow::defaultFileName());
1613 if ( finf.exists() ) { 1613 if ( finf.exists() ) {
1614 setLoadedFileVersion( finf.lastModified () ); 1614 setLoadedFileVersion( finf.lastModified () );
1615 } 1615 }
1616 } 1616 }
1617 return true; 1617 return true;
1618 } else { 1618 } else {
1619 // while failing to load, the calendar object could 1619 // while failing to load, the calendar object could
1620 // have become partially populated. Clear it out. 1620 // have become partially populated. Clear it out.
1621 if ( !merge ) { 1621 if ( !merge ) {
1622 mCalendar->close(); 1622 mCalendar->close();
1623 mViewManager->setDocumentId( filename ); 1623 mViewManager->setDocumentId( filename );
1624 mDialogManager->setDocumentId( filename ); 1624 mDialogManager->setDocumentId( filename );
1625 mTodoList->setDocumentId( filename ); 1625 mTodoList->setDocumentId( filename );
1626 } 1626 }
1627 1627
1628 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1628 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1629 1629
1630 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1630 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1631 globalFlagBlockAgenda = 2; 1631 globalFlagBlockAgenda = 2;
1632 mCalendar->reInitAlarmSettings(); 1632 mCalendar->reInitAlarmSettings();
1633 setSyncEventsReadOnly(); 1633 setSyncEventsReadOnly();
1634 updateUnmanagedViews(); 1634 updateUnmanagedViews();
1635 updateView(); 1635 updateView();
1636 } 1636 }
1637 return false; 1637 return false;
1638} 1638}
1639void CalendarView::showOpenError() 1639void CalendarView::showOpenError()
1640{ 1640{
1641 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1641 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1642} 1642}
1643void CalendarView::setLoadedFileVersion(QDateTime dt) 1643void CalendarView::setLoadedFileVersion(QDateTime dt)
1644{ 1644{
1645 loadedFileVersion = dt; 1645 loadedFileVersion = dt;
1646} 1646}
1647bool CalendarView::checkFileChanged(QString fn) 1647bool CalendarView::checkFileChanged(QString fn)
1648{ 1648{
1649 QFileInfo finf ( fn ); 1649 QFileInfo finf ( fn );
1650 if ( !finf.exists() ) 1650 if ( !finf.exists() )
1651 return true; 1651 return true;
1652 QDateTime dt = finf.lastModified (); 1652 QDateTime dt = finf.lastModified ();
1653 if ( dt <= loadedFileVersion ) 1653 if ( dt <= loadedFileVersion )
1654 return false; 1654 return false;
1655 return true; 1655 return true;
1656 1656
1657} 1657}
1658void CalendarView::watchSavedFile() 1658void CalendarView::watchSavedFile()
1659{ 1659{
1660 QFileInfo finf ( MainWindow::defaultFileName()); 1660 QFileInfo finf ( MainWindow::defaultFileName());
1661 if ( !finf.exists() ) 1661 if ( !finf.exists() )
1662 return; 1662 return;
1663 QDateTime dt = finf.lastModified (); 1663 QDateTime dt = finf.lastModified ();
1664 if ( dt < loadedFileVersion ) { 1664 if ( dt < loadedFileVersion ) {
1665 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1665 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1666 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1666 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1667 return; 1667 return;
1668 } 1668 }
1669 loadedFileVersion = dt; 1669 loadedFileVersion = dt;
1670} 1670}
1671 1671
1672bool CalendarView::checkFileVersion(QString fn) 1672bool CalendarView::checkFileVersion(QString fn)
1673{ 1673{
1674 QFileInfo finf ( fn ); 1674 QFileInfo finf ( fn );
1675 if ( !finf.exists() ) 1675 if ( !finf.exists() )
1676 return true; 1676 return true;
1677 QDateTime dt = finf.lastModified (); 1677 QDateTime dt = finf.lastModified ();
1678 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1678 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1679 //qDebug("file on disk version %s",dt.toString().latin1()); 1679 //qDebug("file on disk version %s",dt.toString().latin1());
1680 if ( dt <= loadedFileVersion ) 1680 if ( dt <= loadedFileVersion )
1681 return true; 1681 return true;
1682 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)) , 1682 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)) ,
1683 i18n("KO/Pi Warning"),i18n("Overwrite"), 1683 i18n("KO/Pi Warning"),i18n("Overwrite"),
1684 i18n("Sync+save")); 1684 i18n("Sync+save"));
1685 1685
1686 if ( km == KMessageBox::Cancel ) 1686 if ( km == KMessageBox::Cancel )
1687 return false; 1687 return false;
1688 if ( km == KMessageBox::Yes ) 1688 if ( km == KMessageBox::Yes )
1689 return true; 1689 return true;
1690 1690
1691 setSyncDevice("deleteaftersync" ); 1691 setSyncDevice("deleteaftersync" );
1692 mSyncManager->mAskForPreferences = true; 1692 mSyncManager->mAskForPreferences = true;
1693 mSyncManager->mSyncAlgoPrefs = 3; 1693 mSyncManager->mSyncAlgoPrefs = 3;
1694 mSyncManager->mWriteBackFile = false; 1694 mSyncManager->mWriteBackFile = false;
1695 mSyncManager->mWriteBackExistingOnly = false; 1695 mSyncManager->mWriteBackExistingOnly = false;
1696 mSyncManager->mShowSyncSummary = false; 1696 mSyncManager->mShowSyncSummary = false;
1697 syncCalendar( fn, 3 ); 1697 syncCalendar( fn, 3 );
1698 Event * e = getLastSyncEvent(); 1698 Event * e = getLastSyncEvent();
1699 mCalendar->deleteEvent ( e ); 1699 mCalendar->deleteEvent ( e );
1700 updateView(); 1700 updateView();
1701 return true; 1701 return true;
1702} 1702}
1703 1703
1704bool CalendarView::saveCalendar( QString filename ) 1704bool CalendarView::saveCalendar( QString filename )
1705{ 1705{
1706 1706
1707 // Store back all unsaved data into calendar object 1707 // Store back all unsaved data into calendar object
1708 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1708 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1709 if ( mViewManager->currentView() ) 1709 if ( mViewManager->currentView() )
1710 mViewManager->currentView()->flushView(); 1710 mViewManager->currentView()->flushView();
1711 1711
1712 1712
1713 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1713 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1714 mStorage->setSaveFormat( new ICalFormat() ); 1714 mStorage->setSaveFormat( new ICalFormat() );
1715 mStorage->setFileName( filename ); 1715 mStorage->setFileName( filename );
1716 bool success; 1716 bool success;
1717 success = mStorage->save(); 1717 success = mStorage->save();
1718 if ( !success ) { 1718 if ( !success ) {
1719 return false; 1719 return false;
1720 } 1720 }
1721 if ( filename == MainWindow::defaultFileName() ) { 1721 if ( filename == MainWindow::defaultFileName() ) {
1722 setLoadedFileVersion( lfv ); 1722 setLoadedFileVersion( lfv );
1723 watchSavedFile(); 1723 watchSavedFile();
1724 } 1724 }
1725 return true; 1725 return true;
1726} 1726}
1727 1727
1728void CalendarView::closeCalendar() 1728void CalendarView::closeCalendar()
1729{ 1729{
1730 1730
1731 // child windows no longer valid 1731 // child windows no longer valid
1732 emit closingDown(); 1732 emit closingDown();
1733 1733
1734 mCalendar->close(); 1734 mCalendar->close();
1735 setModified(false); 1735 setModified(false);
1736 updateView(); 1736 updateView();
1737} 1737}
1738 1738
1739void CalendarView::archiveCalendar() 1739void CalendarView::archiveCalendar()
1740{ 1740{
1741 mDialogManager->showArchiveDialog(); 1741 mDialogManager->showArchiveDialog();
1742} 1742}
1743 1743
1744 1744
1745void CalendarView::readSettings() 1745void CalendarView::readSettings()
1746{ 1746{
1747 1747
1748 1748
1749 // mViewManager->showAgendaView(); 1749 // mViewManager->showAgendaView();
1750 QString str; 1750 QString str;
1751 //qDebug("CalendarView::readSettings() "); 1751 //qDebug("CalendarView::readSettings() ");
1752 // read settings from the KConfig, supplying reasonable 1752 // read settings from the KConfig, supplying reasonable
1753 // defaults where none are to be found 1753 // defaults where none are to be found
1754 KConfig *config = KOGlobals::config(); 1754 KConfig *config = KOGlobals::config();
1755#ifndef KORG_NOSPLITTER 1755#ifndef KORG_NOSPLITTER
1756 config->setGroup("KOrganizer Geometry"); 1756 config->setGroup("KOrganizer Geometry");
1757 1757
1758 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1758 QValueList<int> sizes = config->readIntListEntry("Separator1");
1759 if (sizes.count() != 2) { 1759 if (sizes.count() != 2) {
1760 sizes << mDateNavigator->minimumSizeHint().width(); 1760 sizes << mDateNavigator->minimumSizeHint().width();
1761 sizes << 300; 1761 sizes << 300;
1762 } 1762 }
1763 mPanner->setSizes(sizes); 1763 mPanner->setSizes(sizes);
1764 1764
1765 sizes = config->readIntListEntry("Separator2"); 1765 sizes = config->readIntListEntry("Separator2");
1766 if ( ( mResourceView && sizes.count() == 4 ) || 1766 if ( ( mResourceView && sizes.count() == 4 ) ||
1767 ( !mResourceView && sizes.count() == 3 ) ) { 1767 ( !mResourceView && sizes.count() == 3 ) ) {
1768 mLeftSplitter->setSizes(sizes); 1768 mLeftSplitter->setSizes(sizes);
1769 } 1769 }
1770#endif 1770#endif
1771 globalFlagBlockAgenda = 1; 1771 globalFlagBlockAgenda = 1;
1772 mViewManager->showAgendaView(); 1772 mViewManager->showAgendaView();
1773 //mViewManager->readSettings( config ); 1773 //mViewManager->readSettings( config );
1774 mTodoList->restoreLayout(config,QString("Todo Layout")); 1774 mTodoList->restoreLayout(config,QString("Todo Layout"));
1775 readFilterSettings(config); 1775 readFilterSettings(config);
1776 config->setGroup( "Views" ); 1776 config->setGroup( "Views" );
1777 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1777 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1778 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1778 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1779 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1779 else if ( dateCount == 7 ) mNavigator->selectWeek();
1780 else mNavigator->selectDates( dateCount ); 1780 else mNavigator->selectDates( dateCount );
1781 // mViewManager->readSettings( config ); 1781 // mViewManager->readSettings( config );
1782 updateConfig(); 1782 updateConfig();
1783 globalFlagBlockAgenda = 2; 1783 globalFlagBlockAgenda = 2;
1784 mViewManager->readSettings( config ); 1784 mViewManager->readSettings( config );
1785#ifdef DESKTOP_VERSION 1785#ifdef DESKTOP_VERSION
1786 config->setGroup("WidgetLayout"); 1786 config->setGroup("WidgetLayout");
1787 QStringList list; 1787 QStringList list;
1788 list = config->readListEntry("MainLayout"); 1788 list = config->readListEntry("MainLayout");
1789 int x,y,w,h; 1789 int x,y,w,h;
1790 if ( ! list.isEmpty() ) { 1790 if ( ! list.isEmpty() ) {
1791 x = list[0].toInt(); 1791 x = list[0].toInt();
1792 y = list[1].toInt(); 1792 y = list[1].toInt();
1793 w = list[2].toInt(); 1793 w = list[2].toInt();
1794 h = list[3].toInt(); 1794 h = list[3].toInt();
1795 topLevelWidget()->setGeometry(x,y,w,h); 1795 topLevelWidget()->setGeometry(x,y,w,h);
1796 1796
1797 } else { 1797 } else {
1798 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1798 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1799 } 1799 }
1800 list = config->readListEntry("EditEventLayout"); 1800 list = config->readListEntry("EditEventLayout");
1801 if ( ! list.isEmpty() ) { 1801 if ( ! list.isEmpty() ) {
1802 x = list[0].toInt(); 1802 x = list[0].toInt();
1803 y = list[1].toInt(); 1803 y = list[1].toInt();
1804 w = list[2].toInt(); 1804 w = list[2].toInt();
1805 h = list[3].toInt(); 1805 h = list[3].toInt();
1806 mEventEditor->setGeometry(x,y,w,h); 1806 mEventEditor->setGeometry(x,y,w,h);
1807 1807
1808 } 1808 }
1809 list = config->readListEntry("EditTodoLayout"); 1809 list = config->readListEntry("EditTodoLayout");
1810 if ( ! list.isEmpty() ) { 1810 if ( ! list.isEmpty() ) {
1811 x = list[0].toInt(); 1811 x = list[0].toInt();
1812 y = list[1].toInt(); 1812 y = list[1].toInt();
1813 w = list[2].toInt(); 1813 w = list[2].toInt();
1814 h = list[3].toInt(); 1814 h = list[3].toInt();
1815 mTodoEditor->setGeometry(x,y,w,h); 1815 mTodoEditor->setGeometry(x,y,w,h);
1816 1816
1817 } 1817 }
1818 list = config->readListEntry("ViewerLayout"); 1818 list = config->readListEntry("ViewerLayout");
1819 if ( ! list.isEmpty() ) { 1819 if ( ! list.isEmpty() ) {
1820 x = list[0].toInt(); 1820 x = list[0].toInt();
1821 y = list[1].toInt(); 1821 y = list[1].toInt();
1822 w = list[2].toInt(); 1822 w = list[2].toInt();
1823 h = list[3].toInt(); 1823 h = list[3].toInt();
1824 getEventViewerDialog()->setGeometry(x,y,w,h); 1824 getEventViewerDialog()->setGeometry(x,y,w,h);
1825 } 1825 }
1826#endif 1826#endif
1827 1827
1828} 1828}
1829 1829
1830 1830
1831void CalendarView::writeSettings() 1831void CalendarView::writeSettings()
1832{ 1832{
1833 // kdDebug() << "CalendarView::writeSettings" << endl; 1833 // kdDebug() << "CalendarView::writeSettings" << endl;
1834 1834
1835 KConfig *config = KOGlobals::config(); 1835 KConfig *config = KOGlobals::config();
1836 1836
1837#ifndef KORG_NOSPLITTER 1837#ifndef KORG_NOSPLITTER
1838 config->setGroup("KOrganizer Geometry"); 1838 config->setGroup("KOrganizer Geometry");
1839 1839
1840 QValueList<int> list = mPanner->sizes(); 1840 QValueList<int> list = mPanner->sizes();
1841 config->writeEntry("Separator1",list); 1841 config->writeEntry("Separator1",list);
1842 1842
1843 list = mLeftSplitter->sizes(); 1843 list = mLeftSplitter->sizes();
1844 config->writeEntry("Separator2",list); 1844 config->writeEntry("Separator2",list);
1845#endif 1845#endif
1846 1846
1847 mViewManager->writeSettings( config ); 1847 mViewManager->writeSettings( config );
1848 mTodoList->saveLayout(config,QString("Todo Layout")); 1848 mTodoList->saveLayout(config,QString("Todo Layout"));
1849 mDialogManager->writeSettings( config ); 1849 mDialogManager->writeSettings( config );
1850 //KOPrefs::instance()->usrWriteConfig(); 1850 //KOPrefs::instance()->usrWriteConfig();
1851 KOPrefs::instance()->writeConfig(); 1851 KOPrefs::instance()->writeConfig();
1852 1852
1853 writeFilterSettings(config); 1853 writeFilterSettings(config);
1854 1854
1855 config->setGroup( "Views" ); 1855 config->setGroup( "Views" );
1856 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1856 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1857 1857
1858#ifdef DESKTOP_VERSION 1858#ifdef DESKTOP_VERSION
1859 config->setGroup("WidgetLayout"); 1859 config->setGroup("WidgetLayout");
1860 QStringList list ;//= config->readListEntry("MainLayout"); 1860 QStringList list ;//= config->readListEntry("MainLayout");
1861 int x,y,w,h; 1861 int x,y,w,h;
1862 QWidget* wid; 1862 QWidget* wid;
1863 wid = topLevelWidget(); 1863 wid = topLevelWidget();
1864 x = wid->geometry().x(); 1864 x = wid->geometry().x();
1865 y = wid->geometry().y(); 1865 y = wid->geometry().y();
1866 w = wid->width(); 1866 w = wid->width();
1867 h = wid->height(); 1867 h = wid->height();
1868 list.clear(); 1868 list.clear();
1869 list << QString::number( x ); 1869 list << QString::number( x );
1870 list << QString::number( y ); 1870 list << QString::number( y );
1871 list << QString::number( w ); 1871 list << QString::number( w );
1872 list << QString::number( h ); 1872 list << QString::number( h );
1873 config->writeEntry("MainLayout",list ); 1873 config->writeEntry("MainLayout",list );
1874 1874
1875 wid = mEventEditor; 1875 wid = mEventEditor;
1876 x = wid->geometry().x(); 1876 x = wid->geometry().x();
1877 y = wid->geometry().y(); 1877 y = wid->geometry().y();
1878 w = wid->width(); 1878 w = wid->width();
1879 h = wid->height(); 1879 h = wid->height();
1880 list.clear(); 1880 list.clear();
1881 list << QString::number( x ); 1881 list << QString::number( x );
1882 list << QString::number( y ); 1882 list << QString::number( y );
1883 list << QString::number( w ); 1883 list << QString::number( w );
1884 list << QString::number( h ); 1884 list << QString::number( h );
1885 config->writeEntry("EditEventLayout",list ); 1885 config->writeEntry("EditEventLayout",list );
1886 1886
1887 wid = mTodoEditor; 1887 wid = mTodoEditor;
1888 x = wid->geometry().x(); 1888 x = wid->geometry().x();
1889 y = wid->geometry().y(); 1889 y = wid->geometry().y();
1890 w = wid->width(); 1890 w = wid->width();
1891 h = wid->height(); 1891 h = wid->height();
1892 list.clear(); 1892 list.clear();
1893 list << QString::number( x ); 1893 list << QString::number( x );
1894 list << QString::number( y ); 1894 list << QString::number( y );
1895 list << QString::number( w ); 1895 list << QString::number( w );
1896 list << QString::number( h ); 1896 list << QString::number( h );
1897 config->writeEntry("EditTodoLayout",list ); 1897 config->writeEntry("EditTodoLayout",list );
1898 wid = getEventViewerDialog(); 1898 wid = getEventViewerDialog();
1899 x = wid->geometry().x(); 1899 x = wid->geometry().x();
1900 y = wid->geometry().y(); 1900 y = wid->geometry().y();
1901 w = wid->width(); 1901 w = wid->width();
1902 h = wid->height(); 1902 h = wid->height();
1903 list.clear(); 1903 list.clear();
1904 list << QString::number( x ); 1904 list << QString::number( x );
1905 list << QString::number( y ); 1905 list << QString::number( y );
1906 list << QString::number( w ); 1906 list << QString::number( w );
1907 list << QString::number( h ); 1907 list << QString::number( h );
1908 config->writeEntry("ViewerLayout",list ); 1908 config->writeEntry("ViewerLayout",list );
1909 wid = mDialogManager->getSearchDialog(); 1909 wid = mDialogManager->getSearchDialog();
1910 if ( wid ) { 1910 if ( wid ) {
1911 x = wid->geometry().x(); 1911 x = wid->geometry().x();
1912 y = wid->geometry().y(); 1912 y = wid->geometry().y();
1913 w = wid->width(); 1913 w = wid->width();
1914 h = wid->height(); 1914 h = wid->height();
1915 list.clear(); 1915 list.clear();
1916 list << QString::number( x ); 1916 list << QString::number( x );
1917 list << QString::number( y ); 1917 list << QString::number( y );
1918 list << QString::number( w ); 1918 list << QString::number( w );
1919 list << QString::number( h ); 1919 list << QString::number( h );
1920 config->writeEntry("SearchLayout",list ); 1920 config->writeEntry("SearchLayout",list );
1921 } 1921 }
1922#endif 1922#endif
1923 1923
1924 1924
1925 config->sync(); 1925 config->sync();
1926} 1926}
1927 1927
1928void CalendarView::readFilterSettings(KConfig *config) 1928void CalendarView::readFilterSettings(KConfig *config)
1929{ 1929{
1930 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1930 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1931 1931
1932 mFilters.clear(); 1932 mFilters.clear();
1933 1933
1934 config->setGroup("General"); 1934 config->setGroup("General");
1935 QStringList filterList = config->readListEntry("CalendarFilters"); 1935 QStringList filterList = config->readListEntry("CalendarFilters");
1936 1936
1937 QStringList::ConstIterator it = filterList.begin(); 1937 QStringList::ConstIterator it = filterList.begin();
1938 QStringList::ConstIterator end = filterList.end(); 1938 QStringList::ConstIterator end = filterList.end();
1939 while(it != end) { 1939 while(it != end) {
1940 // kdDebug() << " filter: " << (*it) << endl; 1940 // kdDebug() << " filter: " << (*it) << endl;
1941 1941
1942 CalFilter *filter; 1942 CalFilter *filter;
1943 filter = new CalFilter(*it); 1943 filter = new CalFilter(*it);
1944 config->setGroup("Filter_" + (*it)); 1944 config->setGroup("Filter_" + (*it));
1945 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1945 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1946 filter->setCriteria(config->readNumEntry("Criteria",0)); 1946 filter->setCriteria(config->readNumEntry("Criteria",0));
1947 filter->setCategoryList(config->readListEntry("CategoryList")); 1947 filter->setCategoryList(config->readListEntry("CategoryList"));
1948 mFilters.append(filter); 1948 mFilters.append(filter);
1949 1949
1950 ++it; 1950 ++it;
1951 } 1951 }
1952 1952
1953 if (mFilters.count() == 0) { 1953 if (mFilters.count() == 0) {
1954 CalFilter *filter = new CalFilter(i18n("Default")); 1954 CalFilter *filter = new CalFilter(i18n("Default"));
1955 mFilters.append(filter); 1955 mFilters.append(filter);
1956 } 1956 }
1957 mFilterView->updateFilters(); 1957 mFilterView->updateFilters();
1958 config->setGroup("FilterView"); 1958 config->setGroup("FilterView");
1959 1959
1960 mFilterView->blockSignals(true); 1960 mFilterView->blockSignals(true);
1961 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1961 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1962 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1962 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1963 mFilterView->blockSignals(false); 1963 mFilterView->blockSignals(false);
1964 // We do it manually to avoid it being done twice by the above calls 1964 // We do it manually to avoid it being done twice by the above calls
1965 updateFilter(); 1965 updateFilter();
1966} 1966}
1967 1967
1968void CalendarView::writeFilterSettings(KConfig *config) 1968void CalendarView::writeFilterSettings(KConfig *config)
1969{ 1969{
1970 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1970 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1971 1971
1972 QStringList filterList; 1972 QStringList filterList;
1973 1973
1974 CalFilter *filter = mFilters.first(); 1974 CalFilter *filter = mFilters.first();
1975 while(filter) { 1975 while(filter) {
1976 // kdDebug() << " fn: " << filter->name() << endl; 1976 // kdDebug() << " fn: " << filter->name() << endl;
1977 filterList << filter->name(); 1977 filterList << filter->name();
1978 config->setGroup("Filter_" + filter->name()); 1978 config->setGroup("Filter_" + filter->name());
1979 config->writeEntry("Criteria",filter->criteria()); 1979 config->writeEntry("Criteria",filter->criteria());
1980 config->writeEntry("CategoryList",filter->categoryList()); 1980 config->writeEntry("CategoryList",filter->categoryList());
1981 filter = mFilters.next(); 1981 filter = mFilters.next();
1982 } 1982 }
1983 config->setGroup("General"); 1983 config->setGroup("General");
1984 config->writeEntry("CalendarFilters",filterList); 1984 config->writeEntry("CalendarFilters",filterList);
1985 1985
1986 config->setGroup("FilterView"); 1986 config->setGroup("FilterView");
1987 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1987 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1988 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1988 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1989} 1989}
1990 1990
1991 1991
1992void CalendarView::goToday() 1992void CalendarView::goToday()
1993{ 1993{
1994 mNavigator->selectToday(); 1994 if ( mViewManager->currentView()->isMonthView() )
1995 mNavigator->selectTodayMonth();
1996 else
1997 mNavigator->selectToday();
1995} 1998}
1996 1999
1997void CalendarView::goNext() 2000void CalendarView::goNext()
1998{ 2001{
1999 mNavigator->selectNext(); 2002 mNavigator->selectNext();
2000} 2003}
2001 2004
2002void CalendarView::goPrevious() 2005void CalendarView::goPrevious()
2003{ 2006{
2004 mNavigator->selectPrevious(); 2007 mNavigator->selectPrevious();
2005} 2008}
2006void CalendarView::goNextMonth() 2009void CalendarView::goNextMonth()
2007{ 2010{
2008 mNavigator->selectNextMonth(); 2011 mNavigator->selectNextMonth();
2009} 2012}
2010 2013
2011void CalendarView::goPreviousMonth() 2014void CalendarView::goPreviousMonth()
2012{ 2015{
2013 mNavigator->selectPreviousMonth(); 2016 mNavigator->selectPreviousMonth();
2014} 2017}
2015void CalendarView::writeLocale() 2018void CalendarView::writeLocale()
2016{ 2019{
2017 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2020 //KPimGlobalPrefs::instance()->setGlobalConfig();
2018#if 0 2021#if 0
2019 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2022 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2020 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2023 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2021 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2024 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2022 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2025 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2023 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2026 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2024 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2027 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2025 dummy = KOPrefs::instance()->mUserDateFormatShort; 2028 dummy = KOPrefs::instance()->mUserDateFormatShort;
2026 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2029 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2027 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2030 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2028 KOPrefs::instance()->mDaylightsavingStart, 2031 KOPrefs::instance()->mDaylightsavingStart,
2029 KOPrefs::instance()->mDaylightsavingEnd ); 2032 KOPrefs::instance()->mDaylightsavingEnd );
2030 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2033 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2031#endif 2034#endif
2032} 2035}
2033void CalendarView::updateConfig() 2036void CalendarView::updateConfig()
2034{ 2037{
2035 writeLocale(); 2038 writeLocale();
2036 if ( KOPrefs::instance()->mUseAppColors ) 2039 if ( KOPrefs::instance()->mUseAppColors )
2037 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2040 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2038 emit configChanged(); 2041 emit configChanged();
2039 mTodoList->updateConfig(); 2042 mTodoList->updateConfig();
2040 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2043 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2041 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2044 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2042 // To make the "fill window" configurations work 2045 // To make the "fill window" configurations work
2043 //mViewManager->raiseCurrentView(); 2046 //mViewManager->raiseCurrentView();
2044} 2047}
2045 2048
2046 2049
2047void CalendarView::eventChanged(Event *event) 2050void CalendarView::eventChanged(Event *event)
2048{ 2051{
2049 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2052 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2050 //updateUnmanagedViews(); 2053 //updateUnmanagedViews();
2051} 2054}
2052 2055
2053void CalendarView::eventAdded(Event *event) 2056void CalendarView::eventAdded(Event *event)
2054{ 2057{
2055 changeEventDisplay(event,KOGlobals::EVENTADDED); 2058 changeEventDisplay(event,KOGlobals::EVENTADDED);
2056} 2059}
2057 2060
2058void CalendarView::eventToBeDeleted(Event *) 2061void CalendarView::eventToBeDeleted(Event *)
2059{ 2062{
2060 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2063 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2061} 2064}
2062 2065
2063void CalendarView::eventDeleted() 2066void CalendarView::eventDeleted()
2064{ 2067{
2065 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2068 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2066} 2069}
2067void CalendarView::changeTodoDisplay(Todo *which, int action) 2070void CalendarView::changeTodoDisplay(Todo *which, int action)
2068{ 2071{
2069 changeIncidenceDisplay((Incidence *)which, action); 2072 changeIncidenceDisplay((Incidence *)which, action);
2070 mDateNavigator->updateView(); //LR 2073 mDateNavigator->updateView(); //LR
2071 //mDialogManager->updateSearchDialog(); 2074 //mDialogManager->updateSearchDialog();
2072 2075
2073 if (which) { 2076 if (which) {
2074 mViewManager->updateWNview(); 2077 mViewManager->updateWNview();
2075 //mTodoList->updateView(); 2078 //mTodoList->updateView();
2076 } 2079 }
2077 2080
2078} 2081}
2079 2082
2080void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2083void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2081{ 2084{
2082 updateUnmanagedViews(); 2085 updateUnmanagedViews();
2083 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2086 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2084 if ( action == KOGlobals::EVENTDELETED ) { //delete 2087 if ( action == KOGlobals::EVENTDELETED ) { //delete
2085 mCalendar->checkAlarmForIncidence( 0, true ); 2088 mCalendar->checkAlarmForIncidence( 0, true );
2086 if ( mEventViewerDialog ) 2089 if ( mEventViewerDialog )
2087 mEventViewerDialog->hide(); 2090 mEventViewerDialog->hide();
2088 } 2091 }
2089 else 2092 else
2090 mCalendar->checkAlarmForIncidence( which , false ); 2093 mCalendar->checkAlarmForIncidence( which , false );
2091} 2094}
2092 2095
2093// most of the changeEventDisplays() right now just call the view's 2096// most of the changeEventDisplays() right now just call the view's
2094// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2097// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2095void CalendarView::changeEventDisplay(Event *which, int action) 2098void CalendarView::changeEventDisplay(Event *which, int action)
2096{ 2099{
2097 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2100 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2098 changeIncidenceDisplay((Incidence *)which, action); 2101 changeIncidenceDisplay((Incidence *)which, action);
2099 mDateNavigator->updateView(); 2102 mDateNavigator->updateView();
2100 //mDialogManager->updateSearchDialog(); 2103 //mDialogManager->updateSearchDialog();
2101 2104
2102 if (which) { 2105 if (which) {
2103 // If there is an event view visible update the display 2106 // If there is an event view visible update the display
2104 mViewManager->currentView()->changeEventDisplay(which,action); 2107 mViewManager->currentView()->changeEventDisplay(which,action);
2105 // TODO: check, if update needed 2108 // TODO: check, if update needed
2106 // if (which->getTodoStatus()) { 2109 // if (which->getTodoStatus()) {
2107 mTodoList->updateView(); 2110 mTodoList->updateView();
2108 // } 2111 // }
2109 } else { 2112 } else {
2110 mViewManager->currentView()->updateView(); 2113 mViewManager->currentView()->updateView();
2111 } 2114 }
2112} 2115}
2113 2116
2114 2117
2115void CalendarView::updateTodoViews() 2118void CalendarView::updateTodoViews()
2116{ 2119{
2117 2120
2118 mTodoList->updateView(); 2121 mTodoList->updateView();
2119 mViewManager->currentView()->updateView(); 2122 mViewManager->currentView()->updateView();
2120 2123
2121} 2124}
2122 2125
2123 2126
2124void CalendarView::updateView(const QDate &start, const QDate &end) 2127void CalendarView::updateView(const QDate &start, const QDate &end)
2125{ 2128{
2126 mTodoList->updateView(); 2129 mTodoList->updateView();
2127 mViewManager->updateView(start, end); 2130 mViewManager->updateView(start, end);
2128 //mDateNavigator->updateView(); 2131 //mDateNavigator->updateView();
2129} 2132}
2130 2133
2131void CalendarView::updateView() 2134void CalendarView::updateView()
2132{ 2135{
2133 DateList tmpList = mNavigator->selectedDates(); 2136 DateList tmpList = mNavigator->selectedDates();
2134 2137
2135 // We assume that the navigator only selects consecutive days. 2138 // We assume that the navigator only selects consecutive days.
2136 updateView( tmpList.first(), tmpList.last() ); 2139 updateView( tmpList.first(), tmpList.last() );
2137} 2140}
2138 2141
2139void CalendarView::updateUnmanagedViews() 2142void CalendarView::updateUnmanagedViews()
2140{ 2143{
2141 mDateNavigator->updateDayMatrix(); 2144 mDateNavigator->updateDayMatrix();
2142} 2145}
2143 2146
2144int CalendarView::msgItemDelete() 2147int CalendarView::msgItemDelete()
2145{ 2148{
2146 return KMessageBox::warningContinueCancel(this, 2149 return KMessageBox::warningContinueCancel(this,
2147 i18n("This item will be\npermanently deleted."), 2150 i18n("This item will be\npermanently deleted."),
2148 i18n("KO/Pi Confirmation"),i18n("Delete")); 2151 i18n("KO/Pi Confirmation"),i18n("Delete"));
2149} 2152}
2150 2153
2151 2154
2152void CalendarView::edit_cut() 2155void CalendarView::edit_cut()
2153{ 2156{
2154 Event *anEvent=0; 2157 Event *anEvent=0;
2155 2158
2156 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2159 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2157 2160
2158 if (mViewManager->currentView()->isEventView()) { 2161 if (mViewManager->currentView()->isEventView()) {
2159 if ( incidence && incidence->type() == "Event" ) { 2162 if ( incidence && incidence->type() == "Event" ) {
2160 anEvent = static_cast<Event *>(incidence); 2163 anEvent = static_cast<Event *>(incidence);
2161 } 2164 }
2162 } 2165 }
2163 2166
2164 if (!anEvent) { 2167 if (!anEvent) {
2165 KNotifyClient::beep(); 2168 KNotifyClient::beep();
2166 return; 2169 return;
2167 } 2170 }
2168 DndFactory factory( mCalendar ); 2171 DndFactory factory( mCalendar );
2169 factory.cutEvent(anEvent); 2172 factory.cutEvent(anEvent);
2170 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2173 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2171} 2174}
2172 2175
2173void CalendarView::edit_copy() 2176void CalendarView::edit_copy()
2174{ 2177{
2175 Event *anEvent=0; 2178 Event *anEvent=0;
2176 2179
2177 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2180 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2178 2181
2179 if (mViewManager->currentView()->isEventView()) { 2182 if (mViewManager->currentView()->isEventView()) {
2180 if ( incidence && incidence->type() == "Event" ) { 2183 if ( incidence && incidence->type() == "Event" ) {
2181 anEvent = static_cast<Event *>(incidence); 2184 anEvent = static_cast<Event *>(incidence);
2182 } 2185 }
2183 } 2186 }
2184 2187
2185 if (!anEvent) { 2188 if (!anEvent) {
2186 KNotifyClient::beep(); 2189 KNotifyClient::beep();
2187 return; 2190 return;
2188 } 2191 }
2189 DndFactory factory( mCalendar ); 2192 DndFactory factory( mCalendar );
2190 factory.copyEvent(anEvent); 2193 factory.copyEvent(anEvent);
2191} 2194}
2192 2195
2193void CalendarView::edit_paste() 2196void CalendarView::edit_paste()
2194{ 2197{
2195 QDate date = mNavigator->selectedDates().first(); 2198 QDate date = mNavigator->selectedDates().first();
2196 2199
2197 DndFactory factory( mCalendar ); 2200 DndFactory factory( mCalendar );
2198 Event *pastedEvent = factory.pasteEvent( date ); 2201 Event *pastedEvent = factory.pasteEvent( date );
2199 2202
2200 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2203 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2201} 2204}
2202 2205
2203void CalendarView::edit_options() 2206void CalendarView::edit_options()
2204{ 2207{
2205 mDialogManager->showOptionsDialog(); 2208 mDialogManager->showOptionsDialog();
2206 //writeSettings(); 2209 //writeSettings();
2207} 2210}
2208 2211
2209void CalendarView::slotSelectPickerDate( QDate d) 2212void CalendarView::slotSelectPickerDate( QDate d)
2210{ 2213{
2211 mDateFrame->hide(); 2214 mDateFrame->hide();
2212 if ( mDatePickerMode == 1 ) { 2215 if ( mDatePickerMode == 1 ) {
2213 mNavigator->slotDaySelect( d ); 2216 mNavigator->slotDaySelect( d );
2214 } else if ( mDatePickerMode == 2 ) { 2217 } else if ( mDatePickerMode == 2 ) {
2215 if ( mMoveIncidence->type() == "Todo" ) { 2218 if ( mMoveIncidence->type() == "Todo" ) {
2216 Todo * to = (Todo *) mMoveIncidence; 2219 Todo * to = (Todo *) mMoveIncidence;
2217 QTime tim; 2220 QTime tim;
2218 if ( to->hasDueDate() ) 2221 if ( to->hasDueDate() )
2219 tim = to->dtDue().time(); 2222 tim = to->dtDue().time();
2220 else { 2223 else {
2221 tim = QTime ( 0,0,0 ); 2224 tim = QTime ( 0,0,0 );
2222 to->setFloats( true ); 2225 to->setFloats( true );
2223 to->setHasDueDate( true ); 2226 to->setHasDueDate( true );
2224 } 2227 }
2225 QDateTime dt ( d,tim ); 2228 QDateTime dt ( d,tim );
2226 to->setDtDue( dt ); 2229 to->setDtDue( dt );
2227 todoChanged( to ); 2230 todoChanged( to );
2228 } else { 2231 } else {
2229 QTime tim = mMoveIncidence->dtStart().time(); 2232 QTime tim = mMoveIncidence->dtStart().time();
2230 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2233 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2231 QDateTime dt ( d,tim ); 2234 QDateTime dt ( d,tim );
2232 mMoveIncidence->setDtStart( dt ); 2235 mMoveIncidence->setDtStart( dt );
2233 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2236 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2234 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2237 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2235 } 2238 }
2236 2239
2237 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2240 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2238 } 2241 }
2239} 2242}
2240 2243
2241void CalendarView::removeCategories() 2244void CalendarView::removeCategories()
2242{ 2245{
2243 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2246 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2244 QStringList catList = KOPrefs::instance()->mCustomCategories; 2247 QStringList catList = KOPrefs::instance()->mCustomCategories;
2245 QStringList catIncList; 2248 QStringList catIncList;
2246 QStringList newCatList; 2249 QStringList newCatList;
2247 Incidence* inc = incList.first(); 2250 Incidence* inc = incList.first();
2248 int i; 2251 int i;
2249 int count = 0; 2252 int count = 0;
2250 while ( inc ) { 2253 while ( inc ) {
2251 newCatList.clear(); 2254 newCatList.clear();
2252 catIncList = inc->categories() ; 2255 catIncList = inc->categories() ;
2253 for( i = 0; i< catIncList.count(); ++i ) { 2256 for( i = 0; i< catIncList.count(); ++i ) {
2254 if ( catList.contains (catIncList[i])) 2257 if ( catList.contains (catIncList[i]))
2255 newCatList.append( catIncList[i] ); 2258 newCatList.append( catIncList[i] );
2256 } 2259 }
2257 newCatList.sort(); 2260 newCatList.sort();
2258 inc->setCategories( newCatList.join(",") ); 2261 inc->setCategories( newCatList.join(",") );
2259 inc = incList.next(); 2262 inc = incList.next();
2260 } 2263 }
2261} 2264}
2262 2265
2263int CalendarView::addCategories() 2266int CalendarView::addCategories()
2264{ 2267{
2265 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2268 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2266 QStringList catList = KOPrefs::instance()->mCustomCategories; 2269 QStringList catList = KOPrefs::instance()->mCustomCategories;
2267 QStringList catIncList; 2270 QStringList catIncList;
2268 Incidence* inc = incList.first(); 2271 Incidence* inc = incList.first();
2269 int i; 2272 int i;
2270 int count = 0; 2273 int count = 0;
2271 while ( inc ) { 2274 while ( inc ) {
2272 catIncList = inc->categories() ; 2275 catIncList = inc->categories() ;
2273 for( i = 0; i< catIncList.count(); ++i ) { 2276 for( i = 0; i< catIncList.count(); ++i ) {
2274 if ( !catList.contains (catIncList[i])) { 2277 if ( !catList.contains (catIncList[i])) {
2275 catList.append( catIncList[i] ); 2278 catList.append( catIncList[i] );
2276 //qDebug("add cat %s ", catIncList[i].latin1()); 2279 //qDebug("add cat %s ", catIncList[i].latin1());
2277 ++count; 2280 ++count;
2278 } 2281 }
2279 } 2282 }
2280 inc = incList.next(); 2283 inc = incList.next();
2281 } 2284 }
2282 catList.sort(); 2285 catList.sort();
2283 KOPrefs::instance()->mCustomCategories = catList; 2286 KOPrefs::instance()->mCustomCategories = catList;
2284 return count; 2287 return count;
2285} 2288}
2286 2289
2287void CalendarView::manageCategories() 2290void CalendarView::manageCategories()
2288{ 2291{
2289 KOCatPrefs* cp = new KOCatPrefs(); 2292 KOCatPrefs* cp = new KOCatPrefs();
2290 cp->show(); 2293 cp->show();
2291 int w =cp->sizeHint().width() ; 2294 int w =cp->sizeHint().width() ;
2292 int h = cp->sizeHint().height() ; 2295 int h = cp->sizeHint().height() ;
2293 int dw = QApplication::desktop()->width(); 2296 int dw = QApplication::desktop()->width();
2294 int dh = QApplication::desktop()->height(); 2297 int dh = QApplication::desktop()->height();
2295 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2298 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2296 if ( !cp->exec() ) { 2299 if ( !cp->exec() ) {
2297 delete cp; 2300 delete cp;
2298 return; 2301 return;
2299 } 2302 }
2300 int count = 0; 2303 int count = 0;
2301 if ( cp->addCat() ) { 2304 if ( cp->addCat() ) {
2302 count = addCategories(); 2305 count = addCategories();
2303 if ( count ) { 2306 if ( count ) {
2304 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2307 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2305 writeSettings(); 2308 writeSettings();
2306 } else 2309 } else
2307 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2310 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2308 } else { 2311 } else {
2309 removeCategories(); 2312 removeCategories();
2310 updateView(); 2313 updateView();
2311 } 2314 }
2312 delete cp; 2315 delete cp;
2313} 2316}
2314 2317
2315void CalendarView::beamIncidence(Incidence * Inc) 2318void CalendarView::beamIncidence(Incidence * Inc)
2316{ 2319{
2317 QPtrList<Incidence> delSel ; 2320 QPtrList<Incidence> delSel ;
2318 delSel.append(Inc); 2321 delSel.append(Inc);
2319 beamIncidenceList( delSel ); 2322 beamIncidenceList( delSel );
2320} 2323}
2321void CalendarView::beamCalendar() 2324void CalendarView::beamCalendar()
2322{ 2325{
2323 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2326 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2324 //qDebug("beamCalendar() "); 2327 //qDebug("beamCalendar() ");
2325 beamIncidenceList( delSel ); 2328 beamIncidenceList( delSel );
2326} 2329}
2327void CalendarView::beamFilteredCalendar() 2330void CalendarView::beamFilteredCalendar()
2328{ 2331{
2329 QPtrList<Incidence> delSel = mCalendar->incidences(); 2332 QPtrList<Incidence> delSel = mCalendar->incidences();
2330 //qDebug("beamFilteredCalendar() "); 2333 //qDebug("beamFilteredCalendar() ");
2331 beamIncidenceList( delSel ); 2334 beamIncidenceList( delSel );
2332} 2335}
2333void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2336void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2334{ 2337{
2335 if ( beamDialog->exec () == QDialog::Rejected ) 2338 if ( beamDialog->exec () == QDialog::Rejected )
2336 return; 2339 return;
2337#ifdef DESKTOP_VERSION 2340#ifdef DESKTOP_VERSION
2338 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2341 QString fn = locateLocal( "tmp", "kopibeamfile" );
2339#else 2342#else
2340 QString fn = "/tmp/kopibeamfile"; 2343 QString fn = "/tmp/kopibeamfile";
2341#endif 2344#endif
2342 QString mes; 2345 QString mes;
2343 bool createbup = true; 2346 bool createbup = true;
2344 if ( createbup ) { 2347 if ( createbup ) {
2345 QString description = "\n"; 2348 QString description = "\n";
2346 CalendarLocal* cal = new CalendarLocal(); 2349 CalendarLocal* cal = new CalendarLocal();
2347 if ( beamDialog->beamLocal() ) 2350 if ( beamDialog->beamLocal() )
2348 cal->setLocalTime(); 2351 cal->setLocalTime();
2349 else 2352 else
2350 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2353 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2351 Incidence *incidence = delSel.first(); 2354 Incidence *incidence = delSel.first();
2352 bool addText = false; 2355 bool addText = false;
2353 if ( delSel.count() < 10 ) 2356 if ( delSel.count() < 10 )
2354 addText = true; 2357 addText = true;
2355 else { 2358 else {
2356 description.sprintf(i18n(" %d items?"),delSel.count() ); 2359 description.sprintf(i18n(" %d items?"),delSel.count() );
2357 } 2360 }
2358 while ( incidence ) { 2361 while ( incidence ) {
2359 Incidence *in = incidence->clone(); 2362 Incidence *in = incidence->clone();
2360 if ( ! in->summary().isEmpty() ) { 2363 if ( ! in->summary().isEmpty() ) {
2361 in->setDescription(""); 2364 in->setDescription("");
2362 } else { 2365 } else {
2363 in->setSummary( in->description().left(20)); 2366 in->setSummary( in->description().left(20));
2364 in->setDescription(""); 2367 in->setDescription("");
2365 } 2368 }
2366 if ( addText ) 2369 if ( addText )
2367 description += in->summary() + "\n"; 2370 description += in->summary() + "\n";
2368 cal->addIncidence( in ); 2371 cal->addIncidence( in );
2369 incidence = delSel.next(); 2372 incidence = delSel.next();
2370 } 2373 }
2371 if ( beamDialog->beamVcal() ) { 2374 if ( beamDialog->beamVcal() ) {
2372 fn += ".vcs"; 2375 fn += ".vcs";
2373 FileStorage storage( cal, fn, new VCalFormat ); 2376 FileStorage storage( cal, fn, new VCalFormat );
2374 storage.save(); 2377 storage.save();
2375 } else { 2378 } else {
2376 fn += ".ics"; 2379 fn += ".ics";
2377 FileStorage storage( cal, fn, new ICalFormat( ) ); 2380 FileStorage storage( cal, fn, new ICalFormat( ) );
2378 storage.save(); 2381 storage.save();
2379 } 2382 }
2380 delete cal; 2383 delete cal;
2381 mes = i18n("KO/Pi: Ready for beaming"); 2384 mes = i18n("KO/Pi: Ready for beaming");
2382 topLevelWidget()->setCaption(mes); 2385 topLevelWidget()->setCaption(mes);
2383 KApplication::convert2latin1( fn ); 2386 KApplication::convert2latin1( fn );
2384#ifndef DESKTOP_VERSION 2387#ifndef DESKTOP_VERSION
2385 Ir *ir = new Ir( this ); 2388 Ir *ir = new Ir( this );
2386 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2389 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2387 ir->send( fn, description, "text/x-vCalendar" ); 2390 ir->send( fn, description, "text/x-vCalendar" );
2388#endif 2391#endif
2389 } 2392 }
2390} 2393}
2391void CalendarView::beamDone( Ir *ir ) 2394void CalendarView::beamDone( Ir *ir )
2392{ 2395{
2393#ifndef DESKTOP_VERSION 2396#ifndef DESKTOP_VERSION
2394 delete ir; 2397 delete ir;
2395#endif 2398#endif
2396 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2399 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2397 topLevelWidget()->raise(); 2400 topLevelWidget()->raise();
2398} 2401}
2399 2402
2400void CalendarView::moveIncidence(Incidence * inc ) 2403void CalendarView::moveIncidence(Incidence * inc )
2401{ 2404{
2402 if ( !inc ) return; 2405 if ( !inc ) return;
2403 // qDebug("showDatePickerForIncidence( ) "); 2406 // qDebug("showDatePickerForIncidence( ) ");
2404 if ( mDateFrame->isVisible() ) 2407 if ( mDateFrame->isVisible() )
2405 mDateFrame->hide(); 2408 mDateFrame->hide();
2406 else { 2409 else {
2407 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2410 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2408 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2411 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2409 int dw = QApplication::desktop()->width(); 2412 int dw = QApplication::desktop()->width();
2410 int dh = QApplication::desktop()->height(); 2413 int dh = QApplication::desktop()->height();
2411 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2414 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2412 mDateFrame->show(); 2415 mDateFrame->show();
2413 } 2416 }
2414 mDatePickerMode = 2; 2417 mDatePickerMode = 2;
2415 mMoveIncidence = inc ; 2418 mMoveIncidence = inc ;
2416 QDate da; 2419 QDate da;
2417 if ( mMoveIncidence->type() == "Todo" ) { 2420 if ( mMoveIncidence->type() == "Todo" ) {
2418 Todo * to = (Todo *) mMoveIncidence; 2421 Todo * to = (Todo *) mMoveIncidence;
2419 if ( to->hasDueDate() ) 2422 if ( to->hasDueDate() )
2420 da = to->dtDue().date(); 2423 da = to->dtDue().date();
2421 else 2424 else
2422 da = QDate::currentDate(); 2425 da = QDate::currentDate();
2423 } else { 2426 } else {
2424 da = mMoveIncidence->dtStart().date(); 2427 da = mMoveIncidence->dtStart().date();
2425 } 2428 }
2426 mDatePicker->setDate( da ); 2429 mDatePicker->setDate( da );
2427} 2430}
2428void CalendarView::showDatePicker( ) 2431void CalendarView::showDatePicker( )
2429{ 2432{
2430 //qDebug("CalendarView::showDatePicker( ) "); 2433 //qDebug("CalendarView::showDatePicker( ) ");
2431 if ( mDateFrame->isVisible() ) 2434 if ( mDateFrame->isVisible() )
2432 mDateFrame->hide(); 2435 mDateFrame->hide();
2433 else { 2436 else {
2434 int w =mDatePicker->sizeHint().width() ; 2437 int w =mDatePicker->sizeHint().width() ;
2435 int h = mDatePicker->sizeHint().height() ; 2438 int h = mDatePicker->sizeHint().height() ;
2436 int dw = QApplication::desktop()->width(); 2439 int dw = QApplication::desktop()->width();
2437 int dh = QApplication::desktop()->height(); 2440 int dh = QApplication::desktop()->height();
2438 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2441 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2439 mDateFrame->show(); 2442 mDateFrame->show();
2440 } 2443 }
2441 mDatePickerMode = 1; 2444 mDatePickerMode = 1;
2442 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2445 mDatePicker->setDate( mNavigator->selectedDates().first() );
2443} 2446}
2444 2447
2445void CalendarView::showEventEditor() 2448void CalendarView::showEventEditor()
2446{ 2449{
2447#ifdef DESKTOP_VERSION 2450#ifdef DESKTOP_VERSION
2448 mEventEditor->show(); 2451 mEventEditor->show();
2449#else 2452#else
2450 if ( mEventEditor->width() != QApplication::desktop()->width() ) 2453 if ( mEventEditor->width() != QApplication::desktop()->width() )
2451 mEventEditor->hide(); 2454 mEventEditor->hide();
2452 mEventEditor->showMaximized(); 2455 mEventEditor->showMaximized();
2453#endif 2456#endif
2454} 2457}
2455void CalendarView::showTodoEditor() 2458void CalendarView::showTodoEditor()
2456{ 2459{
2457#ifdef DESKTOP_VERSION 2460#ifdef DESKTOP_VERSION
2458 mTodoEditor->show(); 2461 mTodoEditor->show();
2459#else 2462#else
2460 if ( mTodoEditor->width() != QApplication::desktop()->width() ) 2463 if ( mTodoEditor->width() != QApplication::desktop()->width() )
2461 mTodoEditor->hide(); 2464 mTodoEditor->hide();
2462 mTodoEditor->showMaximized(); 2465 mTodoEditor->showMaximized();
2463#endif 2466#endif
2464} 2467}
2465 2468
2466void CalendarView::cloneIncidence() 2469void CalendarView::cloneIncidence()
2467{ 2470{
2468 Incidence *incidence = currentSelection(); 2471 Incidence *incidence = currentSelection();
2469 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2472 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2470 if ( incidence ) { 2473 if ( incidence ) {
2471 cloneIncidence(incidence); 2474 cloneIncidence(incidence);
2472 } 2475 }
2473} 2476}
2474void CalendarView::moveIncidence() 2477void CalendarView::moveIncidence()
2475{ 2478{
2476 Incidence *incidence = currentSelection(); 2479 Incidence *incidence = currentSelection();
2477 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2480 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2478 if ( incidence ) { 2481 if ( incidence ) {
2479 moveIncidence(incidence); 2482 moveIncidence(incidence);
2480 } 2483 }
2481} 2484}
2482void CalendarView::beamIncidence() 2485void CalendarView::beamIncidence()
2483{ 2486{
2484 Incidence *incidence = currentSelection(); 2487 Incidence *incidence = currentSelection();
2485 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2488 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2486 if ( incidence ) { 2489 if ( incidence ) {
2487 beamIncidence(incidence); 2490 beamIncidence(incidence);
2488 } 2491 }
2489} 2492}
2490void CalendarView::toggleCancelIncidence() 2493void CalendarView::toggleCancelIncidence()
2491{ 2494{
2492 Incidence *incidence = currentSelection(); 2495 Incidence *incidence = currentSelection();
2493 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2496 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2494 if ( incidence ) { 2497 if ( incidence ) {
2495 cancelIncidence(incidence); 2498 cancelIncidence(incidence);
2496 } 2499 }
2497} 2500}
2498 2501
2499 2502
2500void CalendarView::cancelIncidence(Incidence * inc ) 2503void CalendarView::cancelIncidence(Incidence * inc )
2501{ 2504{
2502 inc->setCancelled( ! inc->cancelled() ); 2505 inc->setCancelled( ! inc->cancelled() );
2503 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2506 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2504 updateView(); 2507 updateView();
2505} 2508}
2506void CalendarView::cloneIncidence(Incidence * orgInc ) 2509void CalendarView::cloneIncidence(Incidence * orgInc )
2507{ 2510{
2508 Incidence * newInc = orgInc->clone(); 2511 Incidence * newInc = orgInc->clone();
2509 newInc->recreate(); 2512 newInc->recreate();
2510 2513
2511 if ( newInc->type() == "Todo" ) { 2514 if ( newInc->type() == "Todo" ) {
2512 Todo* t = (Todo*) newInc; 2515 Todo* t = (Todo*) newInc;
2513 mTodoEditor->editTodo( t ); 2516 mTodoEditor->editTodo( t );
2514 showTodoEditor(); 2517 showTodoEditor();
2515 if ( mTodoEditor->exec() ) { 2518 if ( mTodoEditor->exec() ) {
2516 mCalendar->addTodo( t ); 2519 mCalendar->addTodo( t );
2517 updateView(); 2520 updateView();
2518 } else { 2521 } else {
2519 delete t; 2522 delete t;
2520 } 2523 }
2521 } 2524 }
2522 else { 2525 else {
2523 Event* e = (Event*) newInc; 2526 Event* e = (Event*) newInc;
2524 mEventEditor->editEvent( e ); 2527 mEventEditor->editEvent( e );
2525 showEventEditor(); 2528 showEventEditor();
2526 if ( mEventEditor->exec() ) { 2529 if ( mEventEditor->exec() ) {
2527 mCalendar->addEvent( e ); 2530 mCalendar->addEvent( e );
2528 updateView(); 2531 updateView();
2529 } else { 2532 } else {
2530 delete e; 2533 delete e;
2531 } 2534 }
2532 } 2535 }
2533} 2536}
2534 2537
2535void CalendarView::newEvent() 2538void CalendarView::newEvent()
2536{ 2539{
2537 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2540 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2538 KOAgendaView *aView = mViewManager->agendaView(); 2541 KOAgendaView *aView = mViewManager->agendaView();
2539 if (aView) { 2542 if (aView) {
2540 if (aView->selectionStart().isValid()) { 2543 if (aView->selectionStart().isValid()) {
2541 if (aView->selectedIsAllDay()) { 2544 if (aView->selectedIsAllDay()) {
2542 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2545 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2543 } else { 2546 } else {
2544 newEvent(aView->selectionStart(),aView->selectionEnd()); 2547 newEvent(aView->selectionStart(),aView->selectionEnd());
2545 } 2548 }
2546 return; 2549 return;
2547 } 2550 }
2548 } 2551 }
2549 2552
2550 QDate date = mNavigator->selectedDates().first(); 2553 QDate date = mNavigator->selectedDates().first();
2551 QDateTime current = QDateTime::currentDateTime(); 2554 QDateTime current = QDateTime::currentDateTime();
2552 if ( date <= current.date() ) { 2555 if ( date <= current.date() ) {
2553 int hour = current.time().hour() +1; 2556 int hour = current.time().hour() +1;
2554 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2557 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2555 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2558 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2556 } else 2559 } else
2557 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2560 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2558 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2561 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2559 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2562 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2560} 2563}
2561 2564
2562void CalendarView::newEvent(QDateTime fh) 2565void CalendarView::newEvent(QDateTime fh)
2563{ 2566{
2564 newEvent(fh, 2567 newEvent(fh,
2565 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2568 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2566} 2569}
2567 2570
2568void CalendarView::newEvent(QDate dt) 2571void CalendarView::newEvent(QDate dt)
2569{ 2572{
2570 newEvent(QDateTime(dt, QTime(0,0,0)), 2573 newEvent(QDateTime(dt, QTime(0,0,0)),
2571 QDateTime(dt, QTime(0,0,0)), true); 2574 QDateTime(dt, QTime(0,0,0)), true);
2572} 2575}
2573 2576
2574void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2577void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2575{ 2578{
2576 2579
2577 mEventEditor->newEvent(fromHint,toHint,allDay); 2580 mEventEditor->newEvent(fromHint,toHint,allDay);
2578 if ( mFilterView->filtersEnabled() ) { 2581 if ( mFilterView->filtersEnabled() ) {
2579 CalFilter *filter = mFilterView->selectedFilter(); 2582 CalFilter *filter = mFilterView->selectedFilter();
2580 if (filter && filter->showCategories()) { 2583 if (filter && filter->showCategories()) {
2581 mEventEditor->setCategories(filter->categoryList().join(",") ); 2584 mEventEditor->setCategories(filter->categoryList().join(",") );
2582 } 2585 }
2583 if ( filter ) 2586 if ( filter )
2584 mEventEditor->setSecrecy( filter->getSecrecy() ); 2587 mEventEditor->setSecrecy( filter->getSecrecy() );
2585 } 2588 }
2586 showEventEditor(); 2589 showEventEditor();
2587} 2590}
2588void CalendarView::todoAdded(Todo * t) 2591void CalendarView::todoAdded(Todo * t)
2589{ 2592{
2590 2593
2591 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2594 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2592 updateTodoViews(); 2595 updateTodoViews();
2593} 2596}
2594void CalendarView::todoChanged(Todo * t) 2597void CalendarView::todoChanged(Todo * t)
2595{ 2598{
2596 emit todoModified( t, 4 ); 2599 emit todoModified( t, 4 );
2597 // updateTodoViews(); 2600 // updateTodoViews();
2598} 2601}
2599void CalendarView::todoToBeDeleted(Todo *) 2602void CalendarView::todoToBeDeleted(Todo *)
2600{ 2603{
2601 //qDebug("todoToBeDeleted(Todo *) "); 2604 //qDebug("todoToBeDeleted(Todo *) ");
2602 updateTodoViews(); 2605 updateTodoViews();
2603} 2606}
2604void CalendarView::todoDeleted() 2607void CalendarView::todoDeleted()
2605{ 2608{
2606 //qDebug(" todoDeleted()"); 2609 //qDebug(" todoDeleted()");
2607 updateTodoViews(); 2610 updateTodoViews();
2608} 2611}
2609 2612
2610 2613
2611 2614
2612void CalendarView::newTodo() 2615void CalendarView::newTodo()
2613{ 2616{
2614 2617
2615 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2618 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2616 if ( mFilterView->filtersEnabled() ) { 2619 if ( mFilterView->filtersEnabled() ) {
2617 CalFilter *filter = mFilterView->selectedFilter(); 2620 CalFilter *filter = mFilterView->selectedFilter();
2618 if (filter && filter->showCategories()) { 2621 if (filter && filter->showCategories()) {
2619 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2622 mTodoEditor->setCategories(filter->categoryList().join(",") );
2620 } 2623 }
2621 if ( filter ) 2624 if ( filter )
2622 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2625 mTodoEditor->setSecrecy( filter->getSecrecy() );
2623 } 2626 }
2624 showTodoEditor(); 2627 showTodoEditor();
2625} 2628}
2626 2629
2627void CalendarView::newSubTodo() 2630void CalendarView::newSubTodo()
2628{ 2631{
2629 Todo *todo = selectedTodo(); 2632 Todo *todo = selectedTodo();
2630 if ( todo ) newSubTodo( todo ); 2633 if ( todo ) newSubTodo( todo );
2631} 2634}
2632 2635
2633void CalendarView::newSubTodo(Todo *parentEvent) 2636void CalendarView::newSubTodo(Todo *parentEvent)
2634{ 2637{
2635 2638
2636 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2639 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2637 showTodoEditor(); 2640 showTodoEditor();
2638} 2641}
2639 2642
2640void CalendarView::newFloatingEvent() 2643void CalendarView::newFloatingEvent()
2641{ 2644{
2642 DateList tmpList = mNavigator->selectedDates(); 2645 DateList tmpList = mNavigator->selectedDates();
2643 QDate date = tmpList.first(); 2646 QDate date = tmpList.first();
2644 2647
2645 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2648 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2646 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2649 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2647} 2650}
2648 2651
2649 2652
2650void CalendarView::editEvent( Event *event ) 2653void CalendarView::editEvent( Event *event )
2651{ 2654{
2652 2655
2653 if ( !event ) return; 2656 if ( !event ) return;
2654 if ( event->isReadOnly() ) { 2657 if ( event->isReadOnly() ) {
2655 showEvent( event ); 2658 showEvent( event );
2656 return; 2659 return;
2657 } 2660 }
2658 mEventEditor->editEvent( event , mFlagEditDescription); 2661 mEventEditor->editEvent( event , mFlagEditDescription);
2659 showEventEditor(); 2662 showEventEditor();
2660} 2663}
2661void CalendarView::editJournal( Journal *jour ) 2664void CalendarView::editJournal( Journal *jour )
2662{ 2665{
2663 if ( !jour ) return; 2666 if ( !jour ) return;
2664 mDialogManager->hideSearchDialog(); 2667 mDialogManager->hideSearchDialog();
2665 mViewManager->showJournalView(); 2668 mViewManager->showJournalView();
2666 mNavigator->slotDaySelect( jour->dtStart().date() ); 2669 mNavigator->slotDaySelect( jour->dtStart().date() );
2667} 2670}
2668void CalendarView::editTodo( Todo *todo ) 2671void CalendarView::editTodo( Todo *todo )
2669{ 2672{
2670 if ( !todo ) return; 2673 if ( !todo ) return;
2671 2674
2672 if ( todo->isReadOnly() ) { 2675 if ( todo->isReadOnly() ) {
2673 showTodo( todo ); 2676 showTodo( todo );
2674 return; 2677 return;
2675 } 2678 }
2676 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2679 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2677 showTodoEditor(); 2680 showTodoEditor();
2678 2681
2679} 2682}
2680 2683
2681KOEventViewerDialog* CalendarView::getEventViewerDialog() 2684KOEventViewerDialog* CalendarView::getEventViewerDialog()
2682{ 2685{
2683 if ( !mEventViewerDialog ) { 2686 if ( !mEventViewerDialog ) {
2684 mEventViewerDialog = new KOEventViewerDialog(this); 2687 mEventViewerDialog = new KOEventViewerDialog(this);
2685 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2688 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2686 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2689 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2687 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2690 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2688 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2691 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2689 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2692 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2690 viewManager(), SLOT( showAgendaView( bool ) ) ); 2693 viewManager(), SLOT( showAgendaView( bool ) ) );
2691 mEventViewerDialog->resize( 640, 480 ); 2694 mEventViewerDialog->resize( 640, 480 );
2692 2695
2693 } 2696 }
2694 return mEventViewerDialog; 2697 return mEventViewerDialog;
2695} 2698}
2696void CalendarView::showEvent(Event *event) 2699void CalendarView::showEvent(Event *event)
2697{ 2700{
2698 getEventViewerDialog()->setEvent(event); 2701 getEventViewerDialog()->setEvent(event);
2699 getEventViewerDialog()->showMe(); 2702 getEventViewerDialog()->showMe();
2700} 2703}
2701 2704
2702void CalendarView::showTodo(Todo *event) 2705void CalendarView::showTodo(Todo *event)
2703{ 2706{
2704 getEventViewerDialog()->setTodo(event); 2707 getEventViewerDialog()->setTodo(event);
2705 getEventViewerDialog()->showMe(); 2708 getEventViewerDialog()->showMe();
2706} 2709}
2707void CalendarView::showJournal( Journal *jour ) 2710void CalendarView::showJournal( Journal *jour )
2708{ 2711{
2709 getEventViewerDialog()->setJournal(jour); 2712 getEventViewerDialog()->setJournal(jour);
2710 getEventViewerDialog()->showMe(); 2713 getEventViewerDialog()->showMe();
2711 2714
2712} 2715}
2713// void CalendarView::todoModified (Todo *event, int changed) 2716// void CalendarView::todoModified (Todo *event, int changed)
2714// { 2717// {
2715// // if (mDialogList.find (event) != mDialogList.end ()) { 2718// // if (mDialogList.find (event) != mDialogList.end ()) {
2716// // kdDebug() << "Todo modified and open" << endl; 2719// // kdDebug() << "Todo modified and open" << endl;
2717// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2720// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2718// // temp->modified (changed); 2721// // temp->modified (changed);
2719 2722
2720// // } 2723// // }
2721 2724
2722// mViewManager->updateView(); 2725// mViewManager->updateView();
2723// } 2726// }
2724 2727
2725void CalendarView::appointment_show() 2728void CalendarView::appointment_show()
2726{ 2729{
2727 Event *anEvent = 0; 2730 Event *anEvent = 0;
2728 2731
2729 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2732 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2730 2733
2731 if (mViewManager->currentView()->isEventView()) { 2734 if (mViewManager->currentView()->isEventView()) {
2732 if ( incidence && incidence->type() == "Event" ) { 2735 if ( incidence && incidence->type() == "Event" ) {
2733 anEvent = static_cast<Event *>(incidence); 2736 anEvent = static_cast<Event *>(incidence);
2734 } 2737 }
2735 } 2738 }
2736 2739
2737 if (!anEvent) { 2740 if (!anEvent) {
2738 KNotifyClient::beep(); 2741 KNotifyClient::beep();
2739 return; 2742 return;
2740 } 2743 }
2741 2744
2742 showEvent(anEvent); 2745 showEvent(anEvent);
2743} 2746}
2744 2747
2745void CalendarView::appointment_edit() 2748void CalendarView::appointment_edit()
2746{ 2749{
2747 Event *anEvent = 0; 2750 Event *anEvent = 0;
2748 2751
2749 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2752 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2750 2753
2751 if (mViewManager->currentView()->isEventView()) { 2754 if (mViewManager->currentView()->isEventView()) {
2752 if ( incidence && incidence->type() == "Event" ) { 2755 if ( incidence && incidence->type() == "Event" ) {
2753 anEvent = static_cast<Event *>(incidence); 2756 anEvent = static_cast<Event *>(incidence);
2754 } 2757 }
2755 } 2758 }
2756 2759
2757 if (!anEvent) { 2760 if (!anEvent) {
2758 KNotifyClient::beep(); 2761 KNotifyClient::beep();
2759 return; 2762 return;
2760 } 2763 }
2761 2764
2762 editEvent(anEvent); 2765 editEvent(anEvent);
diff --git a/korganizer/datenavigator.cpp b/korganizer/datenavigator.cpp
index e26e20b..3156b2b 100644
--- a/korganizer/datenavigator.cpp
+++ b/korganizer/datenavigator.cpp
@@ -1,287 +1,293 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 "datenavigator.h" 24#include "datenavigator.h"
25 25
26#include "koglobals.h" 26#include "koglobals.h"
27 27
28#include <kcalendarsystem.h> 28#include <kcalendarsystem.h>
29 29
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34using namespace KCal; 34using namespace KCal;
35 35
36DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v) 36DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v)
37 : QObject( parent, name ) 37 : QObject( parent, name )
38{ 38{
39 mViewManager = v; 39 mViewManager = v;
40 mSelectedDates.append( QDate::currentDate() ); 40 mSelectedDates.append( QDate::currentDate() );
41} 41}
42 42
43DateNavigator::~DateNavigator() 43DateNavigator::~DateNavigator()
44{ 44{
45} 45}
46 46
47void DateNavigator::slotMonthSelect( int m ) 47void DateNavigator::slotMonthSelect( int m )
48{ 48{
49 QDate firstSelected = mSelectedDates.first(); 49 QDate firstSelected = mSelectedDates.first();
50 int weekDay = firstSelected.dayOfWeek(); 50 int weekDay = firstSelected.dayOfWeek();
51 int diff = m - firstSelected.month() ; 51 int diff = m - firstSelected.month() ;
52 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff ); 52 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff );
53 53
54 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) 54 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
55 selectMonthByDate( firstSelected ); 55 selectMonthByDate( firstSelected );
56 else 56 else
57 selectWeekByDay( weekDay, firstSelected ); 57 selectWeekByDay( weekDay, firstSelected );
58 58
59} 59}
60 60
61void DateNavigator::slotDaySelect( QDate d ) 61void DateNavigator::slotDaySelect( QDate d )
62{ 62{
63 QDate firstSelected = mSelectedDates.first(); 63 QDate firstSelected = mSelectedDates.first();
64 int weekDay = firstSelected.dayOfWeek(); 64 int weekDay = firstSelected.dayOfWeek();
65 //int diff = firstSelected.daysTo( d ) ; 65 //int diff = firstSelected.daysTo( d ) ;
66 firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) ); 66 firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) );
67 67
68 selectWeekByDay( weekDay, firstSelected ); 68 selectWeekByDay( weekDay, firstSelected );
69 69
70} 70}
71 71
72void DateNavigator::selectMonthByDate( const QDate & firstSelected ) 72void DateNavigator::selectMonthByDate( const QDate & firstSelected )
73{ 73{
74 74
75 int monthDay = firstSelected.day(); 75 int monthDay = firstSelected.day();
76 QDate date = firstSelected.addDays( 1-monthDay ); 76 QDate date = firstSelected.addDays( 1-monthDay );
77 selectDates( date , date.daysInMonth ()); 77 selectDates( date , date.daysInMonth ());
78 78
79} 79}
80void DateNavigator::selectMonth() 80void DateNavigator::selectMonth()
81{ 81{
82 82
83 QDate date =mSelectedDates.first(); 83 QDate date =mSelectedDates.first();
84 selectMonthByDate( date ); 84 selectMonthByDate( date );
85} 85}
86 86
87DateList DateNavigator::selectedDates() 87DateList DateNavigator::selectedDates()
88{ 88{
89 return mSelectedDates; 89 return mSelectedDates;
90} 90}
91 91
92int DateNavigator::datesCount() const 92int DateNavigator::datesCount() const
93{ 93{
94 return mSelectedDates.count(); 94 return mSelectedDates.count();
95} 95}
96 96
97void DateNavigator::selectDates( const DateList& dateList ) 97void DateNavigator::selectDates( const DateList& dateList )
98{ 98{
99 if (dateList.count() > 0) { 99 if (dateList.count() > 0) {
100 mSelectedDates = dateList; 100 mSelectedDates = dateList;
101 emitSelected(); 101 emitSelected();
102 } 102 }
103} 103}
104 104
105void DateNavigator::selectDate( const QDate &date ) 105void DateNavigator::selectDate( const QDate &date )
106{ 106{
107 QDate d = date; 107 QDate d = date;
108 108
109 if ( !d.isValid() ) { 109 if ( !d.isValid() ) {
110 d = QDate::currentDate(); 110 d = QDate::currentDate();
111 } 111 }
112 112
113 mSelectedDates.clear(); 113 mSelectedDates.clear();
114 mSelectedDates.append( d ); 114 mSelectedDates.append( d );
115 115
116 emitSelected(); 116 emitSelected();
117} 117}
118 118
119void DateNavigator::selectDates( int count ) 119void DateNavigator::selectDates( int count )
120{ 120{
121 121
122 QDate d = mSelectedDates.first(); 122 QDate d = mSelectedDates.first();
123 selectDates( d, count ); 123 selectDates( d, count );
124} 124}
125 125
126void DateNavigator::selectDates( const QDate &d, int count ) 126void DateNavigator::selectDates( const QDate &d, int count )
127{ 127{
128 DateList dates; 128 DateList dates;
129 129
130 int i; 130 int i;
131 for( i = 0; i < count; ++i ) { 131 for( i = 0; i < count; ++i ) {
132 dates.append( d.addDays( i ) ); 132 dates.append( d.addDays( i ) );
133 } 133 }
134 134
135 mSelectedDates = dates; 135 mSelectedDates = dates;
136 136
137 emitSelected(); 137 emitSelected();
138} 138}
139 139
140void DateNavigator::selectWeekByDay( int weekDay, const QDate &d ) 140void DateNavigator::selectWeekByDay( int weekDay, const QDate &d )
141{ 141{
142 // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1()); 142 // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1());
143 int dateCount = mSelectedDates.count(); 143 int dateCount = mSelectedDates.count();
144 bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() ); 144 bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() );
145 if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d ); 145 if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d );
146 else if ( weekStart && dateCount == 7 ) selectWeek( d ); 146 else if ( weekStart && dateCount == 7 ) selectWeek( d );
147 else selectDates( d, dateCount ); 147 else selectDates( d, dateCount );
148} 148}
149 149
150void DateNavigator::selectWeek() 150void DateNavigator::selectWeek()
151{ 151{
152 QDate d = mSelectedDates.first(); 152 QDate d = mSelectedDates.first();
153 selectWeek( d ); 153 selectWeek( d );
154} 154}
155void DateNavigator::selectWeek( int num ) 155void DateNavigator::selectWeek( int num )
156{ 156{
157 int year = mSelectedDates.first().year(); 157 int year = mSelectedDates.first().year();
158 if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 ) 158 if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 )
159 ++year; 159 ++year;
160 if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 ) 160 if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 )
161 --year; 161 --year;
162 QDate d = QDate ( year, 1,1); 162 QDate d = QDate ( year, 1,1);
163 while ( d.dayOfWeek() != 4 ) 163 while ( d.dayOfWeek() != 4 )
164 d = d.addDays( 1 ); 164 d = d.addDays( 1 );
165 selectWeek( d.addDays ( (num-1) *7 ) ); 165 selectWeek( d.addDays ( (num-1) *7 ) );
166} 166}
167void DateNavigator::selectWeek( const QDate &d ) 167void DateNavigator::selectWeek( const QDate &d )
168{ 168{
169 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); 169 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
170 170
171 int weekStart = KGlobal::locale()->weekStartDay(); 171 int weekStart = KGlobal::locale()->weekStartDay();
172 QDate firstDate = d.addDays( weekStart - dayOfWeek ); 172 QDate firstDate = d.addDays( weekStart - dayOfWeek );
173 173
174 if ( weekStart != 1 && dayOfWeek < weekStart ) { 174 if ( weekStart != 1 && dayOfWeek < weekStart ) {
175 firstDate = firstDate.addDays(-7 ); 175 firstDate = firstDate.addDays(-7 );
176 } 176 }
177 177
178 178
179 selectDates( firstDate, 7 ); 179 selectDates( firstDate, 7 );
180} 180}
181 181
182void DateNavigator::selectWorkWeek() 182void DateNavigator::selectWorkWeek()
183{ 183{
184 QDate d = mSelectedDates.first(); 184 QDate d = mSelectedDates.first();
185 selectWorkWeek( d ); 185 selectWorkWeek( d );
186} 186}
187 187
188void DateNavigator::selectWorkWeek( const QDate &d ) 188void DateNavigator::selectWorkWeek( const QDate &d )
189{ 189{
190 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); 190 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
191 191
192 QDate firstDate = d.addDays( 1 - dayOfWeek ); 192 QDate firstDate = d.addDays( 1 - dayOfWeek );
193 193
194 int weekStart = KGlobal::locale()->weekStartDay(); 194 int weekStart = KGlobal::locale()->weekStartDay();
195 if ( weekStart != 1 && dayOfWeek >= weekStart ) { 195 if ( weekStart != 1 && dayOfWeek >= weekStart ) {
196 firstDate = firstDate.addDays( 7 ); 196 firstDate = firstDate.addDays( 7 );
197 } 197 }
198 198
199 selectDates( firstDate, 5 ); 199 selectDates( firstDate, 5 );
200} 200}
201 201
202void DateNavigator::selectTodayMonth()
203{
204 QDate date = QDate::currentDate().addDays( 1-QDate::currentDate().day() );
205 selectDates( date , date.daysInMonth ());
206
207}
202void DateNavigator::selectToday() 208void DateNavigator::selectToday()
203{ 209{
204 QDate d = QDate::currentDate(); 210 QDate d = QDate::currentDate();
205 211
206 int dateCount = mSelectedDates.count(); 212 int dateCount = mSelectedDates.count();
207 213
208 if ( dateCount == 5 ) selectWorkWeek( d ); 214 if ( dateCount == 5 ) selectWorkWeek( d );
209 else if ( dateCount == 7 ) selectWeek( d ); 215 else if ( dateCount == 7 ) selectWeek( d );
210 else selectDates( d, dateCount ); 216 else selectDates( d, dateCount );
211} 217}
212 218
213void DateNavigator::selectPreviousYear() 219void DateNavigator::selectPreviousYear()
214{ 220{
215 QDate firstSelected = mSelectedDates.first(); 221 QDate firstSelected = mSelectedDates.first();
216 int weekDay = firstSelected.dayOfWeek(); 222 int weekDay = firstSelected.dayOfWeek();
217 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 ); 223 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 );
218 224
219 selectWeekByDay( weekDay, firstSelected ); 225 selectWeekByDay( weekDay, firstSelected );
220} 226}
221 227
222void DateNavigator::selectPreviousMonth() 228void DateNavigator::selectPreviousMonth()
223{ 229{
224 QDate firstSelected = mSelectedDates.first(); 230 QDate firstSelected = mSelectedDates.first();
225 int weekDay = firstSelected.dayOfWeek(); 231 int weekDay = firstSelected.dayOfWeek();
226 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 ); 232 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 );
227 233
228 234
229 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) 235 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
230 selectMonthByDate( firstSelected ); 236 selectMonthByDate( firstSelected );
231 else 237 else
232 selectWeekByDay( weekDay, firstSelected ); 238 selectWeekByDay( weekDay, firstSelected );
233} 239}
234 240
235void DateNavigator::selectNextMonth() 241void DateNavigator::selectNextMonth()
236{ 242{
237 QDate firstSelected = mSelectedDates.first(); 243 QDate firstSelected = mSelectedDates.first();
238 int weekDay = firstSelected.dayOfWeek(); 244 int weekDay = firstSelected.dayOfWeek();
239 245
240 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 ); 246 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 );
241 247
242 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) 248 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
243 selectMonthByDate( firstSelected ); 249 selectMonthByDate( firstSelected );
244 else 250 else
245 selectWeekByDay( weekDay, firstSelected ); 251 selectWeekByDay( weekDay, firstSelected );
246 252
247} 253}
248 254
249void DateNavigator::selectNextYear() 255void DateNavigator::selectNextYear()
250{ 256{
251 QDate firstSelected = mSelectedDates.first(); 257 QDate firstSelected = mSelectedDates.first();
252 int weekDay = firstSelected.dayOfWeek(); 258 int weekDay = firstSelected.dayOfWeek();
253 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 ); 259 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 );
254 260
255 selectWeekByDay( weekDay, firstSelected ); 261 selectWeekByDay( weekDay, firstSelected );
256} 262}
257 263
258void DateNavigator::selectPrevious() 264void DateNavigator::selectPrevious()
259{ 265{
260 int offset = -7; 266 int offset = -7;
261 if ( datesCount() == 1 ) { 267 if ( datesCount() == 1 ) {
262 offset = -1; 268 offset = -1;
263 } 269 }
264 if ( mViewManager ) 270 if ( mViewManager )
265 if ( mViewManager->showsNextDays() ) 271 if ( mViewManager->showsNextDays() )
266 offset = -datesCount(); 272 offset = -datesCount();
267 selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); 273 selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
268} 274}
269 275
270void DateNavigator::selectNext() 276void DateNavigator::selectNext()
271{ 277{
272 int offset = 7; 278 int offset = 7;
273 if ( datesCount() == 1 ) { 279 if ( datesCount() == 1 ) {
274 offset = 1; 280 offset = 1;
275 } 281 }
276 if ( mViewManager ) 282 if ( mViewManager )
277 if ( mViewManager->showsNextDays() ) 283 if ( mViewManager->showsNextDays() )
278 offset = datesCount(); 284 offset = datesCount();
279 selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); 285 selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
280} 286}
281 287
282void DateNavigator::emitSelected() 288void DateNavigator::emitSelected()
283{ 289{
284 emit datesSelected( mSelectedDates ); 290 emit datesSelected( mSelectedDates );
285} 291}
286 292
287//#include "datenavigator.moc" 293//#include "datenavigator.moc"
diff --git a/korganizer/datenavigator.h b/korganizer/datenavigator.h
index 747e3d3..4a19e17 100644
--- a/korganizer/datenavigator.h
+++ b/korganizer/datenavigator.h
@@ -1,89 +1,90 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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#ifndef DATENAVIGATOR_H 23#ifndef DATENAVIGATOR_H
24#define DATENAVIGATOR_H 24#define DATENAVIGATOR_H
25 25
26#include <libkcal/incidencebase.h> 26#include <libkcal/incidencebase.h>
27 27
28#include <qobject.h> 28#include <qobject.h>
29#include "koviewmanager.h" 29#include "koviewmanager.h"
30 30
31/** 31/**
32 This class controls date navigation. All requests to move the views to another 32 This class controls date navigation. All requests to move the views to another
33 date are sent to the DateNavigator. The DateNavigator processes the new 33 date are sent to the DateNavigator. The DateNavigator processes the new
34 selection of dates and emits the required signals for the views. 34 selection of dates and emits the required signals for the views.
35*/ 35*/
36class DateNavigator : public QObject 36class DateNavigator : public QObject
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 public: 39 public:
40 DateNavigator( QObject *parent = 0, const char *name = 0 , KOViewManager * v = 0); 40 DateNavigator( QObject *parent = 0, const char *name = 0 , KOViewManager * v = 0);
41 ~DateNavigator(); 41 ~DateNavigator();
42 42
43 KCal::DateList selectedDates(); 43 KCal::DateList selectedDates();
44 44
45 int datesCount() const; 45 int datesCount() const;
46 46
47 public slots: 47 public slots:
48 void selectDates( const KCal::DateList & ); 48 void selectDates( const KCal::DateList & );
49 void selectDate( const QDate & ); 49 void selectDate( const QDate & );
50 50
51 void selectDates( int count ); 51 void selectDates( int count );
52 void selectDates( const QDate &, int count ); 52 void selectDates( const QDate &, int count );
53 53
54 void selectWeek(); 54 void selectWeek();
55 void selectWeek( int weeknum ); 55 void selectWeek( int weeknum );
56 void selectWeek( const QDate & ); 56 void selectWeek( const QDate & );
57 57
58 void selectWorkWeek(); 58 void selectWorkWeek();
59 void selectWorkWeek( const QDate & ); 59 void selectWorkWeek( const QDate & );
60 60
61 void selectWeekByDay( int weekDay, const QDate & ); 61 void selectWeekByDay( int weekDay, const QDate & );
62 62
63 void selectToday(); 63 void selectToday();
64 void selectTodayMonth();
64 65
65 void selectPreviousYear(); 66 void selectPreviousYear();
66 void selectPreviousMonth(); 67 void selectPreviousMonth();
67 void selectNextMonth(); 68 void selectNextMonth();
68 void selectNextYear(); 69 void selectNextYear();
69 70
70 void selectMonth(); 71 void selectMonth();
71 void selectMonthByDate( const QDate & ); 72 void selectMonthByDate( const QDate & );
72 73
73 void selectPrevious(); 74 void selectPrevious();
74 void selectNext(); 75 void selectNext();
75 void slotMonthSelect( int ); 76 void slotMonthSelect( int );
76 void slotDaySelect( QDate d ); 77 void slotDaySelect( QDate d );
77 78
78 signals: 79 signals:
79 void datesSelected( const KCal::DateList & ); 80 void datesSelected( const KCal::DateList & );
80 81
81 protected: 82 protected:
82 void emitSelected(); 83 void emitSelected();
83 84
84 private: 85 private:
85 KOViewManager * mViewManager; 86 KOViewManager * mViewManager;
86 KCal::DateList mSelectedDates; 87 KCal::DateList mSelectedDates;
87}; 88};
88 89
89#endif 90#endif
diff --git a/korganizer/interfaces/korganizer/baseview.h b/korganizer/interfaces/korganizer/baseview.h
index 09f8ba3..2ac9de1 100644
--- a/korganizer/interfaces/korganizer/baseview.h
+++ b/korganizer/interfaces/korganizer/baseview.h
@@ -1,192 +1,193 @@
1/* 1/*
2 This file is part of the KOrganizer interfaces. 2 This file is part of the KOrganizer interfaces.
3 Copyright (c) 1999 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 1999 Cornelius Schumacher <schumacher@kde.org>
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef KORG_BASEVIEW_H 21#ifndef KORG_BASEVIEW_H
22#define KORG_BASEVIEW_H 22#define KORG_BASEVIEW_H
23// $Id$ 23// $Id$
24// KOBaseView is the abstract base class of all calendar views. 24// KOBaseView is the abstract base class of all calendar views.
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30#include <klocale.h> 30#include <klocale.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34#include <libkcal/event.h> 34#include <libkcal/event.h>
35#include <libkcal/calendar.h> 35#include <libkcal/calendar.h>
36 36
37using namespace KCal; 37using namespace KCal;
38 38
39class CalPrinter; 39class CalPrinter;
40 40
41namespace KOrg { 41namespace KOrg {
42 42
43class CalPrinterBase 43class CalPrinterBase
44{ 44{
45 public: 45 public:
46 enum PrintType { Day, Week, Month, Todolist }; 46 enum PrintType { Day, Week, Month, Todolist };
47}; 47};
48 48
49 49
50/** 50/**
51 This class provides an interface for all views being displayed within the main 51 This class provides an interface for all views being displayed within the main
52 calendar view. It has functions to update the view, to specify date range and 52 calendar view. It has functions to update the view, to specify date range and
53 other display parameter and to return selected objects. An important class, 53 other display parameter and to return selected objects. An important class,
54 which inherits KOBaseView is KOEventView, which provides the interface for all 54 which inherits KOBaseView is KOEventView, which provides the interface for all
55 views of event data like the agenda or the month view. 55 views of event data like the agenda or the month view.
56 56
57 @short Base class for calendar views 57 @short Base class for calendar views
58 @author Preston Brown, Cornelius Schumacher 58 @author Preston Brown, Cornelius Schumacher
59 @see KOTodoView, KOEventView, KOListView, KOAgendaView, KOMonthView 59 @see KOTodoView, KOEventView, KOListView, KOAgendaView, KOMonthView
60*/ 60*/
61class BaseView : public QWidget 61class BaseView : public QWidget
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 public: 64 public:
65 /** 65 /**
66 Constructs a view. 66 Constructs a view.
67 67
68 @param cal Pointer to the calendar object from which events 68 @param cal Pointer to the calendar object from which events
69 will be retrieved for display. 69 will be retrieved for display.
70 @param parent parent widget. 70 @param parent parent widget.
71 @param name name of this widget. 71 @param name name of this widget.
72 */ 72 */
73 BaseView(Calendar *cal, QWidget *parent = 0, const char *name = 0) : 73 BaseView(Calendar *cal, QWidget *parent = 0, const char *name = 0) :
74 QWidget(parent, name), mCalendar(cal) {} 74 QWidget(parent, name), mCalendar(cal) {}
75 75
76 /** 76 /**
77 Destructor. Views will do view-specific cleanups here. 77 Destructor. Views will do view-specific cleanups here.
78 */ 78 */
79 virtual ~BaseView() {} 79 virtual ~BaseView() {}
80 80
81 /** 81 /**
82 Return calendar object of this view. 82 Return calendar object of this view.
83 */ 83 */
84 Calendar *calendar() { return mCalendar; } 84 Calendar *calendar() { return mCalendar; }
85 85
86 /** 86 /**
87 @return a list of selected events. Most views can probably only 87 @return a list of selected events. Most views can probably only
88 select a single event at a time, but some may be able to select 88 select a single event at a time, but some may be able to select
89 more than one. 89 more than one.
90 */ 90 */
91 virtual QPtrList<Incidence> selectedIncidences() = 0; 91 virtual QPtrList<Incidence> selectedIncidences() = 0;
92 92
93 /** 93 /**
94 @return a list of the dates of selected events. Most views can probably only 94 @return a list of the dates of selected events. Most views can probably only
95 select a single event at a time, but some may be able to select 95 select a single event at a time, but some may be able to select
96 more than one. 96 more than one.
97 */ 97 */
98 virtual DateList selectedDates() = 0; 98 virtual DateList selectedDates() = 0;
99 99
100 /** 100 /**
101 Generate a print preview of this event view. 101 Generate a print preview of this event view.
102 102
103 @param calPrinter Calendar printer object used for printing 103 @param calPrinter Calendar printer object used for printing
104 @param fd from date 104 @param fd from date
105 @param td to date 105 @param td to date
106 */ 106 */
107/* 107/*
108 The date parameters should be determined by the view itself and not given as 108 The date parameters should be determined by the view itself and not given as
109 parameters. At the moment I just move the code from the topwidget to the 109 parameters. At the moment I just move the code from the topwidget to the
110 individual views. 110 individual views.
111*/ 111*/
112 virtual void printPreview(CalPrinter *, 112 virtual void printPreview(CalPrinter *,
113 const QDate &, const QDate &) 113 const QDate &, const QDate &)
114 { 114 {
115 KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n" 115 KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n"
116 "that view yet.\n")); 116 "that view yet.\n"));
117 } 117 }
118 118
119 /** 119 /**
120 Print this view. 120 Print this view.
121 121
122 @param calPrinter Calendar printer object used for printing 122 @param calPrinter Calendar printer object used for printing
123 */ 123 */
124 virtual void print(CalPrinter *) 124 virtual void print(CalPrinter *)
125 { 125 {
126 KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n" 126 KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n"
127 "that view yet.\n")); 127 "that view yet.\n"));
128 } 128 }
129 129
130 /** 130 /**
131 Return number of currently shown dates. A return value of 0 means no idea. 131 Return number of currently shown dates. A return value of 0 means no idea.
132 */ 132 */
133 virtual int currentDateCount() = 0; 133 virtual int currentDateCount() = 0;
134 134
135 /** Return if this view is a view for displaying events. */ 135 /** Return if this view is a view for displaying events. */
136 virtual bool isEventView() { return false; } 136 virtual bool isEventView() { return false; }
137 virtual bool isMonthView() { return false; }
137 138
138 public slots: 139 public slots:
139 /** 140 /**
140 Show incidences for the given date range. The date range actually shown may be 141 Show incidences for the given date range. The date range actually shown may be
141 different from the requested range, depending on the particular requirements 142 different from the requested range, depending on the particular requirements
142 of the view. 143 of the view.
143 144
144 @param start Start of date range. 145 @param start Start of date range.
145 @param end End of date range. 146 @param end End of date range.
146 */ 147 */
147 virtual void showDates( const QDate &start, const QDate &end ) = 0; 148 virtual void showDates( const QDate &start, const QDate &end ) = 0;
148 149
149 /** 150 /**
150 Show given events. Depending on the actual view it might not be possible to 151 Show given events. Depending on the actual view it might not be possible to
151 show all given events. 152 show all given events.
152 153
153 @param eventList a list of events to show. 154 @param eventList a list of events to show.
154 */ 155 */
155 virtual void showEvents(QPtrList<Event> eventList) = 0; 156 virtual void showEvents(QPtrList<Event> eventList) = 0;
156 157
157 /** 158 /**
158 Updates the current display to reflect changes that may have happened 159 Updates the current display to reflect changes that may have happened
159 in the calendar since the last display refresh. 160 in the calendar since the last display refresh.
160 */ 161 */
161 virtual void updateView() = 0; 162 virtual void updateView() = 0;
162 163
163 /** 164 /**
164 Write all unsaved data back to calendar store. 165 Write all unsaved data back to calendar store.
165 */ 166 */
166 virtual void flushView() {} 167 virtual void flushView() {}
167 168
168 /** 169 /**
169 Updates the current display to reflect the changes to one particular event. 170 Updates the current display to reflect the changes to one particular event.
170 */ 171 */
171 virtual void changeEventDisplay(Event *, int) = 0; 172 virtual void changeEventDisplay(Event *, int) = 0;
172 173
173 /** 174 /**
174 Re-reads the KOrganizer configuration and picks up relevant 175 Re-reads the KOrganizer configuration and picks up relevant
175 changes which are applicable to the view. 176 changes which are applicable to the view.
176 */ 177 */
177 virtual void updateConfig() {} 178 virtual void updateConfig() {}
178 179
179 /** 180 /**
180 Clear selection. The incidenceSelected signal is not emitted. 181 Clear selection. The incidenceSelected signal is not emitted.
181 */ 182 */
182 virtual void clearSelection() {} 183 virtual void clearSelection() {}
183 184
184 signals: 185 signals:
185 void incidenceSelected( Incidence * ); 186 void incidenceSelected( Incidence * );
186 187
187 protected: 188 protected:
188 Calendar *mCalendar; 189 Calendar *mCalendar;
189}; 190};
190 191
191} 192}
192#endif 193#endif
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index d976246..e94952f 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,252 +1,253 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 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 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qintdict.h> 29#include <qintdict.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qptrvector.h> 32#include <qptrvector.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35#include <libkcal/event.h> 35#include <libkcal/event.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class KOWeekButton : public QPushButton 39class KOWeekButton : public QPushButton
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 public: 42 public:
43 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 43 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
44 QPushButton( parent, name) 44 QPushButton( parent, name)
45 { 45 {
46 connect( this, SIGNAL( clicked() ), 46 connect( this, SIGNAL( clicked() ),
47 SLOT( bottonClicked() )); 47 SLOT( bottonClicked() ));
48 mNumber = -1; 48 mNumber = -1;
49 } 49 }
50 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 50 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
51 signals: 51 signals:
52 void selectWeekNum ( int ); 52 void selectWeekNum ( int );
53private: 53private:
54 int mNumber; 54 int mNumber;
55private slots : 55private slots :
56 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 56 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
57}; 57};
58 58
59class KNoScrollListBox: public QListBox 59class KNoScrollListBox: public QListBox
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 public: 62 public:
63 KNoScrollListBox(QWidget *parent=0, const char *name=0); 63 KNoScrollListBox(QWidget *parent=0, const char *name=0);
64 ~KNoScrollListBox() {} 64 ~KNoScrollListBox() {}
65 QString getWhatsThisText(QPoint p) ; 65 QString getWhatsThisText(QPoint p) ;
66 66
67 signals: 67 signals:
68 void shiftDown(); 68 void shiftDown();
69 void shiftUp(); 69 void shiftUp();
70 void rightClick(); 70 void rightClick();
71 71
72 protected slots: 72 protected slots:
73 void keyPressEvent(QKeyEvent *); 73 void keyPressEvent(QKeyEvent *);
74 void keyReleaseEvent(QKeyEvent *); 74 void keyReleaseEvent(QKeyEvent *);
75 void mousePressEvent(QMouseEvent *); 75 void mousePressEvent(QMouseEvent *);
76}; 76};
77 77
78 78
79class MonthViewItem: public QListBoxItem 79class MonthViewItem: public QListBoxItem
80{ 80{
81 public: 81 public:
82 MonthViewItem( Incidence *, QDate qd, const QString & title ); 82 MonthViewItem( Incidence *, QDate qd, const QString & title );
83 83
84 void setRecur(bool on) { mRecur = on; } 84 void setRecur(bool on) { mRecur = on; }
85 void setAlarm(bool on) { mAlarm = on; } 85 void setAlarm(bool on) { mAlarm = on; }
86 void setReply(bool on) { mReply = on; } 86 void setReply(bool on) { mReply = on; }
87 void setMoreInfo(bool on) { mInfo = on; } 87 void setMoreInfo(bool on) { mInfo = on; }
88 88
89 89
90 void setPalette(const QPalette &p) { mPalette = p; } 90 void setPalette(const QPalette &p) { mPalette = p; }
91 QPalette palette() const { return mPalette; } 91 QPalette palette() const { return mPalette; }
92 92
93 Incidence *incidence() const { return mIncidence; } 93 Incidence *incidence() const { return mIncidence; }
94 QDate incidenceDate() { return mDate; } 94 QDate incidenceDate() { return mDate; }
95 95
96 protected: 96 protected:
97 virtual void paint(QPainter *); 97 virtual void paint(QPainter *);
98 virtual int height(const QListBox *) const; 98 virtual int height(const QListBox *) const;
99 virtual int width(const QListBox *) const; 99 virtual int width(const QListBox *) const;
100 100
101 private: 101 private:
102 bool mRecur; 102 bool mRecur;
103 bool mAlarm; 103 bool mAlarm;
104 bool mReply; 104 bool mReply;
105 bool mInfo; 105 bool mInfo;
106 106
107 QPalette mPalette; 107 QPalette mPalette;
108 QDate mDate; 108 QDate mDate;
109 109
110 Incidence *mIncidence; 110 Incidence *mIncidence;
111}; 111};
112 112
113 113
114class KOMonthView; 114class KOMonthView;
115 115
116class MonthViewCell : public QWidget 116class MonthViewCell : public QWidget
117{ 117{
118 Q_OBJECT 118 Q_OBJECT
119 public: 119 public:
120 MonthViewCell( KOMonthView * ); 120 MonthViewCell( KOMonthView * );
121 121
122 void setDate( const QDate & ); 122 void setDate( const QDate & );
123 QDate date() const; 123 QDate date() const;
124 124
125 void setPrimary( bool ); 125 void setPrimary( bool );
126 bool isPrimary() const; 126 bool isPrimary() const;
127 127
128 void setHoliday( bool ); 128 void setHoliday( bool );
129 void setHoliday( const QString & ); 129 void setHoliday( const QString & );
130 130
131 void updateCell(); 131 void updateCell();
132 132
133 void updateConfig(); 133 void updateConfig();
134 134
135 void enableScrollBars( bool ); 135 void enableScrollBars( bool );
136 136
137 Incidence *selectedIncidence(); 137 Incidence *selectedIncidence();
138 QDate selectedIncidenceDate(); 138 QDate selectedIncidenceDate();
139 139
140 void deselect(); 140 void deselect();
141 void select(); 141 void select();
142 142
143 signals: 143 signals:
144 void defaultAction( Incidence * ); 144 void defaultAction( Incidence * );
145 void newEventSignal( QDateTime ); 145 void newEventSignal( QDateTime );
146 146
147 protected: 147 protected:
148 void resizeEvent( QResizeEvent * ); 148 void resizeEvent( QResizeEvent * );
149 149
150 protected slots: 150 protected slots:
151 void defaultAction( QListBoxItem * ); 151 void defaultAction( QListBoxItem * );
152 void contextMenu( QListBoxItem * ); 152 void contextMenu( QListBoxItem * );
153 void selection( QListBoxItem * ); 153 void selection( QListBoxItem * );
154 void cellClicked( QListBoxItem * ); 154 void cellClicked( QListBoxItem * );
155 void newEvent(); 155 void newEvent();
156 156
157 private: 157 private:
158 KOMonthView *mMonthView; 158 KOMonthView *mMonthView;
159 159
160 QDate mDate; 160 QDate mDate;
161 bool mPrimary; 161 bool mPrimary;
162 bool mHoliday; 162 bool mHoliday;
163 QString mHolidayString; 163 QString mHolidayString;
164 164
165 //QLabel *mLabel; 165 //QLabel *mLabel;
166 QPushButton *mLabel; 166 QPushButton *mLabel;
167 QListBox *mItemList; 167 QListBox *mItemList;
168 168
169 QSize mLabelSize; 169 QSize mLabelSize;
170 QSize mLabelBigSize; 170 QSize mLabelBigSize;
171 QPalette mHolidayPalette; 171 QPalette mHolidayPalette;
172 QPalette mStandardPalette; 172 QPalette mStandardPalette;
173 QPalette mPrimaryPalette; 173 QPalette mPrimaryPalette;
174 QPalette mNonPrimaryPalette; 174 QPalette mNonPrimaryPalette;
175 void setMyPalette(); 175 void setMyPalette();
176 QPalette getPalette (); 176 QPalette getPalette ();
177 void keyPressEvent ( QKeyEvent * ) ; 177 void keyPressEvent ( QKeyEvent * ) ;
178 178
179}; 179};
180 180
181 181
182class KOMonthView: public KOEventView 182class KOMonthView: public KOEventView
183{ 183{
184 Q_OBJECT 184 Q_OBJECT
185 public: 185 public:
186 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 186 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
187 ~KOMonthView(); 187 ~KOMonthView();
188 188
189 /** Returns maximum number of days supported by the komonthview */ 189 /** Returns maximum number of days supported by the komonthview */
190 virtual int maxDatesHint(); 190 virtual int maxDatesHint();
191 191
192 /** Returns number of currently shown dates. */ 192 /** Returns number of currently shown dates. */
193 virtual int currentDateCount(); 193 virtual int currentDateCount();
194 194
195 /** returns the currently selected events */ 195 /** returns the currently selected events */
196 virtual QPtrList<Incidence> selectedIncidences(); 196 virtual QPtrList<Incidence> selectedIncidences();
197 197
198 /** returns dates of the currently selected events */ 198 /** returns dates of the currently selected events */
199 virtual DateList selectedDates(); 199 virtual DateList selectedDates();
200 200
201 virtual void printPreview(CalPrinter *calPrinter, 201 virtual void printPreview(CalPrinter *calPrinter,
202 const QDate &, const QDate &); 202 const QDate &, const QDate &);
203 bool isMonthView() { return true; }
203 204
204 MonthViewCell * selectedCell(); 205 MonthViewCell * selectedCell();
205 public slots: 206 public slots:
206 virtual void updateView(); 207 virtual void updateView();
207 virtual void updateConfig(); 208 virtual void updateConfig();
208 virtual void showDates(const QDate &start, const QDate &end); 209 virtual void showDates(const QDate &start, const QDate &end);
209 virtual void showEvents(QPtrList<Event> eventList); 210 virtual void showEvents(QPtrList<Event> eventList);
210 211
211 void changeEventDisplay(Event *, int); 212 void changeEventDisplay(Event *, int);
212 213
213 void clearSelection(); 214 void clearSelection();
214 215
215 void showContextMenu( Incidence * ); 216 void showContextMenu( Incidence * );
216 217
217 void setSelectedCell( MonthViewCell * ); 218 void setSelectedCell( MonthViewCell * );
218 219
219 protected slots: 220 protected slots:
220 void processSelectionChange(); 221 void processSelectionChange();
221 signals: 222 signals:
222 void selectWeekNum ( int ); 223 void selectWeekNum ( int );
223 protected: 224 protected:
224 void resizeEvent(QResizeEvent *); 225 void resizeEvent(QResizeEvent *);
225 void viewChanged(); 226 void viewChanged();
226 void updateDayLabels(); 227 void updateDayLabels();
227 228
228 private: 229 private:
229 int mDaysPerWeek; 230 int mDaysPerWeek;
230 int mNumWeeks; 231 int mNumWeeks;
231 int mNumCells; 232 int mNumCells;
232 bool mWeekStartsMonday; 233 bool mWeekStartsMonday;
233 bool mShowSatSunComp; 234 bool mShowSatSunComp;
234 void computeLayout(); 235 void computeLayout();
235 236
236 QPtrVector<MonthViewCell> mCells; 237 QPtrVector<MonthViewCell> mCells;
237 QPtrVector<QLabel> mDayLabels; 238 QPtrVector<QLabel> mDayLabels;
238 QPtrVector<KOWeekButton> mWeekLabels; 239 QPtrVector<KOWeekButton> mWeekLabels;
239 240
240 bool mShortDayLabels; 241 bool mShortDayLabels;
241 int mWidthLongDayLabel; 242 int mWidthLongDayLabel;
242 243
243 QDate mStartDate; 244 QDate mStartDate;
244 245
245 MonthViewCell *mSelectedCell; 246 MonthViewCell *mSelectedCell;
246 247
247 KOEventPopupMenu *mContextMenu; 248 KOEventPopupMenu *mContextMenu;
248 void keyPressEvent ( QKeyEvent * ) ; 249 void keyPressEvent ( QKeyEvent * ) ;
249 250
250}; 251};
251 252
252#endif 253#endif