Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Highlight invalid child algorithms in red in the designer
  • Loading branch information
nyalldawson committed Apr 14, 2020
1 parent 2dc07ee commit e45b739
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/gui/processing/models/qgsmodelcomponentgraphicitem.cpp
Expand Up @@ -861,6 +861,9 @@ QgsModelChildAlgorithmGraphicItem::QgsModelChildAlgorithmGraphicItem( QgsProcess
}

setLabel( child->description() );

QStringList issues;
mIsValid = model->validateChildAlgorithm( child->childId(), issues );
}

void QgsModelChildAlgorithmGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
Expand Down Expand Up @@ -893,7 +896,13 @@ void QgsModelChildAlgorithmGraphicItem::contextMenuEvent( QGraphicsSceneContextM

QColor QgsModelChildAlgorithmGraphicItem::fillColor( QgsModelComponentGraphicItem::State state ) const
{
QColor c( 255, 255, 255 );
QColor c;

if ( mIsValid )
c = QColor( 255, 255, 255 );
else
c = QColor( 208, 0, 0 );

switch ( state )
{
case Selected:
Expand All @@ -914,17 +923,17 @@ QColor QgsModelChildAlgorithmGraphicItem::strokeColor( QgsModelComponentGraphicI
switch ( state )
{
case Selected:
return QColor( 50, 50, 50 );
return mIsValid ? QColor( 50, 50, 50 ) : QColor( 80, 0, 0 );
case Hover:
case Normal:
return Qt::gray;
return mIsValid ? Qt::gray : QColor( 134, 0, 0 );
}
return QColor();
}

QColor QgsModelChildAlgorithmGraphicItem::textColor( QgsModelComponentGraphicItem::State ) const
{
return dynamic_cast< const QgsProcessingModelChildAlgorithm * >( component() )->isActive() ? Qt::black : Qt::gray;
return mIsValid ? ( dynamic_cast< const QgsProcessingModelChildAlgorithm * >( component() )->isActive() ? Qt::black : Qt::gray ) : QColor( 255, 255, 255 );
}

QPixmap QgsModelChildAlgorithmGraphicItem::iconPixmap() const
Expand Down
1 change: 1 addition & 0 deletions src/gui/processing/models/qgsmodelcomponentgraphicitem.h
Expand Up @@ -493,6 +493,7 @@ class GUI_EXPORT QgsModelChildAlgorithmGraphicItem : public QgsModelComponentGra
QPixmap mPixmap;
QVariantMap mResults;
QVariantMap mInputs;
bool mIsValid = true;
};


Expand Down

0 comments on commit e45b739

Please sign in to comment.