@@ -513,6 +513,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
513
513
, mpTileScaleWidget( 0 )
514
514
, mpGpsWidget( 0 )
515
515
, mSnappingUtils ( 0 )
516
+ , mProjectLastModified ()
516
517
{
517
518
if ( smInstance )
518
519
{
@@ -916,6 +917,7 @@ QgisApp::QgisApp()
916
917
, mVectorLayerTools ( 0 )
917
918
, mBtnFilterLegend ( 0 )
918
919
, mSnappingUtils ( 0 )
920
+ , mProjectLastModified ()
919
921
{
920
922
smInstance = this ;
921
923
setupUi ( this );
@@ -3599,6 +3601,8 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
3599
3601
}
3600
3602
}
3601
3603
3604
+ mProjectLastModified = QDateTime ();
3605
+
3602
3606
QSettings settings;
3603
3607
3604
3608
closeProject ();
@@ -3989,7 +3993,7 @@ bool QgisApp::addProject( QString projectFile )
3989
3993
// close the previous opened project if any
3990
3994
closeProject ();
3991
3995
3992
- if ( ! QgsProject::instance ()->read ( projectFile ) )
3996
+ if ( !QgsProject::instance ()->read ( projectFile ) )
3993
3997
{
3994
3998
QApplication::restoreOverrideCursor ();
3995
3999
statusBar ()->clearMessage ();
@@ -4004,6 +4008,8 @@ bool QgisApp::addProject( QString projectFile )
4004
4008
return false ;
4005
4009
}
4006
4010
4011
+ mProjectLastModified = pfi.lastModified ();
4012
+
4007
4013
setTitleBarText_ ( *this );
4008
4014
int myRedInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorRedPart" , 255 );
4009
4015
int myGreenInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorGreenPart" , 255 );
@@ -4123,6 +4129,19 @@ bool QgisApp::fileSave()
4123
4129
else
4124
4130
{
4125
4131
QFileInfo fi ( QgsProject::instance ()->fileName () );
4132
+ if ( fi.exists () && !mProjectLastModified .isNull () && mProjectLastModified != fi.lastModified () )
4133
+ {
4134
+ if ( QMessageBox::warning ( this ,
4135
+ tr ( " Project file was changed" ),
4136
+ tr ( " The loaded project file on disk was meanwhile changed. Do you want to overwrite the changes?\n "
4137
+ " \n Last modification date on load was: %1"
4138
+ " \n Current last modification date is: %2" )
4139
+ .arg ( mProjectLastModified .toString ( Qt::DefaultLocaleLongDate ) )
4140
+ .arg ( fi.lastModified ().toString ( Qt::DefaultLocaleLongDate ) ),
4141
+ QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
4142
+ return false ;
4143
+ }
4144
+
4126
4145
if ( fi.exists () && ! fi.isWritable () )
4127
4146
{
4128
4147
messageBar ()->pushMessage ( tr ( " Insufficient permissions" ),
@@ -4143,6 +4162,9 @@ bool QgisApp::fileSave()
4143
4162
QSettings settings;
4144
4163
saveRecentProjectPath ( fullPath.filePath (), settings );
4145
4164
}
4165
+
4166
+ QFileInfo fi ( QgsProject::instance ()->fileName () );
4167
+ mProjectLastModified = fi.lastModified ();
4146
4168
}
4147
4169
else
4148
4170
{
0 commit comments