Skip to content
Permalink
Browse files

Save non-pinned recent projects below pinned ones

  • Loading branch information
nirvn committed Nov 16, 2017
1 parent 3fd32b4 commit 4420eba61c035df3b1dac73a18083990e20f0a87
Showing with 19 additions and 6 deletions.
  1. +19 −6 src/app/qgisapp.cpp
@@ -3891,19 +3891,32 @@ void QgisApp::saveRecentProjectPath( const QString &projectPath, bool savePrevie
projectData.previewImagePath = mRecentProjects.at( idx ).previewImagePath;
}

// If this file is already in the list, remove it
mRecentProjects.removeAll( projectData );

// Prepend this file to the list
mRecentProjects.prepend( projectData );

// Count the number of pinned items, those shouldn't affect trimming
int pinnedCount = 0;
int nonPinnedPos = 0;
bool pinnedTop = true;
Q_FOREACH ( const QgsWelcomePageItemsModel::RecentProjectData &recentProject, mRecentProjects )
{
if ( recentProject.pin )
{
pinnedCount++;
if ( pinnedTop )
{
nonPinnedPos++;
}
}
else if ( pinnedTop )
{
pinnedTop = false;
}
}

// If this file is already in the list, remove it
mRecentProjects.removeAll( projectData );

// Insert this file to the list
mRecentProjects.insert( projectData.pin ? 0 : nonPinnedPos, projectData );

// Keep the list to 10 items by trimming excess off the bottom
// And remove the associated image
while ( mRecentProjects.count() > 10 + pinnedCount )

0 comments on commit 4420eba

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