summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp3
3 files changed, 18 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3635cfa..eaea040 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1501,74 +1501,87 @@ bool CalendarView::openCalendar(QString filename, bool merge)
1501 1501
1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
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 if ( filename != MainWindow::defaultFileName() ) 1517 if ( filename != MainWindow::defaultFileName() )
1518 saveCalendar( MainWindow::defaultFileName() ); 1518 saveCalendar( MainWindow::defaultFileName() );
1519 loadedFileVersion = QDateTime::currentDateTime(); 1519 loadedFileVersion = QDateTime::currentDateTime();
1520 return true; 1520 return true;
1521 } else { 1521 } else {
1522 // while failing to load, the calendar object could 1522 // while failing to load, the calendar object could
1523 // have become partially populated. Clear it out. 1523 // have become partially populated. Clear it out.
1524 if ( !merge ) mCalendar->close(); 1524 if ( !merge ) mCalendar->close();
1525 1525
1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1527 1527
1528 globalFlagBlockAgenda = 2; 1528 globalFlagBlockAgenda = 2;
1529 updateView(); 1529 updateView();
1530 } 1530 }
1531 return false; 1531 return false;
1532} 1532}
1533void CalendarView::setLoadedFileVersion(QDateTime dt) 1533void CalendarView::setLoadedFileVersion(QDateTime dt)
1534{ 1534{
1535 loadedFileVersion = dt; 1535 loadedFileVersion = dt;
1536} 1536}
1537bool CalendarView::checkFileChanged(QString fn) 1537bool CalendarView::checkFileChanged(QString fn)
1538{ 1538{
1539 QFileInfo finf ( fn ); 1539 QFileInfo finf ( fn );
1540 if ( !finf.exists() ) 1540 if ( !finf.exists() )
1541 return true; 1541 return true;
1542 QDateTime dt = finf.lastModified (); 1542 QDateTime dt = finf.lastModified ();
1543 if ( dt <= loadedFileVersion ) 1543 if ( dt <= loadedFileVersion )
1544 return false; 1544 return false;
1545 return true; 1545 return true;
1546 1546
1547} 1547}
1548void CalendarView::watchSavedFile()
1549{
1550 QFileInfo finf ( MainWindow::defaultFileName());
1551 if ( !finf.exists() )
1552 return;
1553 QDateTime dt = finf.lastModified ();
1554 if ( dt < loadedFileVersion ) {
1555 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1556 return;
1557 }
1558 loadedFileVersion = dt;
1559}
1560
1548bool CalendarView::checkFileVersion(QString fn) 1561bool CalendarView::checkFileVersion(QString fn)
1549{ 1562{
1550 QFileInfo finf ( fn ); 1563 QFileInfo finf ( fn );
1551 if ( !finf.exists() ) 1564 if ( !finf.exists() )
1552 return true; 1565 return true;
1553 QDateTime dt = finf.lastModified (); 1566 QDateTime dt = finf.lastModified ();
1554 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1567 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1555 //qDebug("file on disk version %s",dt.toString().latin1()); 1568 //qDebug("file on disk version %s",dt.toString().latin1());
1556 if ( dt <= loadedFileVersion ) 1569 if ( dt <= loadedFileVersion )
1557 return true; 1570 return true;
1558 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, false)) , 1571 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)) ,
1559 i18n("KO/Pi Warning"),i18n("Overwrite"), 1572 i18n("KO/Pi Warning"),i18n("Overwrite"),
1560 i18n("Sync+save")); 1573 i18n("Sync+save"));
1561 1574
1562 if ( km == KMessageBox::Cancel ) 1575 if ( km == KMessageBox::Cancel )
1563 return false; 1576 return false;
1564 if ( km == KMessageBox::Yes ) 1577 if ( km == KMessageBox::Yes )
1565 return true; 1578 return true;
1566 1579
1567 setSyncDevice("deleteaftersync" ); 1580 setSyncDevice("deleteaftersync" );
1568 KOPrefs::instance()->mAskForPreferences = true; 1581 KOPrefs::instance()->mAskForPreferences = true;
1569 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1582 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1570 KOPrefs::instance()->mWriteBackFile = false; 1583 KOPrefs::instance()->mWriteBackFile = false;
1571 KOPrefs::instance()->mWriteBackExistingOnly = false; 1584 KOPrefs::instance()->mWriteBackExistingOnly = false;
1572 KOPrefs::instance()->mShowSyncSummary = false; 1585 KOPrefs::instance()->mShowSyncSummary = false;
1573 syncCalendar( fn, 3 ); 1586 syncCalendar( fn, 3 );
1574 Event * e = getLastSyncEvent(); 1587 Event * e = getLastSyncEvent();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index a3315ad..355bb84 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -159,32 +159,33 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
159 void pasteEnabled(bool); 159 void pasteEnabled(bool);
160 160
161 /** Emitted, when the number of incoming messages has changed. */ 161 /** Emitted, when the number of incoming messages has changed. */
162 void numIncomingChanged(int); 162 void numIncomingChanged(int);
163 163
164 /** Emitted, when the number of outgoing messages has changed. */ 164 /** Emitted, when the number of outgoing messages has changed. */
165 void numOutgoingChanged(int); 165 void numOutgoingChanged(int);
166 166
167 /** Send status message, which can e.g. be displayed in the status bar. */ 167 /** Send status message, which can e.g. be displayed in the status bar. */
168 void statusMessage(const QString &); 168 void statusMessage(const QString &);
169 169
170 void calendarViewExpanded( bool ); 170 void calendarViewExpanded( bool );
171 void updateSearchDialog(); 171 void updateSearchDialog();
172 172
173 173
174 public slots: 174 public slots:
175 void watchSavedFile();
175 void recheckTimerAlarm(); 176 void recheckTimerAlarm();
176 void checkNextTimerAlarm(); 177 void checkNextTimerAlarm();
177 void addAlarm(const QDateTime &qdt, const QString &noti ); 178 void addAlarm(const QDateTime &qdt, const QString &noti );
178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 179 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
179 void removeAlarm(const QDateTime &qdt, const QString &noti ); 180 void removeAlarm(const QDateTime &qdt, const QString &noti );
180 181
181 /** options dialog made a changed to the configuration. we catch this 182 /** options dialog made a changed to the configuration. we catch this
182 * and notify all widgets which need to update their configuration. */ 183 * and notify all widgets which need to update their configuration. */
183 void updateConfig(); 184 void updateConfig();
184 185
185 /** 186 /**
186 Load calendar from file \a filename. If \a merge is true, load 187 Load calendar from file \a filename. If \a merge is true, load
187 calendar into existing one, if it is false, clear calendar, before 188 calendar into existing one, if it is false, clear calendar, before
188 loading. Return true, if calendar could be successfully loaded. 189 loading. Return true, if calendar could be successfully loaded.
189 */ 190 */
190 bool openCalendar(QString filename, bool merge=false); 191 bool openCalendar(QString filename, bool merge=false);
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 1c4a186..6315c64 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1395,36 +1395,37 @@ void MainWindow::slotModifiedChanged( bool changed )
1395 mSaveTimer.start( msec, true ); // 1 minute 1395 mSaveTimer.start( msec, true ); // 1 minute
1396 qDebug("KO: Saving File in %d secs!", msec/1000); 1396 qDebug("KO: Saving File in %d secs!", msec/1000);
1397 mCalendarModifiedFlag = true; 1397 mCalendarModifiedFlag = true;
1398} 1398}
1399#include <qfileinfo.h> 1399#include <qfileinfo.h>
1400void MainWindow::save() 1400void MainWindow::save()
1401{ 1401{
1402 if ( mBlockSaveFlag ) 1402 if ( mBlockSaveFlag )
1403 return; 1403 return;
1404 bool store = mBlockSaveFlag; 1404 bool store = mBlockSaveFlag;
1405 mBlockSaveFlag = true; 1405 mBlockSaveFlag = true;
1406 if ( mView->checkFileVersion( defaultFileName()) ) { 1406 if ( mView->checkFileVersion( defaultFileName()) ) {
1407 1407
1408 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1408 QTime neededSaveTime = QDateTime::currentDateTime().time();
1409 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1409 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1410 qDebug("KO: Start saving data to file!"); 1410 qDebug("KO: Start saving data to file!");
1411 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1411 mView->saveCalendar( defaultFileName() ); 1412 mView->saveCalendar( defaultFileName() );
1412 1413
1413 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1414 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1414 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1415 mView->watchSavedFile();
1415 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1416 qDebug("KO: Needed %d ms for saving.",msNeeded );
1416 QString savemes; 1417 QString savemes;
1417 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1418 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1418 setCaption(savemes); 1419 setCaption(savemes);
1419 } else 1420 } else
1420 setCaption(i18n("Saving cancelled!")); 1421 setCaption(i18n("Saving cancelled!"));
1421 mCalendarModifiedFlag = false; 1422 mCalendarModifiedFlag = false;
1422 mBlockSaveFlag = store; 1423 mBlockSaveFlag = store;
1423} 1424}
1424 1425
1425void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1426void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1426{ 1427{
1427 if ( !e->isAutoRepeat() ) { 1428 if ( !e->isAutoRepeat() ) {
1428 mFlagKeyPressed = false; 1429 mFlagKeyPressed = false;
1429 } 1430 }
1430} 1431}