-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
810cb9c
commit 101c98f
Showing
9 changed files
with
317 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
python/gui/auto_generated/processing/qgsprocessingtoolboxtreeview.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/processing/qgsprocessingtoolboxtreeview.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsProcessingToolboxTreeView : QTreeView | ||
{ | ||
%Docstring | ||
Processing toolbox tree view, showing algorithms and providers in a tree structure. | ||
|
||
.. versionadded:: 3.4 | ||
|
||
.. warning:: | ||
|
||
Not part of stable API and may change in future QGIS releases. | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprocessingtoolboxtreeview.h" | ||
%End | ||
public: | ||
|
||
QgsProcessingToolboxTreeView( QWidget *parent /TransferThis/ = 0, | ||
QgsProcessingRegistry *registry = 0, | ||
QgsProcessingRecentAlgorithmLog *recentLog = 0 ); | ||
%Docstring | ||
Constructor for QgsProcessingToolboxTreeView, with the specified ``parent`` widget. | ||
|
||
If ``registry`` is set, then the view will automatically be populated with algorithms | ||
and providers from the registry. Otherwise, users must manually call setRegistry() | ||
to associate a registry with the view. | ||
|
||
If \recentLog is specified then it will be used to create a "Recently used" top | ||
level group containing recently used algorithms. | ||
%End | ||
|
||
void setRegistry( | ||
QgsProcessingRegistry *registry, | ||
QgsProcessingRecentAlgorithmLog *recentLog = 0 ); | ||
%Docstring | ||
Sets the processing ``registry`` associated with the view. | ||
|
||
If \recentLog is specified then it will be used to create a "Recently used" top | ||
level group containing recently used algorithms. | ||
%End | ||
|
||
const QgsProcessingAlgorithm *algorithmForIndex( const QModelIndex &index ); | ||
%Docstring | ||
Returns the algorithm at the specified tree view ``index``, or a None | ||
if the index does not correspond to an algorithm. | ||
%End | ||
|
||
const QgsProcessingAlgorithm *selectedAlgorithm(); | ||
%Docstring | ||
Returns the currently selected algorithm in the tree view, or a None | ||
if no algorithm is currently selected. | ||
%End | ||
|
||
void setFilters( QgsProcessingToolboxProxyModel::Filters filters ); | ||
%Docstring | ||
Sets ``filters`` controlling the view's contents. | ||
%End | ||
|
||
public slots: | ||
|
||
void setFilterString( const QString &filter ); | ||
%Docstring | ||
Sets a ``filter`` string, used to filter out the contents of the view | ||
to matching algorithms. | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/processing/qgsprocessingtoolboxtreeview.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/*************************************************************************** | ||
qgsprocessingtoolboxtreeview.cpp | ||
------------------------------- | ||
begin : July 2018 | ||
copyright : (C) 2018 by Nyall Dawso | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsprocessingtoolboxtreeview.h" | ||
#include "qgsprocessingtoolboxmodel.h" | ||
|
||
QgsProcessingToolboxTreeView::QgsProcessingToolboxTreeView( QWidget *parent, | ||
QgsProcessingRegistry *registry, | ||
QgsProcessingRecentAlgorithmLog *recentLog ) | ||
: QTreeView( parent ) | ||
{ | ||
mModel = new QgsProcessingToolboxProxyModel( this, registry, recentLog ); | ||
mToolboxModel = mModel->toolboxModel(); | ||
setModel( mModel ); | ||
} | ||
|
||
void QgsProcessingToolboxTreeView::setRegistry( QgsProcessingRegistry *registry, QgsProcessingRecentAlgorithmLog *recentLog ) | ||
{ | ||
QgsProcessingToolboxProxyModel *newModel = new QgsProcessingToolboxProxyModel( this, registry, recentLog ); | ||
mToolboxModel = mModel->toolboxModel(); | ||
setModel( newModel ); | ||
mModel->deleteLater(); | ||
mModel = newModel; | ||
} | ||
|
||
void QgsProcessingToolboxTreeView::setFilterString( const QString &filter ) | ||
{ | ||
const QString text = filter.trimmed().toLower(); | ||
mModel->setFilterString( text ); | ||
if ( !text.isEmpty() ) | ||
{ | ||
expandAll(); | ||
if ( !selectedAlgorithm() ) | ||
{ | ||
// if previously selected item was hidden, auto select the first visible algorithm | ||
QModelIndex firstVisibleIndex = findFirstVisibleAlgorithm( QModelIndex() ); | ||
if ( firstVisibleIndex.isValid() ) | ||
selectionModel()->setCurrentIndex( firstVisibleIndex, QItemSelectionModel::ClearAndSelect ); | ||
} | ||
} | ||
else | ||
{ | ||
collapseAll(); | ||
} | ||
} | ||
|
||
const QgsProcessingAlgorithm *QgsProcessingToolboxTreeView::algorithmForIndex( const QModelIndex &index ) | ||
{ | ||
QModelIndex sourceIndex = mModel->mapToSource( index ); | ||
if ( mToolboxModel->isAlgorithm( sourceIndex ) ) | ||
return mToolboxModel->algorithmForIndex( sourceIndex ); | ||
else | ||
return nullptr; | ||
} | ||
|
||
const QgsProcessingAlgorithm *QgsProcessingToolboxTreeView::selectedAlgorithm() | ||
{ | ||
if ( selectionModel()->hasSelection() ) | ||
{ | ||
QModelIndex index = selectionModel()->selectedIndexes().at( 0 ); | ||
return algorithmForIndex( index ); | ||
} | ||
else | ||
{ | ||
return nullptr; | ||
} | ||
} | ||
|
||
void QgsProcessingToolboxTreeView::setFilters( QgsProcessingToolboxProxyModel::Filters filters ) | ||
{ | ||
mModel->setFilters( filters ); | ||
} | ||
|
||
QModelIndex QgsProcessingToolboxTreeView::findFirstVisibleAlgorithm( const QModelIndex &parent ) | ||
{ | ||
for ( int r = 0; r < mModel->rowCount( parent ); ++r ) | ||
{ | ||
QModelIndex proxyIndex = mModel->index( r, 0, parent ); | ||
QModelIndex sourceIndex = mModel->mapToSource( proxyIndex ); | ||
if ( mToolboxModel->isAlgorithm( sourceIndex ) ) | ||
return proxyIndex; | ||
|
||
QModelIndex index = findFirstVisibleAlgorithm( proxyIndex ); | ||
if ( index.isValid() ) | ||
return index; | ||
} | ||
return QModelIndex(); | ||
} | ||
|
Oops, something went wrong.