summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fecc7e2..687943e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1502,57 +1502,70 @@ bool CalendarView::openCalendar(QString filename, bool merge)
1502 if ( mStorage->load() ) { 1502 if ( mStorage->load() ) {
1503 if ( merge ) ;//setModified( true ); 1503 if ( merge ) ;//setModified( true );
1504 else { 1504 else {
1505 //setModified( true ); 1505 //setModified( true );
1506 mViewManager->setDocumentId( filename ); 1506 mViewManager->setDocumentId( filename );
1507 mDialogManager->setDocumentId( filename ); 1507 mDialogManager->setDocumentId( filename );
1508 mTodoList->setDocumentId( filename ); 1508 mTodoList->setDocumentId( filename );
1509 } 1509 }
1510 globalFlagBlockAgenda = 2; 1510 globalFlagBlockAgenda = 2;
1511 // if ( getLastSyncEvent() ) 1511 // if ( getLastSyncEvent() )
1512 // getLastSyncEvent()->setReadOnly( true ); 1512 // getLastSyncEvent()->setReadOnly( true );
1513 mCalendar->reInitAlarmSettings(); 1513 mCalendar->reInitAlarmSettings();
1514 setSyncEventsReadOnly(); 1514 setSyncEventsReadOnly();
1515 updateUnmanagedViews(); 1515 updateUnmanagedViews();
1516 updateView(); 1516 updateView();
1517 loadedFileVersion = QDateTime::currentDateTime(); 1517 loadedFileVersion = QDateTime::currentDateTime();
1518 if ( filename != MainWindow::defaultFileName() ) { 1518 if ( filename != MainWindow::defaultFileName() ) {
1519 saveCalendar( MainWindow::defaultFileName() ); 1519 saveCalendar( MainWindow::defaultFileName() );
1520 watchSavedFile(); 1520 watchSavedFile();
1521 } 1521 }
1522 return true; 1522 return true;
1523 } else { 1523 } else {
1524 // while failing to load, the calendar object could 1524 // while failing to load, the calendar object could
1525 // have become partially populated. Clear it out. 1525 // have become partially populated. Clear it out.
1526 if ( !merge ) mCalendar->close(); 1526 if ( !merge ) {
1527 mCalendar->close();
1528 mViewManager->setDocumentId( filename );
1529 mDialogManager->setDocumentId( filename );
1530 mTodoList->setDocumentId( filename );
1531 }
1527 1532
1528 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1533 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1529 1534
1535 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1530 globalFlagBlockAgenda = 2; 1536 globalFlagBlockAgenda = 2;
1537 mCalendar->reInitAlarmSettings();
1538 setSyncEventsReadOnly();
1539 updateUnmanagedViews();
1531 updateView(); 1540 updateView();
1532 } 1541 }
1533 return false; 1542 return false;
1534} 1543}
1544void CalendarView::showOpenError()
1545{
1546 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1547}
1535void CalendarView::setLoadedFileVersion(QDateTime dt) 1548void CalendarView::setLoadedFileVersion(QDateTime dt)
1536{ 1549{
1537 loadedFileVersion = dt; 1550 loadedFileVersion = dt;
1538} 1551}
1539bool CalendarView::checkFileChanged(QString fn) 1552bool CalendarView::checkFileChanged(QString fn)
1540{ 1553{
1541 QFileInfo finf ( fn ); 1554 QFileInfo finf ( fn );
1542 if ( !finf.exists() ) 1555 if ( !finf.exists() )
1543 return true; 1556 return true;
1544 QDateTime dt = finf.lastModified (); 1557 QDateTime dt = finf.lastModified ();
1545 if ( dt <= loadedFileVersion ) 1558 if ( dt <= loadedFileVersion )
1546 return false; 1559 return false;
1547 return true; 1560 return true;
1548 1561
1549} 1562}
1550void CalendarView::watchSavedFile() 1563void CalendarView::watchSavedFile()
1551{ 1564{
1552 QFileInfo finf ( MainWindow::defaultFileName()); 1565 QFileInfo finf ( MainWindow::defaultFileName());
1553 if ( !finf.exists() ) 1566 if ( !finf.exists() )
1554 return; 1567 return;
1555 QDateTime dt = finf.lastModified (); 1568 QDateTime dt = finf.lastModified ();
1556 if ( dt < loadedFileVersion ) { 1569 if ( dt < loadedFileVersion ) {
1557 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1570 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1558 return; 1571 return;