diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp
index 9127398e8..eb5479e23 100644
--- a/src/calamares/progresstree/ProgressTreeModel.cpp
+++ b/src/calamares/progresstree/ProgressTreeModel.cpp
@@ -50,34 +50,51 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const
}
const auto* step = steps.at( index.row() );
-
- if ( role == Qt::DisplayRole )
+ if ( !step )
{
- return step->prettyName();
+ return QVariant();
}
- if ( Calamares::Settings::instance()->debugMode() && role == Qt::ToolTipRole )
+
+ switch ( role )
{
- QString toolTip( "Debug information" );
- if ( step )
+ case Qt::DisplayRole:
+ return step->prettyName();
+ case Qt::ToolTipRole:
+ if ( Calamares::Settings::instance()->debugMode() )
{
+ auto key = step->moduleInstanceKey();
+ QString toolTip( "Debug information" );
toolTip.append( "
Type:\tViewStep" );
toolTip.append( QString( "
Pretty:\t%1" ).arg( step->prettyName() ) );
toolTip.append( QString( "
Status:\t%1" ).arg( step->prettyStatus() ) );
- toolTip.append( QString( "
Source:\t%1" )
- .arg( step->moduleInstanceKey().isValid() ? step->moduleInstanceKey().toString()
- : QStringLiteral( "built-in" ) ) );
+ toolTip.append(
+ QString( "
Source:\t%1" ).arg( key.isValid() ? key.toString() : QStringLiteral( "built-in" ) ) );
+ return toolTip;
}
else
{
- toolTip.append( "
Type:\tDelegate" );
+ return QVariant();
}
- return toolTip;
+ case ProgressTreeItemCurrentRole:
+ return vm->currentStep() == step;
+ case ProgressTreeItemCompletedRole:
+ // Every step *before* the current step is considered "complete"
+ for ( const auto* otherstep : steps )
+ {
+ if ( otherstep == vm->currentStep() )
+ {
+ break;
+ }
+ if ( otherstep == step )
+ {
+ return true;
+ }
+ }
+ // .. and the others (including current) are not.
+ return false;
+ default:
+ return QVariant();
}
- if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole )
- {
- return step && ( Calamares::ViewManager::instance()->currentStep() == step );
- }
- return QVariant();
}
diff --git a/src/calamares/progresstree/ProgressTreeModel.h b/src/calamares/progresstree/ProgressTreeModel.h
index e52ecf189..9fed4ae1f 100644
--- a/src/calamares/progresstree/ProgressTreeModel.h
+++ b/src/calamares/progresstree/ProgressTreeModel.h
@@ -31,7 +31,8 @@ class ProgressTreeModel : public QAbstractListModel
public:
enum Role
{
- ProgressTreeItemCurrentRole = Qt::UserRole + 11
+ ProgressTreeItemCurrentRole = Qt::UserRole + 11, ///< Is this the *current* step?
+ ProgressTreeItemCompletedRole = Qt::UserRole + 12 ///< Are we past this one?
};
explicit ProgressTreeModel( QObject* parent = nullptr );