QGIS API Documentation 4.3.0-Master (3b7b3208a79)
Loading...
Searching...
No Matches
qgsmodelviewtoollink.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelviewtoollink.cpp
3 ------------------------------------
4 Date : January 2024
5 Copyright : (C) 2024 Celia Buira
6 Email : celia dot buira at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include <memory>
19
20#include "qgsapplication.h"
21#include "qgsfilterlineedit.h"
22#include "qgsmodelgraphicitem.h"
34
35#include <QHeaderView>
36#include <QString>
37#include <QVBoxLayout>
38
39#include "moc_qgsmodelviewtoollink.cpp"
40
41using namespace Qt::StringLiterals;
42
43
45class PopupToolboxWidget : public QWidget
46{
47 Q_OBJECT
48 public:
49 PopupToolboxWidget( QWidget *parent = nullptr )
50 : QWidget( parent )
51 {
52 QVBoxLayout *layout = new QVBoxLayout();
53 layout->setSpacing( 0 );
54 layout->setContentsMargins( 0, 0, 0, 0 );
55
56 mLineEdit = new QgsFilterLineEdit( this );
57 mLineEdit->setShowSearchIcon( true );
58 mLineEdit->setPlaceholderText( tr( "Search…" ) );
59 mLineEdit->setFocus();
60
61 mToolboxTreeView = new QgsProcessingToolboxTreeView( this );
62 mToolboxTreeView->header()->setVisible( false );
63 mToolboxTreeView->setAlternatingRowColors( true );
64 const QFontMetrics fm( font() );
65 mToolboxTreeView->setFixedSize( fm.horizontalAdvance( 'X' ) * 40, fm.height() * 10 );
66
67 connect( mLineEdit, &QgsFilterLineEdit::textChanged, mToolboxTreeView, &QgsProcessingToolboxTreeView::setFilterString );
68
69 layout->addWidget( mLineEdit );
70 layout->addWidget( mToolboxTreeView );
71
72 setLayout( layout );
73
74 connect( mLineEdit, &QgsFilterLineEdit::returnPressed, this, [this]() { itemSelected(); } );
75 connect( mToolboxTreeView, &QgsProcessingToolboxTreeView::clicked, this, [this]( const QModelIndex & ) { itemSelected(); } );
76 connect( mToolboxTreeView, &QgsProcessingToolboxTreeView::doubleClicked, this, [this]( const QModelIndex & ) { itemSelected(); } );
77 }
78
79 QgsProcessingToolboxTreeView *toolboxView() const { return mToolboxTreeView; }
80
81 signals:
82 void algorithmAdded( const QString &algorithmId );
83 void parameterAdded( const QString &parameterTypeId );
84
85
86 private:
87 QgsFilterLineEdit *mLineEdit = nullptr;
88 QgsProcessingToolboxTreeView *mToolboxTreeView = nullptr;
89
90 void itemSelected()
91 {
92 if ( mToolboxTreeView->selectedAlgorithm() )
93 {
94 emit algorithmAdded( mToolboxTreeView->selectedAlgorithm()->id() );
95 close();
96 }
97 if ( mToolboxTreeView->selectedParameterType() )
98 {
99 emit parameterAdded( mToolboxTreeView->selectedParameterType()->id() );
100 close();
101 }
102 }
103};
104
105// For PopupToolboxWidget
106#include "qgsmodelviewtoollink.moc"
107
109
110
112 : QgsModelViewTool( view, tr( "Link Tool" ) )
113{
114 setCursor( Qt::PointingHandCursor );
115 mBezierRubberBand = std::make_unique<QgsModelViewBezierRubberBand>( view );
116
117 mBezierRubberBand->setBrush( QBrush( QColor( 0, 0, 0, 63 ) ) );
118 mBezierRubberBand->setPen( QPen( QBrush( QColor( 0, 0, 0, 100 ) ), 0, Qt::SolidLine ) );
119}
120
122{
123 mBezierRubberBand->update( event->modelPoint(), Qt::KeyboardModifiers() );
124
125 // we need to manually pass this event down to items we want it to go to -- QGraphicsScene doesn't propagate
126 const QList<QGraphicsItem *> items = scene()->items( event->modelPoint() );
127
128 QgsModelDesignerSocketGraphicItem *socket = nullptr;
129 for ( QGraphicsItem *item : items )
130 {
131 socket = dynamic_cast<QgsModelDesignerSocketGraphicItem *>( item );
132 if ( !socket || mFromSocket == socket || mFromSocket->edge() == socket->edge() || mFromSocket->component() == socket->component() )
133 continue;
134
135 // snap
136 socket->modelHoverEnterEvent( event );
137 const QPointF rubberEndPos = socket->mapToScene( socket->position() );
138 mBezierRubberBand->update( rubberEndPos, Qt::KeyboardModifiers() );
139 break;
140 }
141
142 if ( mLastHoveredSocket && socket != mLastHoveredSocket )
143 {
144 mLastHoveredSocket->modelHoverLeaveEvent( event );
145 mLastHoveredSocket = nullptr;
146 }
147
148 if ( socket && socket != mLastHoveredSocket )
149 {
150 mLastHoveredSocket = socket;
151 }
152}
153
155{
156 if ( event->button() != Qt::LeftButton )
157 {
158 return;
159 }
160 mBezierRubberBand->finish( event->modelPoint() );
161 if ( mLastHoveredSocket )
162 {
163 mLastHoveredSocket->modelHoverLeaveEvent( nullptr );
164 mLastHoveredSocket = nullptr;
165 }
166
167 view()->setTool( mPreviousViewTool );
168
169 // we need to manually pass this event down to items we want it to go to -- QGraphicsScene doesn't propagate
170 const QList<QGraphicsItem *> items = scene()->items( event->modelPoint() );
171
172 mToSocket = nullptr;
173
174 for ( QGraphicsItem *item : items )
175 {
176 if ( QgsModelDesignerSocketGraphicItem *socket = dynamic_cast<QgsModelDesignerSocketGraphicItem *>( item ) )
177 {
178 // Skip if sockets are both input or both output or both from the same algorithm
179 if ( mFromSocket->edge() == socket->edge() || mFromSocket->component() == socket->component() )
180 continue;
181
182 mToSocket = socket;
183 break;
184 }
185 }
186
187 // Do nothing if we unlink sockets
188 if ( !mToSocket && mPreviousInputSocketNumber != -1 )
189 {
190 // but it might have been an unlink, so we properly end the command
191 view()->endCommand();
192 return;
193 }
194
195 // and we abort any pending unlink command to not litter the undo buffer
196 view()->abortCommand();
197
198 if ( !mToSocket )
199 {
200 PopupToolboxWidget *widget = new PopupToolboxWidget();
201 widget->setAttribute( Qt::WA_DeleteOnClose );
202 widget->setWindowFlags( Qt::Popup );
203 widget->move( event->globalPos() );
204
205 QgsSettings settings;
207 if ( settings.value( u"Processing/Configuration/SHOW_ALGORITHMS_KNOWN_ISSUES"_s, false ).toBool() )
208 {
210 }
211
212 if ( !mFromSocket->isInput() ) //is an output
213 {
214 QgsProcessingModelComponent *outputComponent = mFromSocket->component();
215 if ( const QgsProcessingModelChildAlgorithm *outputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( outputComponent ) )
216 {
217 widget->toolboxView()->setFilterOutput( outputChildAlgorithm->algorithm()->outputDefinitions().at( mFromSocket->index() ) );
218 }
219 else if ( const QgsProcessingModelParameter *paramFrom = dynamic_cast<QgsProcessingModelParameter *>( outputComponent ) )
220 {
221 widget->toolboxView()->setFilterParameter( scene()->model()->parameterDefinition( paramFrom->parameterName() ) );
222 }
224 }
225 else
226 { // is an input
227 QgsProcessingModelComponent *outputComponent = mFromSocket->component();
228 if ( const QgsProcessingModelChildAlgorithm *outputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( outputComponent ) )
229 {
230 const QgsProcessingParameterDefinition *paramDef = outputChildAlgorithm->algorithm()->parameterDefinitions().at( mFromSocket->index() );
231 widget->toolboxView()->setFilterParameter( paramDef );
233 }
234 }
235
236 widget->toolboxView()->setFilters( filters );
237
238 const QPointF modelPoint = event->modelPoint();
239 connect( widget, &PopupToolboxWidget::algorithmAdded, this, [this, modelPoint]( const QString &algorithmId ) { addAlgorithm( algorithmId, modelPoint, mFromSocket ); } );
240 connect( widget, &PopupToolboxWidget::parameterAdded, this, [this, modelPoint]( const QString &parameterTypeId ) { addParameter( parameterTypeId, modelPoint, mFromSocket ); } );
241
242 widget->show();
243 return;
244 }
245
246 // Do nothing if from socket and to socket are both input or both output
247 if ( mFromSocket->edge() == mToSocket->edge() )
248 {
249 return;
250 }
251
261 if ( !mToSocket->isInput() )
262 {
263 std::swap( mFromSocket, mToSocket );
264 }
265
266 QgsProcessingModelComponent *outputComponent = mFromSocket->component();
267 QgsProcessingModelChildAlgorithm *inputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( mToSocket->component() );
268 if ( !inputChildAlgorithm )
269 {
270 // Should not happen, but checking is cheap!
271 QgsDebugError( u"Input is not a QgsProcessingModelChildAlgorithm"_s );
272 return;
273 }
274
275 QgsProcessingModelChildParameterSource newInputParamSource;
276
277 QString outParamDescription;
278 if ( const QgsProcessingModelChildAlgorithm *outputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( outputComponent ) )
279 {
280 const QgsProcessingOutputDefinition *outputDef = outputChildAlgorithm->algorithm()->outputDefinitions().at( mFromSocket->index() );
281
282 const QString outParamName = outputDef->name();
283 newInputParamSource = QgsProcessingModelChildParameterSource::fromChildOutput( outputChildAlgorithm->childId(), outParamName );
284 outParamDescription = outputDef->description();
285 }
286 else if ( const QgsProcessingModelParameter *paramFrom = dynamic_cast<QgsProcessingModelParameter *>( outputComponent ) )
287 {
288 newInputParamSource = QgsProcessingModelChildParameterSource::fromModelParameter( paramFrom->parameterName() );
289 outParamDescription = paramFrom->description();
290 }
291
292 const QgsProcessingParameterDefinition *inputParam = inputChildAlgorithm->algorithm()->parameterDefinitions().at( mToSocket->index() );
293 const QList<QgsProcessingModelChildParameterSource> compatibleInputParamSources = scene()->model()->availableSourcesForChild( inputChildAlgorithm->childId(), inputParam );
294 if ( !compatibleInputParamSources.contains( newInputParamSource ) )
295 {
296 // Types are incompatible
297 const QString title = tr( "Sockets cannot be connected" );
298 const QString message = tr( "Either the sockets are incompatible or there is a circular dependency" );
299 scene()->showWarning( message, title, message );
300
301 // If the output was previously connected to an input, let's restore it.
302 if ( mPreviousInputSocketNumber != -1 )
303 {
304 QgsProcessingModelChildAlgorithm previousChildAlgorithm = scene()->model()->childAlgorithm( mPreviousInputChildId );
305 const QgsProcessingParameterDefinition *previousInputParam = previousChildAlgorithm.algorithm()->parameterDefinitions().at( mPreviousInputSocketNumber );
306 previousChildAlgorithm.addParameterSources( previousInputParam->name(), { newInputParamSource } );
307 scene()->model()->setChildAlgorithm( previousChildAlgorithm );
308 scene()->requestRebuildRequired();
309 }
310 return;
311 }
312
313 view()->beginCommand( tr( "Link %1: %2 to %3: %4" ).arg( outputComponent->description(), outParamDescription, inputChildAlgorithm->description(), inputParam->description() ) );
314
315 inputChildAlgorithm->addParameterSources( inputParam->name(), { newInputParamSource } );
316
317 //We need to pass the update child algorithm to the model
318 scene()->model()->setChildAlgorithm( *inputChildAlgorithm );
319
320 if ( inputChildAlgorithm->childId() == mPreviousInputChildId && mToSocket->index() == mPreviousInputSocketNumber )
321 {
322 // This is the input socket that was originally connected, let's keep the undo buffer clean since practically nothing changed.
323 view()->abortCommand();
324 }
325 else
326 {
327 view()->endCommand();
328 }
329
330 // Redraw
331 scene()->requestRebuildRequired();
332}
333
335{
336 return true;
337}
338
340{
341 QgsModelViewTool *tool = view()->tool();
342 // Make sure we always return to the select tool and not a temporary tool.
343 if ( dynamic_cast<QgsModelViewToolSelect *>( tool ) )
344 {
345 mPreviousViewTool = tool;
346 }
347
348 const QPointF rubberStartPos = mFromSocket->mapToScene( mFromSocket->position() );
349 mBezierRubberBand->start( rubberStartPos, Qt::KeyboardModifiers() );
350
352}
353
355{
356 mBezierRubberBand->finish();
358}
359
360void QgsModelViewToolLink::setFromSocket( QgsModelDesignerSocketGraphicItem *socket )
361{
362 mFromSocket = socket;
363 mPreviousInputChildId.clear();
364 mPreviousInputSocketNumber = -1;
365
366 // If it's an input socket and it's already connected, we want 'From' to be the output at the other end of the connection
367 if ( mFromSocket->isInput() )
368 {
369 QgsProcessingModelChildAlgorithm *childFrom = dynamic_cast<QgsProcessingModelChildAlgorithm *>( mFromSocket->component() );
370 if ( !childFrom )
371 return;
372
373 const QgsProcessingParameterDefinition *param = childFrom->algorithm()->parameterDefinitions().at( mFromSocket->index() );
374 const QList<QgsProcessingModelChildParameterSource> currentSources = childFrom->parameterSources().value( param->name() );
375
376 for ( const QgsProcessingModelChildParameterSource &source : currentSources )
377 {
378 // Was not connected, nothing to do
379 if ( ( source.source() == Qgis::ProcessingModelChildParameterSource::ChildOutput && source.outputChildId().isEmpty() )
380 || ( source.source() == Qgis::ProcessingModelChildParameterSource::ModelParameter && source.parameterName().isEmpty() ) )
381 continue;
382
383 switch ( source.source() )
384 {
387 {
388 view()->beginCommand( tr( "Unlink %1: %2", "Unlink Algorithm: Input" ).arg( childFrom->description(), param->description() ) );
389
390 // reset to default value.
391 QList<QgsProcessingModelChildParameterSource> newSources;
398 {
399 // Layers/feature sources default to an empty model input parameter
400 // This is the same default that a newly added algorithm uses. It's not the best, since when opening the algorithm's
401 // dialog it will be automatically assigned to the first available input, however it is more consistent behavior.
402 // If we defaulted to an empty static value, then it would be populated by the first available project layer which
403 // would be more confusing.
404 newSources << QgsProcessingModelChildParameterSource::fromModelParameter( QString() );
405 }
406 else
407 {
408 // Other parameters default to static value
409 newSources << QgsProcessingModelChildParameterSource::fromStaticValue( param->defaultValue() );
410 }
411
412 childFrom->addParameterSources( param->name(), newSources );
413 //We need to pass the update child algorithm to the model
414 scene()->model()->setChildAlgorithm( *childFrom );
415 // Redraw
416 scene()->requestRebuildRequired();
417
418 //Get socket from initial source alg / source parameter
419 QgsModelComponentGraphicItem *item = nullptr;
420 int socketIndex = -1;
422 {
423 item = scene()->childAlgorithmItem( source.outputChildId() );
424 auto algSource = dynamic_cast<QgsProcessingModelChildAlgorithm *>( item->component() );
425 if ( !algSource )
426 {
427 QgsDebugError( u"algSource not set, aborting!"_s );
428 return;
429 }
430 socketIndex = QgsProcessingUtils::outputDefinitionIndex( algSource->algorithm(), source.outputName() );
431 }
433 {
434 item = scene()->parameterItem( source.parameterName() );
435 socketIndex = 0;
436 }
437
438 if ( !item )
439 {
440 QgsDebugError( u"item not set, aborting!"_s );
441 return;
442 }
443
444 mPreviousInputChildId = childFrom->childId();
445 mPreviousInputSocketNumber = mFromSocket->index();
446 mFromSocket = item->outSocketAt( socketIndex );
447 }
448 break;
449
454 continue;
455 }
456
457 // Stop on first iteration to get only one link at a time
458 break;
459 }
460 }
461}
462
463void QgsModelViewToolLink::addAlgorithm( const QString &algorithmId, const QPointF &pos, const QgsModelDesignerSocketGraphicItem *socket )
464{
465 std::unique_ptr<QgsProcessingAlgorithm> alg;
466 alg.reset( QgsApplication::processingRegistry()->createAlgorithmById( algorithmId ) );
467
468 if ( !alg )
469 return;
470
471 QgsProcessingModelChildAlgorithm childAlg( algorithmId );
472
473 childAlg.setDescription( alg->displayName() );
474
475 const double offsetX = socket->isInput() ? -childAlg.size().width() / 2 : childAlg.size().width() / 2;
476 const QPointF offset( offsetX, 0 );
477 childAlg.setPosition( pos + offset );
478
479 QgsProcessingModelComponent *outputComponent = const_cast<QgsProcessingModelComponent *>( socket->component() );
480
481 // If connected from an output socket the newly added algorithm needs to have a source.
482 if ( !socket->isInput() )
483 {
484 if ( QgsProcessingModelChildAlgorithm *outputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( outputComponent ) )
485 {
486 const QgsProcessingOutputDefinition *outputDef = outputChildAlgorithm->algorithm()->outputDefinitions().at( socket->index() );
487 const QString outputName = outputDef->name();
488
489 const QList<const QgsProcessingParameterDefinition *> definitions = alg->parameterDefinitions();
490 for ( const QgsProcessingParameterDefinition *paramDef : definitions )
491 {
492 if ( paramDef->flags() & Qgis::ProcessingParameterFlag::Hidden )
493 {
494 continue;
495 }
496 if ( QgsApplication::processingRegistry()->isCompatibleOutput( paramDef, outputDef ) )
497 {
498 QgsProcessingModelChildParameterSource newInputParamSource = QgsProcessingModelChildParameterSource::fromChildOutput( outputChildAlgorithm->childId(), outputName );
499 childAlg.addParameterSources( paramDef->name(), { newInputParamSource } );
500 break;
501 }
502 }
503 }
504 else if ( QgsProcessingModelParameter *outputParam = dynamic_cast<QgsProcessingModelParameter *>( outputComponent ) )
505 {
506 const QgsProcessingParameterDefinition *outputParamDef = scene()->model()->parameterDefinition( outputParam->parameterName() );
507
508 const QList<const QgsProcessingParameterDefinition *> definitions = alg->parameterDefinitions();
509 for ( const QgsProcessingParameterDefinition *paramDef : definitions )
510 {
511 if ( paramDef->flags() & Qgis::ProcessingParameterFlag::Hidden )
512 {
513 continue;
514 }
515 if ( QgsApplication::processingRegistry()->isCompatibleDefinition( paramDef, outputParamDef ) )
516 {
517 QgsProcessingModelChildParameterSource newInputParamSource = QgsProcessingModelChildParameterSource::fromModelParameter( outputParam->parameterName() );
518 childAlg.addParameterSources( paramDef->name(), { newInputParamSource } );
519 break;
520 }
521 }
522 }
523 }
524
525 view()->beginCommand( tr( "Add Algorithm" ) );
526 QString childAlgorithmId = scene()->model()->addChildAlgorithm( childAlg );
527 view()->endCommand();
528
529 // If connect from an input socket the existing algorithm needs to have a the newly added algorithm as a source.
530 if ( socket->isInput() )
531 {
532 QgsProcessingModelChildAlgorithm *outputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( outputComponent );
533 if ( !outputChildAlgorithm || !outputChildAlgorithm->algorithm() )
534 return;
535
536 const QgsProcessingParameterDefinition *parameter = outputChildAlgorithm->algorithm()->parameterDefinitions().at( socket->index() );
537 const QString parameterName = parameter->name();
538
539 const QList<const QgsProcessingOutputDefinition *> definitions = childAlg.algorithm()->outputDefinitions();
540 for ( const QgsProcessingOutputDefinition *outputDef : definitions )
541 {
542 if ( QgsApplication::processingRegistry()->isCompatibleOutput( parameter, outputDef ) )
543 {
544 QgsProcessingModelChildParameterSource newInputParamSource = QgsProcessingModelChildParameterSource::fromChildOutput( childAlgorithmId, outputDef->name() );
545 outputChildAlgorithm->addParameterSources( parameterName, { newInputParamSource } );
546 scene()->model()->setChildAlgorithm( *outputChildAlgorithm );
547 break;
548 }
549 }
550 }
551
552 scene()->requestRebuildRequired();
553}
554
555void QgsModelViewToolLink::addParameter( const QString &parameterId, const QPointF &pos, const QgsModelDesignerSocketGraphicItem *socket )
556{
557 QgsProcessingModelComponent *outputComponent = const_cast<QgsProcessingModelComponent *>( socket->component() );
558 QgsProcessingModelChildAlgorithm *outputChildAlgorithm = dynamic_cast<QgsProcessingModelChildAlgorithm *>( outputComponent );
559 if ( !outputChildAlgorithm || !outputChildAlgorithm->algorithm() )
560 return;
561
562 const QgsProcessingParameterDefinition *socketParameter = outputChildAlgorithm->algorithm()->parameterDefinitions().at( socket->index() );
563
564 QString nameCandidate = socketParameter->name();
565 QString descriptionCandidate = socketParameter->description();
566 int i = 2;
567 while ( scene()->model()->parameterDefinition( nameCandidate ) )
568 {
569 nameCandidate = u"%1 (%2)"_s.arg( socketParameter->name() ).arg( i );
570 descriptionCandidate = u"%1 (%2)"_s.arg( socketParameter->description() ).arg( i );
571 i += 1;
572 }
573 QgsProcessingParameterDefinition *newParameter;
574 if ( socketParameter->type() == parameterId )
575 {
576 // clone if they are the same type so we have nicer default
577 newParameter = socketParameter->clone();
578 }
579 else
580 {
581 newParameter = QgsApplication::processingRegistry()->parameterType( parameterId )->create( nameCandidate );
582 }
583
584 newParameter->setName( nameCandidate );
585 newParameter->setDescription( descriptionCandidate );
586
587 QgsProcessingModelParameter component = QgsProcessingModelParameter( newParameter->name() );
588
589 component.setDescription( newParameter->description() );
590 const double offsetX = -component.size().width() / 2;
591 const QPointF offset( offsetX, 0 );
592 component.setPosition( pos + offset );
593
594 view()->beginCommand( tr( "Add input" ) );
595 scene()->model()->addModelParameter( newParameter, component );
596 view()->endCommand();
597
598 QgsProcessingModelChildParameterSource newInputParamSource = QgsProcessingModelChildParameterSource::fromModelParameter( newParameter->name() );
599 outputChildAlgorithm->addParameterSources( socketParameter->name(), { newInputParamSource } );
600 scene()->model()->setChildAlgorithm( *outputChildAlgorithm );
601
602
603 scene()->requestRebuildRequired();
604}
@ ExpressionText
Parameter value is taken from a text with expressions, evaluated just before the algorithm runs.
Definition qgis.h:4115
@ ModelOutput
Parameter value is linked to an output parameter for the model.
Definition qgis.h:4116
@ ChildOutput
Parameter value is taken from an output generated by a child algorithm.
Definition qgis.h:4112
@ ModelParameter
Parameter value is taken from a parent model parameter.
Definition qgis.h:4111
@ StaticValue
Parameter value is a static value.
Definition qgis.h:4113
@ Expression
Parameter value is taken from an expression, evaluated just before the algorithm runs.
Definition qgis.h:4114
@ Hidden
Parameter is hidden and should not be shown to users.
Definition qgis.h:4027
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.
QPointF modelPoint() const
Returns the event point location in model coordinates.
Model designer view tool for selecting items in the model.
QgsModelGraphicsView * view() const
Returns the view associated with the tool.
void setCursor(const QCursor &cursor)
Sets a user defined cursor for use when the tool is active.
virtual void deactivate()
Called when tool is deactivated.
QgsModelViewTool(QgsModelGraphicsView *view, const QString &name)
Constructor for QgsModelViewTool, taking a model view and tool name as parameters.
virtual void activate()
Called when tool is set as the currently active model tool.
QgsModelGraphicsScene * scene() const
Returns the scene associated with the tool.
QgsProcessingParameterDefinitions parameterDefinitions() const
Returns an ordered list of parameter definitions utilized by the algorithm.
Base class for the definition of processing outputs.
QString name() const
Returns the name of the output.
QString description() const
Returns the description for the output.
Base class for the definition of processing parameters.
QVariant defaultValue() const
Returns the default value for the parameter.
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QString description() const
Returns the description for the parameter.
void setDescription(const QString &description)
Sets the description for the parameter.
void setName(const QString &name)
Sets the name of the parameter.
virtual QgsProcessingParameterDefinition * clone() const =0
Creates a clone of the parameter definition.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
@ ShowKnownIssues
Show algorithms with known issues (hidden by default).
@ ForSocketOutput
Only show algorithms compatible with a certain socket output, use with setFilterOutput().
@ Modeler
Filters out any algorithms and content which should not be shown in the modeler.
@ ForSocketInput
Only show algorithms compatible with a certain input socket, use with setFilterOutput() xor setFilter...
static int outputDefinitionIndex(const QgsProcessingAlgorithm *algorithm, const QString &name)
Returns the index of the output matching name for a specified algorithm.
Stores settings for use within QGIS.
Definition qgssettings.h:68
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
#define QgsDebugError(str)
Definition qgslogger.h:71