author | zautrix <zautrix> | 2004-09-22 06:39:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-22 06:39:51 (UTC) |
commit | c640aaff31f298b4aff7a61cbdfa9c8a95269479 (patch) (unidiff) | |
tree | 3fe1c1d16c63d03e7b1faec540df30b7a8e5c506 /korganizer | |
parent | bbeffa56ee51d30b84bcadaf22234b8227958f31 (diff) | |
download | kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.zip kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.gz kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.bz2 |
modified file warning fix
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 |
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 | |||
@@ -1514,7 +1514,7 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
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; |
@@ -1545,6 +1545,19 @@ bool CalendarView::checkFileChanged(QString fn) | |||
1545 | return true; | 1545 | return true; |
1546 | 1546 | ||
1547 | } | 1547 | } |
1548 | void 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 | |||
1548 | bool CalendarView::checkFileVersion(QString fn) | 1561 | bool CalendarView::checkFileVersion(QString fn) |
1549 | { | 1562 | { |
1550 | QFileInfo finf ( fn ); | 1563 | QFileInfo finf ( fn ); |
@@ -1555,7 +1568,7 @@ bool CalendarView::checkFileVersion(QString fn) | |||
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 | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index a3315ad..355bb84 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -172,6 +172,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
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 ¬i ); | 178 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 1c4a186..6315c64 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1408,10 +1408,11 @@ void MainWindow::save() | |||
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 ); |