-rw-r--r-- | korganizer/mainwindow.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 3feb4ab..a2c20a8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -214,96 +214,98 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
214 | qApp->processEvents(); | 214 | qApp->processEvents(); |
215 | } else { | 215 | } else { |
216 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 216 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
217 | finfo.setFile( oldFile ); | 217 | finfo.setFile( oldFile ); |
218 | if (finfo.exists() ) { | 218 | if (finfo.exists() ) { |
219 | KMessageBox::information( this, message); | 219 | KMessageBox::information( this, message); |
220 | mView->openCalendar( oldFile ); | 220 | mView->openCalendar( oldFile ); |
221 | qApp->processEvents(); | 221 | qApp->processEvents(); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | mView->saveCalendar( defaultFileName() ); | 224 | mView->saveCalendar( defaultFileName() ); |
225 | newFile = true; | 225 | newFile = true; |
226 | } | 226 | } |
227 | 227 | ||
228 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 228 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
229 | mView->openCalendar( defaultFileName() ); | 229 | mView->openCalendar( defaultFileName() ); |
230 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 230 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
231 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 231 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
232 | 232 | ||
233 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 233 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
234 | KOPrefs::instance()->setCategoryDefaults(); | 234 | KOPrefs::instance()->setCategoryDefaults(); |
235 | int count = mView->addCategories(); | 235 | int count = mView->addCategories(); |
236 | } | 236 | } |
237 | processIncidenceSelection( 0 ); | 237 | processIncidenceSelection( 0 ); |
238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
239 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 239 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
241 | SLOT( slotModifiedChanged( bool ) ) ); | 241 | SLOT( slotModifiedChanged( bool ) ) ); |
242 | 242 | ||
243 | 243 | ||
244 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 244 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
245 | SLOT( disableBR(bool) ) ); | 245 | SLOT( disableBR(bool) ) ); |
246 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 246 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
247 | mView->setModified( false ); | 247 | mView->setModified( false ); |
248 | mBlockAtStartup = false; | 248 | mBlockAtStartup = false; |
249 | mView->setModified( false ); | 249 | mView->setModified( false ); |
250 | setCentralWidget( mView ); | 250 | setCentralWidget( mView ); |
251 | globalFlagBlockStartup = 0; | 251 | globalFlagBlockStartup = 0; |
252 | mView->show(); | 252 | mView->show(); |
253 | delete splash; | 253 | delete splash; |
254 | if ( newFile ) | 254 | if ( newFile ) |
255 | mView->updateConfig(); | 255 | mView->updateConfig(); |
256 | // qApp->processEvents(); | 256 | // qApp->processEvents(); |
257 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 257 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
258 | //fillSyncMenu(); | 258 | //fillSyncMenu(); |
259 | 259 | ||
260 | 260 | ||
261 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 261 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
262 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | ||
263 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | ||
262 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 264 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
263 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 265 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
264 | mSyncManager->setDefaultFileName( defaultFileName()); | 266 | mSyncManager->setDefaultFileName( defaultFileName()); |
265 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 267 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
266 | mSyncManager->fillSyncMenu(); | 268 | mSyncManager->fillSyncMenu(); |
267 | 269 | ||
268 | 270 | ||
269 | 271 | ||
270 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 272 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
271 | if ( showWarning ) { | 273 | if ( showWarning ) { |
272 | KMessageBox::information( this, | 274 | KMessageBox::information( this, |
273 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 275 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
274 | qApp->processEvents(); | 276 | qApp->processEvents(); |
275 | mView->dialogManager()->showSyncOptions(); | 277 | mView->dialogManager()->showSyncOptions(); |
276 | } | 278 | } |
277 | 279 | ||
278 | //US listen for result adressed from Ka/Pi | 280 | //US listen for result adressed from Ka/Pi |
279 | #ifndef DESKTOP_VERSION | 281 | #ifndef DESKTOP_VERSION |
280 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 282 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
281 | #endif | 283 | #endif |
282 | #ifndef DESKTOP_VERSION | 284 | #ifndef DESKTOP_VERSION |
283 | infrared = 0; | 285 | infrared = 0; |
284 | #endif | 286 | #endif |
285 | 287 | ||
286 | mBRdisabled = false; | 288 | mBRdisabled = false; |
287 | //toggleBeamReceive(); | 289 | //toggleBeamReceive(); |
288 | } | 290 | } |
289 | MainWindow::~MainWindow() | 291 | MainWindow::~MainWindow() |
290 | { | 292 | { |
291 | //qDebug("MainWindow::~MainWindow() "); | 293 | //qDebug("MainWindow::~MainWindow() "); |
292 | //save toolbar location | 294 | //save toolbar location |
293 | delete mCalendar; | 295 | delete mCalendar; |
294 | delete mSyncManager; | 296 | delete mSyncManager; |
295 | #ifndef DESKTOP_VERSION | 297 | #ifndef DESKTOP_VERSION |
296 | if ( infrared ) | 298 | if ( infrared ) |
297 | delete infrared; | 299 | delete infrared; |
298 | #endif | 300 | #endif |
299 | 301 | ||
300 | 302 | ||
301 | } | 303 | } |
302 | 304 | ||
303 | void MainWindow::disableBR(bool b) | 305 | void MainWindow::disableBR(bool b) |
304 | { | 306 | { |
305 | #ifndef DESKTOP_VERSION | 307 | #ifndef DESKTOP_VERSION |
306 | if ( b ) { | 308 | if ( b ) { |
307 | if ( infrared ) { | 309 | if ( infrared ) { |
308 | toggleBeamReceive(); | 310 | toggleBeamReceive(); |
309 | mBRdisabled = true; | 311 | mBRdisabled = true; |
@@ -1402,127 +1404,138 @@ void MainWindow::importBday() | |||
1402 | { | 1404 | { |
1403 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1405 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1404 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1406 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1405 | i18n("Import!"), i18n("Cancel"), 0, | 1407 | i18n("Import!"), i18n("Cancel"), 0, |
1406 | 0, 1 ); | 1408 | 0, 1 ); |
1407 | if ( result == 0 ) { | 1409 | if ( result == 0 ) { |
1408 | mView->importBday(); | 1410 | mView->importBday(); |
1409 | 1411 | ||
1410 | } | 1412 | } |
1411 | 1413 | ||
1412 | 1414 | ||
1413 | } | 1415 | } |
1414 | void MainWindow::importQtopia() | 1416 | void MainWindow::importQtopia() |
1415 | { | 1417 | { |
1416 | #ifndef DESKTOP_VERSION | 1418 | #ifndef DESKTOP_VERSION |
1417 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1419 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1418 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1420 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1419 | i18n("Import!"), i18n("Cancel"), 0, | 1421 | i18n("Import!"), i18n("Cancel"), 0, |
1420 | 0, 1 ); | 1422 | 0, 1 ); |
1421 | if ( result == 0 ) { | 1423 | if ( result == 0 ) { |
1422 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1424 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1423 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1425 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1424 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1426 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1425 | mView->importQtopia( categories, datebook, todolist ); | 1427 | mView->importQtopia( categories, datebook, todolist ); |
1426 | } | 1428 | } |
1427 | #else | 1429 | #else |
1428 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1430 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1429 | i18n("Not supported \non desktop!\n"), | 1431 | i18n("Not supported \non desktop!\n"), |
1430 | i18n("Ok"), i18n("Cancel"), 0, | 1432 | i18n("Ok"), i18n("Cancel"), 0, |
1431 | 0, 1 ); | 1433 | 0, 1 ); |
1432 | 1434 | ||
1433 | #endif | 1435 | #endif |
1434 | } | 1436 | } |
1435 | 1437 | ||
1436 | void MainWindow::saveOnClose() | 1438 | void MainWindow::saveOnClose() |
1437 | { | 1439 | { |
1438 | KOPrefs *p = KOPrefs::instance(); | 1440 | KOPrefs *p = KOPrefs::instance(); |
1439 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1441 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1440 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1442 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1441 | iconToolBar->y() > height()/2; | 1443 | iconToolBar->y() > height()/2; |
1442 | mView->writeSettings(); | 1444 | mView->writeSettings(); |
1443 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1445 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1444 | save(); | 1446 | save(); |
1445 | } | 1447 | } |
1446 | void MainWindow::slotModifiedChanged( bool changed ) | 1448 | void MainWindow::slotModifiedChanged( bool changed ) |
1447 | { | 1449 | { |
1448 | if ( mBlockAtStartup ) | 1450 | if ( mBlockAtStartup ) |
1449 | return; | 1451 | return; |
1452 | |||
1450 | int msec; | 1453 | int msec; |
1451 | // we store the changes after 1 minute, | 1454 | // we store the changes after 1 minute, |
1452 | // and for safety reasons after 10 minutes again | 1455 | // and for safety reasons after 10 minutes again |
1453 | if ( !mSyncManager->blockSave() ) | 1456 | if ( !mSyncManager->blockSave() ) |
1454 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1457 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1455 | else | 1458 | else |
1456 | msec = 1000 * 600; | 1459 | msec = 1000 * 600; |
1457 | mSaveTimer.start( msec, true ); // 1 minute | 1460 | mSaveTimer.start( msec, true ); // 1 minute |
1458 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1461 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1459 | mCalendarModifiedFlag = true; | 1462 | mCalendarModifiedFlag = true; |
1460 | } | 1463 | } |
1464 | void MainWindow::saveStopTimer() | ||
1465 | { | ||
1466 | mSaveTimer.stop(); | ||
1467 | if (mSaveTimer.isActive() ) | ||
1468 | qDebug("ti active "); | ||
1469 | else | ||
1470 | qDebug("KO: Save timer stopped"); | ||
1471 | } | ||
1461 | void MainWindow::save() | 1472 | void MainWindow::save() |
1462 | { | 1473 | { |
1474 | if ( !mCalendarModifiedFlag ) { | ||
1475 | qDebug("KO: Calendar not modified. Nothing saved."); | ||
1476 | return; | ||
1477 | } | ||
1463 | if ( mSyncManager->blockSave() ) | 1478 | if ( mSyncManager->blockSave() ) |
1464 | return; | 1479 | return; |
1465 | mSyncManager->setBlockSave(true); | 1480 | mSyncManager->setBlockSave(true); |
1466 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1481 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1467 | |||
1468 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1482 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1469 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1483 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1470 | qDebug("KO: Start saving data to file!"); | 1484 | qDebug("KO: Start saving data to file!"); |
1471 | mView->saveCalendar( defaultFileName() ); | 1485 | mView->saveCalendar( defaultFileName() ); |
1472 | 1486 | mCalendarModifiedFlag = false; | |
1473 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1487 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1474 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1488 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1475 | QString savemes; | 1489 | QString savemes; |
1476 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1490 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1477 | setCaption(savemes); | 1491 | setCaption(savemes); |
1478 | } else | 1492 | } else |
1479 | setCaption(i18n("Saving cancelled!")); | 1493 | setCaption(i18n("Saving cancelled!")); |
1480 | mCalendarModifiedFlag = false; | ||
1481 | mSyncManager->setBlockSave( false ); | 1494 | mSyncManager->setBlockSave( false ); |
1482 | } | 1495 | } |
1483 | 1496 | ||
1484 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1497 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1485 | { | 1498 | { |
1486 | if ( !e->isAutoRepeat() ) { | 1499 | if ( !e->isAutoRepeat() ) { |
1487 | mFlagKeyPressed = false; | 1500 | mFlagKeyPressed = false; |
1488 | } | 1501 | } |
1489 | } | 1502 | } |
1490 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1503 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1491 | { | 1504 | { |
1492 | qApp->processEvents(); | 1505 | qApp->processEvents(); |
1493 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1506 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1494 | e->ignore(); | 1507 | e->ignore(); |
1495 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1508 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1496 | return; | 1509 | return; |
1497 | } | 1510 | } |
1498 | if (! e->isAutoRepeat() ) | 1511 | if (! e->isAutoRepeat() ) |
1499 | mFlagKeyPressed = true; | 1512 | mFlagKeyPressed = true; |
1500 | KOPrefs *p = KOPrefs::instance(); | 1513 | KOPrefs *p = KOPrefs::instance(); |
1501 | bool showSelectedDates = false; | 1514 | bool showSelectedDates = false; |
1502 | int size; | 1515 | int size; |
1503 | int pro = 0; | 1516 | int pro = 0; |
1504 | //qDebug("MainWindow::keyPressEvent "); | 1517 | //qDebug("MainWindow::keyPressEvent "); |
1505 | switch ( e->key() ) { | 1518 | switch ( e->key() ) { |
1506 | case Qt::Key_Right: | 1519 | case Qt::Key_Right: |
1507 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1520 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1508 | mView->goNextMonth(); | 1521 | mView->goNextMonth(); |
1509 | else | 1522 | else |
1510 | mView->goNext(); | 1523 | mView->goNext(); |
1511 | showSelectedDates = true; | 1524 | showSelectedDates = true; |
1512 | break; | 1525 | break; |
1513 | case Qt::Key_Left: | 1526 | case Qt::Key_Left: |
1514 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1527 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1515 | mView->goPreviousMonth(); | 1528 | mView->goPreviousMonth(); |
1516 | else | 1529 | else |
1517 | mView->goPrevious(); | 1530 | mView->goPrevious(); |
1518 | showSelectedDates = true; | 1531 | showSelectedDates = true; |
1519 | break; | 1532 | break; |
1520 | case Qt::Key_Down: | 1533 | case Qt::Key_Down: |
1521 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1534 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1522 | break; | 1535 | break; |
1523 | case Qt::Key_Up: | 1536 | case Qt::Key_Up: |
1524 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1537 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1525 | break; | 1538 | break; |
1526 | case Qt::Key_I: | 1539 | case Qt::Key_I: |
1527 | mView->showIncidence(); | 1540 | mView->showIncidence(); |
1528 | break; | 1541 | break; |