Skip to content
Permalink
Browse files

Merge pull request #7906 from borysiasty/deprecated_plugins_grayed_out

[Plugin manager] Deprecated plugins grayed out and moved to the list bottom
  • Loading branch information
borysiasty committed Sep 18, 2018
2 parents e52dc86 + 840749c commit 5edb326ab273eb65c55dda9478a940be74134090
@@ -77,6 +77,10 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem
{
painter->setPen( option.palette.highlightedText().color() );
}
else if ( index.data( PLUGIN_ISDEPRECATED_ROLE ).toString() == QLatin1String( "true" ) )
{
painter->setPen( option.palette.color( QPalette::Disabled, QPalette::Text ) );
}
else
{
painter->setPen( option.palette.text().color() );
@@ -538,6 +538,7 @@ void QgsPluginManager::reloadModelData()
mypDetailItem->setData( it->value( QStringLiteral( "tags" ) ), PLUGIN_TAGS_ROLE );
mypDetailItem->setData( it->value( QStringLiteral( "downloads" ) ).rightJustified( 10, '0' ), PLUGIN_DOWNLOADS_ROLE );
mypDetailItem->setData( it->value( QStringLiteral( "average_vote" ) ), PLUGIN_VOTE_ROLE );
mypDetailItem->setData( it->value( QStringLiteral( "deprecated" ) ), PLUGIN_ISDEPRECATED_ROLE );

if ( QFileInfo( iconPath ).isFile() )
{
@@ -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 );
}
}
@@ -29,6 +29,7 @@ const int PLUGIN_ERROR_ROLE = Qt::UserRole + 5; // for filtering
const int PLUGIN_STATUS_ROLE = Qt::UserRole + 6; // for filtering and sorting
const int PLUGIN_DOWNLOADS_ROLE = Qt::UserRole + 7; // for sorting
const int PLUGIN_VOTE_ROLE = Qt::UserRole + 8; // for sorting
const int PLUGIN_ISDEPRECATED_ROLE = Qt::UserRole + 9; // for styling
const int SPACER_ROLE = Qt::UserRole + 20; // for sorting


@@ -68,6 +69,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 5edb326

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