Skip to content

Commit f082aa5

Browse files
committedSep 1, 2015
Don't delete recent projects for QGIS <=2.10 from settings
1 parent e95bf6d commit f082aa5

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,22 +1154,28 @@ void QgisApp::readSettings()
11541154
// Read legacy settings
11551155
mRecentProjects.clear();
11561156

1157-
QStringList oldRecentProjects = settings.value( "/UI/recentProjectsList" ).toStringList();
1158-
settings.remove( "/UI/recentProjectsList" );
1157+
settings.beginGroup( "/UI" );
11591158

1160-
Q_FOREACH( const QString& project, oldRecentProjects )
1159+
// Migrate old recent projects if first time with new system
1160+
if ( !settings.childGroups().contains( "recentProjects" ) )
11611161
{
1162-
QgsWelcomePageItemsModel::RecentProjectData data;
1163-
data.path = project;
1164-
data.title = project;
1162+
QStringList oldRecentProjects = settings.value( "/UI/recentProjectsList" ).toStringList();
11651163

1166-
mRecentProjects.append( data );
1164+
Q_FOREACH ( const QString& project, oldRecentProjects )
1165+
{
1166+
QgsWelcomePageItemsModel::RecentProjectData data;
1167+
data.path = project;
1168+
data.title = project;
1169+
1170+
mRecentProjects.append( data );
1171+
}
11671172
}
1173+
settings.endGroup();
11681174

11691175
settings.beginGroup( "/UI/recentProjects" );
11701176
QStringList projectKeys = settings.childGroups();
11711177

1172-
Q_FOREACH( const QString& key, projectKeys )
1178+
Q_FOREACH ( const QString& key, projectKeys )
11731179
{
11741180
QgsWelcomePageItemsModel::RecentProjectData data;
11751181
settings.beginGroup( key );
@@ -2747,7 +2753,7 @@ void QgisApp::updateRecentProjectPaths()
27472753
{
27482754
mRecentProjectsMenu->clear();
27492755

2750-
Q_FOREACH( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2756+
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
27512757
{
27522758
QAction* action = mRecentProjectsMenu->addAction( QString( "%1 (%2)" ).arg( recentProject.title ).arg( recentProject.path ) );
27532759
action->setEnabled( QFile::exists(( recentProject.path ) ) );
@@ -2816,7 +2822,7 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
28162822
int idx = 0;
28172823

28182824
// Persist the list
2819-
Q_FOREACH( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
2825+
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData& recentProject, mRecentProjects )
28202826
{
28212827
++idx;
28222828
settings.beginGroup( QString( "/UI/recentProjects/%1" ).arg( idx ) );

0 commit comments

Comments
 (0)
Please sign in to comment.