-rw-r--r-- | korganizer/mainwindow.cpp | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 9ae393d..8c72d89 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -341,50 +341,41 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
341 | mView->openCalendar( oldFile ); | 341 | mView->openCalendar( oldFile ); |
342 | qApp->processEvents(); | 342 | qApp->processEvents(); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | mView->saveCalendar( defaultFileName() ); | 345 | mView->saveCalendar( defaultFileName() ); |
346 | newFile = true; | 346 | newFile = true; |
347 | } | 347 | } |
348 | 348 | ||
349 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 349 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); |
350 | mView->loadCalendars(); | 350 | //mView->loadCalendars(); |
351 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 351 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
352 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 352 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
353 | 353 | ||
354 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 354 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
355 | KOPrefs::instance()->setAllDefaults(); | 355 | KOPrefs::instance()->setAllDefaults(); |
356 | } | 356 | } |
357 | processIncidenceSelection( 0 ); | ||
358 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
359 | SLOT( processIncidenceSelection( Incidence * ) ) ); | ||
360 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | ||
361 | SLOT( slotModifiedChanged( bool ) ) ); | ||
362 | 357 | ||
363 | 358 | ||
364 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 359 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
365 | SLOT( disableBR(bool) ) ); | 360 | SLOT( disableBR(bool) ) ); |
366 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 361 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
367 | mView->setModified( false ); | ||
368 | mBlockAtStartup = false; | ||
369 | mView->setModified( false ); | ||
370 | setCentralWidget( mView ); | 362 | setCentralWidget( mView ); |
371 | globalFlagBlockStartup = 0; | 363 | globalFlagBlockStartup = 0; |
372 | mView->show(); | 364 | mView->show(); |
373 | delete splash; | 365 | delete splash; |
374 | if ( newFile ) | 366 | if ( newFile ) |
375 | mView->updateConfig(); | 367 | mView->updateConfig(); |
376 | // qApp->processEvents(); | 368 | // qApp->processEvents(); |
377 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 369 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
378 | //fillSyncMenu(); | 370 | //fillSyncMenu(); |
379 | 371 | ||
380 | 372 | ||
381 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 373 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
382 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | ||
383 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 374 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
384 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 375 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
385 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 376 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
386 | mSyncManager->setDefaultFileName( sentSyncFile()); | 377 | mSyncManager->setDefaultFileName( sentSyncFile()); |
387 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 378 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
388 | mSyncManager->fillSyncMenu(); | 379 | mSyncManager->fillSyncMenu(); |
389 | 380 | ||
390 | 381 | ||
@@ -393,44 +384,75 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
393 | if ( showWarning ) { | 384 | if ( showWarning ) { |
394 | KMessageBox::information( this, | 385 | KMessageBox::information( this, |
395 | "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"); | 386 | "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"); |
396 | qApp->processEvents(); | 387 | qApp->processEvents(); |
397 | mView->dialogManager()->showSyncOptions(); | 388 | mView->dialogManager()->showSyncOptions(); |
398 | } | 389 | } |
399 | 390 | ||
400 | //US listen for result adressed from Ka/Pi | 391 | //US listen for result adressed from Ka/Pi |
401 | #ifndef DESKTOP_VERSION | 392 | |
402 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | ||
403 | #endif | ||
404 | #ifndef DESKTOP_VERSION | 393 | #ifndef DESKTOP_VERSION |
405 | infrared = 0; | 394 | infrared = 0; |
406 | #endif | 395 | #endif |
407 | updateFilterToolbar(); | 396 | updateFilterToolbar(); |
408 | updateWeek( mView->startDate() ); | 397 | updateWeek( mView->startDate() ); |
409 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 398 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
410 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 399 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
411 | mBRdisabled = false; | 400 | mBRdisabled = false; |
412 | //toggleBeamReceive(); | 401 | //toggleBeamReceive(); |
413 | 402 | ||
414 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 403 | setCaption(i18n("Loading calendar files ... please wait" )); |
404 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); | ||
415 | } | 405 | } |
416 | MainWindow::~MainWindow() | 406 | MainWindow::~MainWindow() |
417 | { | 407 | { |
418 | //qDebug("MainWindow::~MainWindow() "); | 408 | //qDebug("MainWindow::~MainWindow() "); |
419 | //save toolbar location | 409 | //save toolbar location |
420 | delete mCalendar; | 410 | delete mCalendar; |
421 | delete mSyncManager; | 411 | delete mSyncManager; |
422 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
423 | if ( infrared ) | 413 | if ( infrared ) |
424 | delete infrared; | 414 | delete infrared; |
425 | #endif | 415 | #endif |
426 | 416 | ||
427 | 417 | ||
428 | } | 418 | } |
419 | |||
420 | void MainWindow::loadDataAfterStart() | ||
421 | { | ||
422 | |||
423 | qDebug("KO: Start loading files..." ); | ||
424 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | ||
425 | mView->loadCalendars(); | ||
426 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | ||
427 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | ||
428 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | ||
429 | mView->setModified( false ); | ||
430 | mBlockAtStartup = false; | ||
431 | mView->setModified( false ); | ||
432 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | ||
433 | processIncidenceSelection( 0 ); | ||
434 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
435 | SLOT( processIncidenceSelection( Incidence * ) ) ); | ||
436 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | ||
437 | SLOT( slotModifiedChanged( bool ) ) ); | ||
438 | |||
439 | #ifndef DESKTOP_VERSION | ||
440 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | ||
441 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); | ||
442 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); | ||
443 | if ( !mCStringMess.isEmpty() ) | ||
444 | recieve( mCStringMess, mByteData ); | ||
445 | #endif | ||
446 | |||
447 | |||
448 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | ||
449 | } | ||
450 | |||
429 | void MainWindow::slotResetFocus() | 451 | void MainWindow::slotResetFocus() |
430 | { | 452 | { |
431 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); | 453 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); |
432 | mFocusLoop = 3; | 454 | mFocusLoop = 3; |
433 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 455 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
434 | } | 456 | } |
435 | void MainWindow::slotResetFocusLoop() | 457 | void MainWindow::slotResetFocusLoop() |
436 | { | 458 | { |
@@ -535,17 +557,22 @@ void MainWindow::closeEvent( QCloseEvent* ce ) | |||
535 | case 2: | 557 | case 2: |
536 | 558 | ||
537 | default: | 559 | default: |
538 | break; | 560 | break; |
539 | } | 561 | } |
540 | 562 | ||
541 | 563 | ||
542 | } | 564 | } |
543 | 565 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) | |
566 | { | ||
567 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | ||
568 | mCStringMess = cmsg; | ||
569 | mByteData = data; | ||
570 | } | ||
544 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 571 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
545 | { | 572 | { |
546 | QDataStream stream( data, IO_ReadOnly ); | 573 | QDataStream stream( data, IO_ReadOnly ); |
547 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 574 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
548 | //QString datamess; | 575 | //QString datamess; |
549 | //qDebug("message "); | 576 | //qDebug("message "); |
550 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 577 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
551 | 578 | ||
@@ -2511,16 +2538,17 @@ void MainWindow::importFile( QString fn, bool quick ) | |||
2511 | } | 2538 | } |
2512 | if ( result == 0 ) { | 2539 | if ( result == 0 ) { |
2513 | if ( mView->openCalendar( fn, true )) { | 2540 | if ( mView->openCalendar( fn, true )) { |
2514 | KOPrefs::instance()->mLastImportFile = fn; | 2541 | KOPrefs::instance()->mLastImportFile = fn; |
2515 | setCaption(i18n("Imported file successfully")); | 2542 | setCaption(i18n("Imported file successfully")); |
2516 | } else { | 2543 | } else { |
2517 | setCaption(i18n("Error importing file")); | 2544 | setCaption(i18n("Error importing file")); |
2518 | } | 2545 | } |
2546 | mView->updateView(); | ||
2519 | } | 2547 | } |
2520 | } | 2548 | } |
2521 | 2549 | ||
2522 | void MainWindow::importIcal() | 2550 | void MainWindow::importIcal() |
2523 | { | 2551 | { |
2524 | 2552 | ||
2525 | QString fn =KOPrefs::instance()->mLastImportFile; | 2553 | QString fn =KOPrefs::instance()->mLastImportFile; |
2526 | 2554 | ||