Skip to content

Commit

Permalink
Save non-pinned recent projects below pinned ones
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 16, 2017
1 parent 3fd32b4 commit 4420eba
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 4420eba

Please sign in to comment.