Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Make handling of processing child algorithm dependencies more flexible
Instead of just using child ID strings, use a new dedicated class to store dependency information
- Loading branch information
1 parent
359df3c
commit b216759
Showing
12 changed files
with
263 additions
and
31 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
65 changes: 65 additions & 0 deletions
65
python/core/auto_generated/processing/models/qgsprocessingmodelchilddependency.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,65 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/processing/models/qgsprocessingmodelchilddependency.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsProcessingModelChildDependency | ||
{ | ||
%Docstring | ||
Contains details of a child algorithm dependency. | ||
|
||
.. versionadded:: 3.14 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprocessingmodelchilddependency.h" | ||
%End | ||
public: | ||
|
||
QgsProcessingModelChildDependency( const QString &childId = QString(), const QString &conditionalBranch = QString() ); | ||
%Docstring | ||
Constructor for QgsProcessingModelChildDependency, with the specified ``childId``. | ||
%End | ||
|
||
QString childId; | ||
|
||
QString conditionalBranch; | ||
|
||
QVariant toVariant() const; | ||
%Docstring | ||
Saves this dependency to a QVariant. | ||
|
||
.. seealso:: :py:func:`loadVariant` | ||
%End | ||
|
||
bool loadVariant( const QVariantMap &map ); | ||
%Docstring | ||
Loads this dependency from a QVariantMap. | ||
|
||
.. seealso:: :py:func:`toVariant` | ||
%End | ||
|
||
bool operator==( const QgsProcessingModelChildDependency &other ) const; | ||
|
||
bool operator!=( const QgsProcessingModelChildDependency &other ) const; | ||
|
||
bool operator<( const QgsProcessingModelChildDependency &other ) const; | ||
}; | ||
|
||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/processing/models/qgsprocessingmodelchilddependency.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
95 changes: 95 additions & 0 deletions
95
src/core/processing/models/qgsprocessingmodelchilddependency.h
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,95 @@ | ||
/*************************************************************************** | ||
qgsprocessingmodelchilddependency.h | ||
----------------------------- | ||
begin : April 2020 | ||
copyright : (C) 2020 by Nyall Dawson | ||
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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSPROCESSINGMODELCHILDDEPENDENCY_H | ||
#define QGSPROCESSINGMODELCHILDDEPENDENCY_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis.h" | ||
|
||
|
||
///@cond NOT_STABLE | ||
|
||
/** | ||
* \class QgsProcessingModelChildDependency | ||
* \ingroup core | ||
* Contains details of a child algorithm dependency. | ||
* \since QGIS 3.14 | ||
*/ | ||
class CORE_EXPORT QgsProcessingModelChildDependency | ||
{ | ||
public: | ||
|
||
/** | ||
* Constructor for QgsProcessingModelChildDependency, with the specified \a childId. | ||
*/ | ||
QgsProcessingModelChildDependency( const QString &childId = QString(), const QString &conditionalBranch = QString() ) | ||
: childId( childId ) | ||
, conditionalBranch( conditionalBranch ) | ||
{ | ||
} | ||
|
||
//! Child algorithm ID | ||
QString childId; | ||
|
||
//! Conditional branch output name, if applicable. | ||
QString conditionalBranch; | ||
|
||
/** | ||
* Saves this dependency to a QVariant. | ||
* \see loadVariant() | ||
*/ | ||
QVariant toVariant() const | ||
{ | ||
QVariantMap res; | ||
res.insert( QStringLiteral( "child_id" ), childId ); | ||
res.insert( QStringLiteral( "conditional_branch" ), conditionalBranch ); | ||
return res; | ||
} | ||
|
||
/** | ||
* Loads this dependency from a QVariantMap. | ||
* \see toVariant() | ||
*/ | ||
bool loadVariant( const QVariantMap &map ) | ||
{ | ||
childId = map.value( QStringLiteral( "child_id" ) ).toString(); | ||
conditionalBranch = map.value( QStringLiteral( "conditional_branch" ) ).toString(); | ||
return true; | ||
} | ||
|
||
bool operator==( const QgsProcessingModelChildDependency &other ) const | ||
{ | ||
return childId == other.childId && conditionalBranch == other.conditionalBranch; | ||
} | ||
|
||
bool operator!=( const QgsProcessingModelChildDependency &other ) const | ||
{ | ||
return !( *this == other ); | ||
} | ||
|
||
bool operator<( const QgsProcessingModelChildDependency &other ) const | ||
{ | ||
return childId == other.childId ? conditionalBranch < other.conditionalBranch : childId < other.childId; | ||
} | ||
}; | ||
|
||
Q_DECLARE_METATYPE( QgsProcessingModelChildDependency ) | ||
|
||
///@endcond | ||
|
||
#endif // QGSPROCESSINGMODELCHILDDEPENDENCY_H |
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
Oops, something went wrong.