17#include "moc_qgsprocessingtoolboxtreeview.cpp"
24QgsProcessingToolboxTreeView::QgsProcessingToolboxTreeView( QWidget *parent,
QgsProcessingRegistry *registry, QgsProcessingRecentAlgorithmLog *recentLog, QgsProcessingFavoriteAlgorithmManager *favoriteManager )
28 mToolboxModel = mModel->toolboxModel();
32void QgsProcessingToolboxTreeView::setRegistry(
QgsProcessingRegistry *registry, QgsProcessingRecentAlgorithmLog *recentLog, QgsProcessingFavoriteAlgorithmManager *favoriteManager )
37 mModel->deleteLater();
45 mModel->deleteLater();
49void QgsProcessingToolboxTreeView::setFilterString(
const QString &filter )
51 const QString text = filter.trimmed().toLower();
53 if ( !text.isEmpty() )
56 if ( !selectedAlgorithm() )
59 const QModelIndex firstVisibleIndex = findFirstVisibleAlgorithm( QModelIndex() );
60 if ( firstVisibleIndex.isValid() )
61 selectionModel()->setCurrentIndex( firstVisibleIndex, QItemSelectionModel::ClearAndSelect );
72 const QModelIndex sourceIndex = mModel->mapToSource( index );
73 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
74 return mToolboxModel->algorithmForIndex( sourceIndex );
81 if ( selectionModel()->hasSelection() )
83 const QModelIndex index = selectionModel()->selectedIndexes().at( 0 );
84 return algorithmForIndex( index );
94 mModel->setFilters( filters );
99 return mModel->filters();
102void QgsProcessingToolboxTreeView::setInPlaceLayer(
QgsVectorLayer *layer )
104 mModel->setInPlaceLayer( layer );
107QModelIndex QgsProcessingToolboxTreeView::findFirstVisibleAlgorithm(
const QModelIndex &parent )
109 for (
int r = 0; r < mModel->rowCount( parent ); ++r )
111 QModelIndex proxyIndex = mModel->index( r, 0, parent );
112 const QModelIndex sourceIndex = mModel->mapToSource( proxyIndex );
113 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
116 QModelIndex index = findFirstVisibleAlgorithm( proxyIndex );
117 if ( index.isValid() )
120 return QModelIndex();
123void QgsProcessingToolboxTreeView::keyPressEvent( QKeyEvent *event )
125 if ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter )
126 emit doubleClicked( currentIndex() );
128 QTreeView::keyPressEvent( event );
Abstract base class for processing algorithms.
Registry for various processing components, including providers, algorithms and various parameters an...
Represents a vector layer which manages a vector based data sets.