Skip to content
Permalink
Browse files

Start on recent item proxy handling

  • Loading branch information
nyalldawson committed Jul 8, 2018
1 parent 2efc08e commit 9de2cc3ce47fe60064c1cf829c1cf9a30b7c8360
Showing with 19 additions and 2 deletions.
  1. +5 −1 src/gui/processing/qgsprocessingtoolboxmodel.cpp
  2. +14 −1 tests/src/gui/testqgsprocessingmodel.cpp
@@ -720,7 +720,11 @@ bool QgsProcessingToolboxProxyModel::lessThan( const QModelIndex &left, const QM
QgsProcessingToolboxModelNode::NodeType leftType = static_cast< QgsProcessingToolboxModelNode::NodeType >( sourceModel()->data( left, QgsProcessingToolboxModel::RoleNodeType ).toInt() );
QgsProcessingToolboxModelNode::NodeType rightType = static_cast< QgsProcessingToolboxModelNode::NodeType >( sourceModel()->data( right, QgsProcessingToolboxModel::RoleNodeType ).toInt() );

if ( leftType != rightType )
if ( leftType == QgsProcessingToolboxModelNode::NodeRecent )
return true;
else if ( rightType == QgsProcessingToolboxModelNode::NodeRecent )
return false;
else if ( leftType != rightType )
{
if ( leftType == QgsProcessingToolboxModelNode::NodeProvider )
return false;
@@ -382,8 +382,14 @@ void TestQgsProcessingModel::testModel()

void TestQgsProcessingModel::testProxyModel()
{
QgsSettings().clear();
QgsProcessingRegistry registry;
QgsProcessingToolboxProxyModel model( nullptr, &registry );
QgsProcessingRecentAlgorithmLog recentLog;
QgsProcessingToolboxProxyModel model( nullptr, &registry, &recentLog );

#ifdef ENABLE_MODELTEST
new ModelTest( &model, this ); // for model validity checking
#endif

// add a provider
DummyAlgorithm *a1 = new DummyAlgorithm( "a1", "group2", QgsProcessingAlgorithm::FlagHideFromModeler );
@@ -510,6 +516,13 @@ void TestQgsProcessingModel::testProxyModel()
QCOMPARE( model.data( model.index( 0, 0, group2Index ), QgsProcessingToolboxModel::RoleAlgorithmId ).toString(), QStringLiteral( "p2:a1" ) );

model.setFilterString( QString() );
QCOMPARE( model.rowCount(), 4 );

// check sort order of recent algorithms
recentLog.push( QStringLiteral( "qgis:a1" ) );
QCOMPARE( model.rowCount(), 5 );
QModelIndex recentIndex = model.index( 0, 0, QModelIndex() );
QCOMPARE( model.data( recentIndex, Qt::DisplayRole ).toString(), QStringLiteral( "Recently used" ) );

// inactive provider - should not be visible
QCOMPARE( model.rowCount(), 4 );

0 comments on commit 9de2cc3

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