21 QgsProcessingToolboxTreeView::QgsProcessingToolboxTreeView( QWidget *parent,
23 QgsProcessingRecentAlgorithmLog *recentLog )
27 mToolboxModel = mModel->toolboxModel();
31 void QgsProcessingToolboxTreeView::setRegistry(
QgsProcessingRegistry *registry, QgsProcessingRecentAlgorithmLog *recentLog )
36 mModel->deleteLater();
44 mModel->deleteLater();
48 void QgsProcessingToolboxTreeView::setFilterString(
const QString &filter )
50 const QString text = filter.trimmed().toLower();
52 if ( !text.isEmpty() )
55 if ( !selectedAlgorithm() )
58 QModelIndex firstVisibleIndex = findFirstVisibleAlgorithm( QModelIndex() );
59 if ( firstVisibleIndex.isValid() )
60 selectionModel()->setCurrentIndex( firstVisibleIndex, QItemSelectionModel::ClearAndSelect );
71 QModelIndex sourceIndex = mModel->mapToSource( index );
72 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
73 return mToolboxModel->algorithmForIndex( sourceIndex );
80 if ( selectionModel()->hasSelection() )
82 QModelIndex index = selectionModel()->selectedIndexes().at( 0 );
83 return algorithmForIndex( index );
91 void QgsProcessingToolboxTreeView::setFilters( QgsProcessingToolboxProxyModel::Filters filters )
93 mModel->setFilters( filters );
96 QgsProcessingToolboxProxyModel::Filters QgsProcessingToolboxTreeView::filters()
const
98 return mModel->filters();
101 void QgsProcessingToolboxTreeView::setInPlaceLayer(
QgsVectorLayer *layer )
103 mModel->setInPlaceLayer( layer );
106 QModelIndex QgsProcessingToolboxTreeView::findFirstVisibleAlgorithm(
const QModelIndex &parent )
108 for (
int r = 0; r < mModel->rowCount( parent ); ++r )
110 QModelIndex proxyIndex = mModel->index( r, 0, parent );
111 QModelIndex sourceIndex = mModel->mapToSource( proxyIndex );
112 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
115 QModelIndex index = findFirstVisibleAlgorithm( proxyIndex );
116 if ( index.isValid() )
119 return QModelIndex();