Skip to content

Commit 3c3de3f

Browse files
committedApr 7, 2018
Recent projects work now for postgres projects
1 parent 15f7ec7 commit 3c3de3f

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ static void setTitleBarText_( QWidget &qgisApp )
468468
}
469469
else
470470
{
471-
QFileInfo projectFileInfo( QgsProject::instance()->fileName() );
472-
caption = projectFileInfo.completeBaseName();
471+
caption = QgsProject::instance()->baseName();
473472
}
474473
}
475474
else
@@ -3964,19 +3963,20 @@ void QgisApp::updateRecentProjectPaths()
39643963
} // QgisApp::updateRecentProjectPaths
39653964

39663965
// add this file to the recently opened/saved projects list
3967-
void QgisApp::saveRecentProjectPath( const QString &projectPath, bool savePreviewImage )
3966+
void QgisApp::saveRecentProjectPath( bool savePreviewImage )
39683967
{
39693968
// first, re-read the recent project paths. This prevents loss of recent
39703969
// projects when multiple QGIS sessions are open
39713970
readRecentProjects();
39723971

39733972
// Get canonical absolute path
3974-
QFileInfo myFileInfo( projectPath );
39753973
QgsWelcomePageItemsModel::RecentProjectData projectData;
3976-
projectData.path = myFileInfo.absoluteFilePath();
3974+
projectData.path = QgsProject::instance()->absoluteFilePath();
3975+
if ( projectData.path.isEmpty() ) // in case of custom project storage
3976+
projectData.path = QgsProject::instance()->fileName();
39773977
projectData.title = QgsProject::instance()->title();
39783978
if ( projectData.title.isEmpty() )
3979-
projectData.title = projectData.path;
3979+
projectData.title = QgsProject::instance()->baseName();
39803980

39813981
projectData.crs = QgsProject::instance()->crs().authid();
39823982

@@ -5681,7 +5681,7 @@ bool QgisApp::addProject( const QString &projectFile )
56815681
// specific plug-in state
56825682

56835683
// add this to the list of recently used project files
5684-
saveRecentProjectPath( projectFile, false );
5684+
saveRecentProjectPath( false );
56855685

56865686
QApplication::restoreOverrideCursor();
56875687

@@ -5767,7 +5767,7 @@ bool QgisApp::fileSave()
57675767
setTitleBarText_( *this ); // update title bar
57685768
mStatusBar->showMessage( tr( "Saved project to: %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), 5000 );
57695769

5770-
saveRecentProjectPath( fullPath.filePath() );
5770+
saveRecentProjectPath();
57715771

57725772
QFileInfo fi( QgsProject::instance()->fileName() );
57735773
mProjectLastModified = fi.lastModified();
@@ -5827,7 +5827,7 @@ void QgisApp::fileSaveAs()
58275827
setTitleBarText_( *this ); // update title bar
58285828
mStatusBar->showMessage( tr( "Saved project to: %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), 5000 );
58295829
// add this to the list of recently used project files
5830-
saveRecentProjectPath( fullPath.filePath() );
5830+
saveRecentProjectPath();
58315831
mProjectLastModified = fullPath.lastModified();
58325832
}
58335833
else
@@ -13582,7 +13582,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, bool saving )
1358213582
setTitleBarText_( *this ); // update title bar
1358313583
mStatusBar->showMessage( tr( "Saved project to: %1" ).arg( uri ), 5000 );
1358413584
// add this to the list of recently used project files
13585-
saveRecentProjectPath( uri );
13585+
saveRecentProjectPath();
1358613586
mProjectLastModified = QgsProject::instance()->lastModified();
1358713587
}
1358813588
else

‎src/app/qgisapp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,13 +1743,13 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
17431743
bool guiUpdate );
17441744

17451745
/**
1746-
* Add this file to the recently opened/saved projects list
1746+
* Add thie current project to the recently opened/saved projects list
17471747
* pass settings by reference since creating more than one
17481748
* instance simultaneously results in data loss.
17491749
*
17501750
* \param savePreviewImage Set to false when the preview image should not be saved. E.g. project load.
17511751
*/
1752-
void saveRecentProjectPath( const QString &projectPath, bool savePreviewImage = true );
1752+
void saveRecentProjectPath( bool savePreviewImage = true );
17531753
//! Save recent projects list to settings
17541754
void saveRecentProjects();
17551755
//! Update project menu with the current list of recently accessed projects

‎src/app/qgswelcomepageitemsmodel.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
***************************************************************************/
1515

1616
#include "qgswelcomepageitemsmodel.h"
17+
18+
#include "qgsapplication.h"
1719
#include "qgscoordinatereferencesystem.h"
1820
#include "qgsmessagelog.h"
21+
#include "qgsprojectstorageregistry.h"
1922

2023
#include <QApplication>
2124
#include <QAbstractTextDocumentLayout>
@@ -211,7 +214,12 @@ Qt::ItemFlags QgsWelcomePageItemsModel::flags( const QModelIndex &index ) const
211214
// This check can be slow for network based projects, so only run it the first time
212215
if ( !projectData.checkedExists )
213216
{
214-
projectData.exists = QFile::exists( ( projectData.path ) );
217+
if ( QgsApplication::projectStorageRegistry()->projectStorageFromUri( projectData.path ) )
218+
// we could check whether a project exists in a custom project storage by checking its metadata,
219+
// but that may be slow (e.g. doing some network queries) so for now we always assume such projects exist
220+
projectData.exists = true;
221+
else
222+
projectData.exists = QFile::exists( ( projectData.path ) );
215223
projectData.checkedExists = true;
216224
}
217225

0 commit comments

Comments
 (0)
Please sign in to comment.