Skip to content

Commit

Permalink
Recent projects work now for postgres projects
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 7, 2018
1 parent 15f7ec7 commit 3c3de3f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ static void setTitleBarText_( QWidget &qgisApp )
}
else
{
QFileInfo projectFileInfo( QgsProject::instance()->fileName() );
caption = projectFileInfo.completeBaseName();
caption = QgsProject::instance()->baseName();
}
}
else
Expand Down Expand Up @@ -3964,19 +3963,20 @@ void QgisApp::updateRecentProjectPaths()
} // QgisApp::updateRecentProjectPaths

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

// Get canonical absolute path
QFileInfo myFileInfo( projectPath );
QgsWelcomePageItemsModel::RecentProjectData projectData;
projectData.path = myFileInfo.absoluteFilePath();
projectData.path = QgsProject::instance()->absoluteFilePath();
if ( projectData.path.isEmpty() ) // in case of custom project storage
projectData.path = QgsProject::instance()->fileName();
projectData.title = QgsProject::instance()->title();
if ( projectData.title.isEmpty() )
projectData.title = projectData.path;
projectData.title = QgsProject::instance()->baseName();

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

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

// add this to the list of recently used project files
saveRecentProjectPath( projectFile, false );
saveRecentProjectPath( false );

QApplication::restoreOverrideCursor();

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

saveRecentProjectPath( fullPath.filePath() );
saveRecentProjectPath();

QFileInfo fi( QgsProject::instance()->fileName() );
mProjectLastModified = fi.lastModified();
Expand Down Expand Up @@ -5827,7 +5827,7 @@ void QgisApp::fileSaveAs()
setTitleBarText_( *this ); // update title bar
mStatusBar->showMessage( tr( "Saved project to: %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), 5000 );
// add this to the list of recently used project files
saveRecentProjectPath( fullPath.filePath() );
saveRecentProjectPath();
mProjectLastModified = fullPath.lastModified();
}
else
Expand Down Expand Up @@ -13582,7 +13582,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, bool saving )
setTitleBarText_( *this ); // update title bar
mStatusBar->showMessage( tr( "Saved project to: %1" ).arg( uri ), 5000 );
// add this to the list of recently used project files
saveRecentProjectPath( uri );
saveRecentProjectPath();
mProjectLastModified = QgsProject::instance()->lastModified();
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1743,13 +1743,13 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
bool guiUpdate );

/**
* Add this file to the recently opened/saved projects list
* Add thie current project to the recently opened/saved projects list
* pass settings by reference since creating more than one
* instance simultaneously results in data loss.
*
* \param savePreviewImage Set to false when the preview image should not be saved. E.g. project load.
*/
void saveRecentProjectPath( const QString &projectPath, bool savePreviewImage = true );
void saveRecentProjectPath( bool savePreviewImage = true );
//! Save recent projects list to settings
void saveRecentProjects();
//! Update project menu with the current list of recently accessed projects
Expand Down
10 changes: 9 additions & 1 deletion src/app/qgswelcomepageitemsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
***************************************************************************/

#include "qgswelcomepageitemsmodel.h"

#include "qgsapplication.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsmessagelog.h"
#include "qgsprojectstorageregistry.h"

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

Expand Down

0 comments on commit 3c3de3f

Please sign in to comment.