mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Recent projects work now for postgres projects
This commit is contained in:
parent
15f7ec7854
commit
3c3de3f7d8
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user