File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -151,3 +151,24 @@ void QgsPluginSortFilterProxyModel::sortPluginsByStatus()
151
151
sort ( 0 , Qt::DescendingOrder );
152
152
setSortRole ( PLUGIN_STATUS_ROLE );
153
153
}
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
+ }
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ class QgsPluginSortFilterProxyModel : public QSortFilterProxyModel
70
70
// ! The main filter method
71
71
bool filterAcceptsRow ( int sourceRow, const QModelIndex &sourceParent ) const override ;
72
72
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
+
73
76
private:
74
77
QStringList mAcceptedStatuses ;
75
78
QString mAcceptedSpacers ;
You can’t perform that action at this time.
0 commit comments