Skip to content
Permalink
Browse files

Recent projects work now for postgres projects

  • Loading branch information
wonder-sk committed Apr 7, 2018
1 parent 15f7ec7 commit 3c3de3f7d87d5bb2d9b8d5d2b520814e4562e50c
Showing with 21 additions and 13 deletions.
  1. +10 −10 src/app/qgisapp.cpp
  2. +2 −2 src/app/qgisapp.h
  3. +9 −1 src/app/qgswelcomepageitemsmodel.cpp
@@ -468,8 +468,7 @@ static void setTitleBarText_( QWidget &qgisApp )
}
else
{
QFileInfo projectFileInfo( QgsProject::instance()->fileName() );
caption = projectFileInfo.completeBaseName();
caption = QgsProject::instance()->baseName();
}
}
else
@@ -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();

@@ -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();

@@ -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();
@@ -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
@@ -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
@@ -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
@@ -14,8 +14,11 @@
***************************************************************************/

#include "qgswelcomepageitemsmodel.h"

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

#include <QApplication>
#include <QAbstractTextDocumentLayout>
@@ -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;
}

0 comments on commit 3c3de3f

Please sign in to comment.
You can’t perform that action at this time.