summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-22 06:39:51 (UTC)
committer zautrix <zautrix>2004-09-22 06:39:51 (UTC)
commitc640aaff31f298b4aff7a61cbdfa9c8a95269479 (patch) (side-by-side diff)
tree3fe1c1d16c63d03e7b1faec540df30b7a8e5c506
parentbbeffa56ee51d30b84bcadaf22234b8227958f31 (diff)
downloadkdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.zip
kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.gz
kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.bz2
modified file warning fix
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
@@ -1516,3 +1516,3 @@ bool CalendarView::openCalendar(QString filename, bool merge)
updateView();
- if ( filename != MainWindow::defaultFileName() )
+ if ( filename != MainWindow::defaultFileName() )
saveCalendar( MainWindow::defaultFileName() );
@@ -1547,2 +1547,15 @@ bool CalendarView::checkFileChanged(QString fn)
}
+void CalendarView::watchSavedFile()
+{
+ QFileInfo finf ( MainWindow::defaultFileName());
+ if ( !finf.exists() )
+ return;
+ QDateTime dt = finf.lastModified ();
+ if ( dt < loadedFileVersion ) {
+ QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
+ return;
+ }
+ loadedFileVersion = dt;
+}
+
bool CalendarView::checkFileVersion(QString fn)
@@ -1557,3 +1570,3 @@ bool CalendarView::checkFileVersion(QString fn)
return true;
- 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)) ,
+ 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)) ,
i18n("KO/Pi Warning"),i18n("Overwrite"),
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index a3315ad..355bb84 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -174,2 +174,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
public slots:
+ void watchSavedFile();
void recheckTimerAlarm();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 1c4a186..6315c64 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1410,2 +1410,3 @@ void MainWindow::save()
qDebug("KO: Start saving data to file!");
+ mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
mView->saveCalendar( defaultFileName() );
@@ -1413,3 +1414,3 @@ void MainWindow::save()
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
- mView->setLoadedFileVersion(QDateTime::currentDateTime());
+ mView->watchSavedFile();
qDebug("KO: Needed %d ms for saving.",msNeeded );