diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp index 8a42a25a3..707dd6655 100644 --- a/src/calamares/progresstree/ProgressTreeModel.cpp +++ b/src/calamares/progresstree/ProgressTreeModel.cpp @@ -133,7 +133,11 @@ ProgressTreeModel::setupModelData() m_rootItem = new ProgressTreeRoot(); const Calamares::ViewManager* vm = Calamares::ViewManager::instance(); - TextTreeItem* prepare = new TextTreeItem( tr( "Prepare" ), m_rootItem ); + TextTreeItem* prepare = new TextTreeItem( []() -> QString + { + return tr( "Prepare" ); + }, + m_rootItem ); m_rootItem->appendChild( prepare ); foreach ( const Calamares::ViewStep* step, vm->prepareSteps() ) @@ -141,13 +145,21 @@ ProgressTreeModel::setupModelData() prepare->appendChild( new ViewStepItem( step, prepare ) ); } - m_rootItem->appendChild( new ViewStepItem( tr( "Install" ), + m_rootItem->appendChild( new ViewStepItem( + []() -> QString + { + return tr( "Install" ); + }, [vm]() -> const Calamares::ViewStep* { return vm->installationStep(); }, m_rootItem ) ); - m_rootItem->appendChild( new ViewStepItem( tr( "Finish" ), + m_rootItem->appendChild( new ViewStepItem( + []() -> QString + { + return tr( "Finish" ); + }, [vm]() -> const Calamares::ViewStep* { return vm->finishedStep(); diff --git a/src/calamares/progresstree/TextTreeItem.cpp b/src/calamares/progresstree/TextTreeItem.cpp index 16a7a41eb..8e5c1c6e4 100644 --- a/src/calamares/progresstree/TextTreeItem.cpp +++ b/src/calamares/progresstree/TextTreeItem.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,10 +20,12 @@ #include "ProgressTreeModel.h" -TextTreeItem::TextTreeItem( const QString& text, ProgressTreeItem* parent ) +TextTreeItem::TextTreeItem( std::function< QString() > textReturner, + ProgressTreeItem* parent ) : ProgressTreeItem( parent ) - , m_text( text ) -{} +{ + m_textReturner = textReturner; +} QVariant @@ -32,6 +34,6 @@ TextTreeItem::data( int role ) const if ( role == ProgressTreeModel::ProgressTreeItemRole ) return this; if ( role == Qt::DisplayRole ) - return m_text; + return m_textReturner(); return QVariant(); } diff --git a/src/calamares/progresstree/TextTreeItem.h b/src/calamares/progresstree/TextTreeItem.h index ba69b34b2..fb5890082 100644 --- a/src/calamares/progresstree/TextTreeItem.h +++ b/src/calamares/progresstree/TextTreeItem.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,16 +21,19 @@ #include "ProgressTreeItem.h" +#include + class TextTreeItem : public ProgressTreeItem { public: - explicit TextTreeItem( const QString& text, ProgressTreeItem* parent = nullptr ); + explicit TextTreeItem( std::function< QString() > textReturner, + ProgressTreeItem* parent = nullptr ); virtual QVariant data( int role ) const override; private: - QString m_text; + std::function< QString() > m_textReturner; }; #endif // TEXTTREEITEM_H diff --git a/src/calamares/progresstree/ViewStepItem.cpp b/src/calamares/progresstree/ViewStepItem.cpp index bfc07a820..77ee869d7 100644 --- a/src/calamares/progresstree/ViewStepItem.cpp +++ b/src/calamares/progresstree/ViewStepItem.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,13 +23,13 @@ #include "viewpages/ViewStep.h" -ViewStepItem::ViewStepItem( const QString& prettyName, +ViewStepItem::ViewStepItem( std::function< QString() > prettyName, std::function< const Calamares::ViewStep*() > accessor, ProgressTreeItem* parent ) : ProgressTreeItem( parent ) - , m_step( 0 ) - , m_prettyName( prettyName ) + , m_step( nullptr ) { + m_prettyName = prettyName; m_accessor = accessor; } @@ -54,7 +54,7 @@ ViewStepItem::data( int role ) const if ( role == ProgressTreeModel::ProgressTreeItemRole ) return this; if ( role == Qt::DisplayRole ) - return m_step ? m_step->prettyName() : m_prettyName; + return m_step ? m_step->prettyName() : m_prettyName(); if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole ) return m_step ? ( Calamares::ViewManager::instance()->currentStep() == m_step ) : diff --git a/src/calamares/progresstree/ViewStepItem.h b/src/calamares/progresstree/ViewStepItem.h index 8235a5a82..a226f3d30 100644 --- a/src/calamares/progresstree/ViewStepItem.h +++ b/src/calamares/progresstree/ViewStepItem.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014, Teo Mrnjavac + * Copyright 2014-2015, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ class ViewStep; class ViewStepItem : public ProgressTreeItem { public: - explicit ViewStepItem( const QString& prettyName, + explicit ViewStepItem( std::function< QString() > prettyName, std::function< const Calamares::ViewStep*() > accessor, ProgressTreeItem* parent = nullptr ); @@ -44,7 +44,7 @@ public: private: std::function< const Calamares::ViewStep*() > m_accessor; - QString m_prettyName; + std::function< QString() > m_prettyName; const Calamares::ViewStep* m_step; };