Skip to content
Permalink
Browse files

Move deprecated plugins to the list bottom

  • Loading branch information
borysiasty committed Sep 14, 2018
1 parent 05c9e01 commit d838d63e1fedbef898c6022b2ef8978cd2c337f7
@@ -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 );
}
}
@@ -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;

0 comments on commit d838d63

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