17#include "moc_qgsprocessingtoolboxtreeview.cpp"
24QgsProcessingToolboxTreeView::QgsProcessingToolboxTreeView( QWidget *parent,
26 QgsProcessingRecentAlgorithmLog *recentLog,
27 QgsProcessingFavoriteAlgorithmManager *favoriteManager )
31 mToolboxModel = mModel->toolboxModel();
35void QgsProcessingToolboxTreeView::setRegistry(
QgsProcessingRegistry *registry, QgsProcessingRecentAlgorithmLog *recentLog, QgsProcessingFavoriteAlgorithmManager *favoriteManager )
40 mModel->deleteLater();
48 mModel->deleteLater();
52void QgsProcessingToolboxTreeView::setFilterString(
const QString &filter )
54 const QString text = filter.trimmed().toLower();
56 if ( !text.isEmpty() )
59 if ( !selectedAlgorithm() )
62 const QModelIndex firstVisibleIndex = findFirstVisibleAlgorithm( QModelIndex() );
63 if ( firstVisibleIndex.isValid() )
64 selectionModel()->setCurrentIndex( firstVisibleIndex, QItemSelectionModel::ClearAndSelect );
75 const QModelIndex sourceIndex = mModel->mapToSource( index );
76 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
77 return mToolboxModel->algorithmForIndex( sourceIndex );
84 if ( selectionModel()->hasSelection() )
86 const QModelIndex index = selectionModel()->selectedIndexes().at( 0 );
87 return algorithmForIndex( index );
97 mModel->setFilters( filters );
102 return mModel->filters();
105void QgsProcessingToolboxTreeView::setInPlaceLayer(
QgsVectorLayer *layer )
107 mModel->setInPlaceLayer( layer );
110QModelIndex QgsProcessingToolboxTreeView::findFirstVisibleAlgorithm(
const QModelIndex &parent )
112 for (
int r = 0; r < mModel->rowCount( parent ); ++r )
114 QModelIndex proxyIndex = mModel->index( r, 0, parent );
115 const QModelIndex sourceIndex = mModel->mapToSource( proxyIndex );
116 if ( mToolboxModel->isAlgorithm( sourceIndex ) )
119 QModelIndex index = findFirstVisibleAlgorithm( proxyIndex );
120 if ( index.isValid() )
123 return QModelIndex();
126void QgsProcessingToolboxTreeView::keyPressEvent( QKeyEvent *event )
128 if ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter )
129 emit doubleClicked( currentIndex() );
131 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.