Skip to content

Commit d838d63

Browse files
committedSep 14, 2018
Move deprecated plugins to the list bottom
1 parent 05c9e01 commit d838d63

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 

‎src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,24 @@ void QgsPluginSortFilterProxyModel::sortPluginsByStatus()
151151
sort( 0, Qt::DescendingOrder );
152152
setSortRole( PLUGIN_STATUS_ROLE );
153153
}
154+
155+
156+
157+
bool QgsPluginSortFilterProxyModel::lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const
158+
{
159+
// Always move deprecated plugins to bottom, regardless of the sort order.
160+
const bool isLeftDepreciated = sourceModel()->data( source_left, PLUGIN_ISDEPRECATED_ROLE ).toString() == QStringLiteral( "true" );
161+
const bool isRightDepreciated = sourceModel()->data( source_right, PLUGIN_ISDEPRECATED_ROLE ).toString() == QStringLiteral( "true" );
162+
if ( isRightDepreciated && !isLeftDepreciated )
163+
{
164+
return sortOrder() == Qt::AscendingOrder ? true : false;
165+
}
166+
else if ( isLeftDepreciated && !isRightDepreciated )
167+
{
168+
return sortOrder() == Qt::AscendingOrder ? false : true;
169+
}
170+
else
171+
{
172+
return QSortFilterProxyModel::lessThan( source_left, source_right );
173+
}
174+
}

‎src/app/pluginmanager/qgspluginsortfilterproxymodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class QgsPluginSortFilterProxyModel : public QSortFilterProxyModel
7070
//! The main filter method
7171
bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
7272

73+
//! The sort method overwritten in order to always display deprecated plugins last.
74+
bool lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const override;
75+
7376
private:
7477
QStringList mAcceptedStatuses;
7578
QString mAcceptedSpacers;

0 commit comments

Comments
 (0)
Please sign in to comment.