Skip to content

Commit

Permalink
Move deprecated plugins to the list bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
borysiasty committed Sep 14, 2018
1 parent 05c9e01 commit d838d63
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp
Expand Up @@ -151,3 +151,24 @@ void QgsPluginSortFilterProxyModel::sortPluginsByStatus()
sort( 0, Qt::DescendingOrder );
setSortRole( PLUGIN_STATUS_ROLE );
}



bool QgsPluginSortFilterProxyModel::lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const
{
// Always move deprecated plugins to bottom, regardless of the sort order.
const bool isLeftDepreciated = sourceModel()->data( source_left, PLUGIN_ISDEPRECATED_ROLE ).toString() == QStringLiteral( "true" );
const bool isRightDepreciated = sourceModel()->data( source_right, PLUGIN_ISDEPRECATED_ROLE ).toString() == QStringLiteral( "true" );
if ( isRightDepreciated && !isLeftDepreciated )
{
return sortOrder() == Qt::AscendingOrder ? true : false;
}
else if ( isLeftDepreciated && !isRightDepreciated )
{
return sortOrder() == Qt::AscendingOrder ? false : true;
}
else
{
return QSortFilterProxyModel::lessThan( source_left, source_right );
}
}
3 changes: 3 additions & 0 deletions src/app/pluginmanager/qgspluginsortfilterproxymodel.h
Expand Up @@ -70,6 +70,9 @@ class QgsPluginSortFilterProxyModel : public QSortFilterProxyModel
//! The main filter method
bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;

//! The sort method overwritten in order to always display deprecated plugins last.
bool lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const override;

private:
QStringList mAcceptedStatuses;
QString mAcceptedSpacers;
Expand Down

0 comments on commit d838d63

Please sign in to comment.