Skip to content

Commit 4420eba

Browse files
committed
Save non-pinned recent projects below pinned ones
1 parent 3fd32b4 commit 4420eba

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/app/qgisapp.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,19 +3891,32 @@ void QgisApp::saveRecentProjectPath( const QString &projectPath, bool savePrevie
38913891
projectData.previewImagePath = mRecentProjects.at( idx ).previewImagePath;
38923892
}
38933893

3894-
// If this file is already in the list, remove it
3895-
mRecentProjects.removeAll( projectData );
3896-
3897-
// Prepend this file to the list
3898-
mRecentProjects.prepend( projectData );
3899-
39003894
// Count the number of pinned items, those shouldn't affect trimming
39013895
int pinnedCount = 0;
3896+
int nonPinnedPos = 0;
3897+
bool pinnedTop = true;
39023898
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData &recentProject, mRecentProjects )
39033899
{
39043900
if ( recentProject.pin )
3901+
{
39053902
pinnedCount++;
3903+
if ( pinnedTop )
3904+
{
3905+
nonPinnedPos++;
3906+
}
3907+
}
3908+
else if ( pinnedTop )
3909+
{
3910+
pinnedTop = false;
3911+
}
39063912
}
3913+
3914+
// If this file is already in the list, remove it
3915+
mRecentProjects.removeAll( projectData );
3916+
3917+
// Insert this file to the list
3918+
mRecentProjects.insert( projectData.pin ? 0 : nonPinnedPos, projectData );
3919+
39073920
// Keep the list to 10 items by trimming excess off the bottom
39083921
// And remove the associated image
39093922
while ( mRecentProjects.count() > 10 + pinnedCount )

0 commit comments

Comments
 (0)