23 QgsProcessingToolboxTreeView::QgsProcessingToolboxTreeView( QWidget *parent,
25 QgsProcessingRecentAlgorithmLog *recentLog )
29 mToolboxModel = mModel->toolboxModel();
33 void QgsProcessingToolboxTreeView::setRegistry(
QgsProcessingRegistry *registry, QgsProcessingRecentAlgorithmLog *recentLog )
38 mModel->deleteLater();
46 mModel->deleteLater();
50 void QgsProcessingToolboxTreeView::setFilterString(
const QString &filter )
52 const QString text = filter.trimmed().toLower();
54 if ( !text.isEmpty() )
57 if ( !selectedAlgorithm() )
60 const QModelIndex firstVisibleIndex = findFirstVisibleAlgorithm( QModelIndex() );
61 if ( firstVisibleIndex.isValid() )
62 selectionModel()->setCurrentIndex( firstVisibleIndex, QItemSelectionModel::ClearAndSelect );
73 const QModelIndex sourceIndex = mModel->mapToSource( index );
74 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
75 return mToolboxModel->algorithmForIndex( sourceIndex );
82 if ( selectionModel()->hasSelection() )
84 const QModelIndex index = selectionModel()->selectedIndexes().at( 0 );
85 return algorithmForIndex( index );
93 void QgsProcessingToolboxTreeView::setFilters( QgsProcessingToolboxProxyModel::Filters filters )
95 mModel->setFilters( filters );
98 QgsProcessingToolboxProxyModel::Filters QgsProcessingToolboxTreeView::filters()
const
100 return mModel->filters();
103 void QgsProcessingToolboxTreeView::setInPlaceLayer(
QgsVectorLayer *layer )
105 mModel->setInPlaceLayer( layer );
108 QModelIndex QgsProcessingToolboxTreeView::findFirstVisibleAlgorithm(
const QModelIndex &parent )
110 for (
int r = 0; r < mModel->rowCount( parent ); ++r )
112 QModelIndex proxyIndex = mModel->index( r, 0, parent );
113 const QModelIndex sourceIndex = mModel->mapToSource( proxyIndex );
114 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
117 QModelIndex index = findFirstVisibleAlgorithm( proxyIndex );
118 if ( index.isValid() )
121 return QModelIndex();
124 void QgsProcessingToolboxTreeView::keyPressEvent( QKeyEvent *event )
126 if ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter )
127 emit doubleClicked( currentIndex() );
129 QTreeView::keyPressEvent( event );