Refactor Summary page to use new workflow to get operations list.

This commit is contained in:
Teo Mrnjavac 2015-09-09 19:06:44 +02:00
parent 007ad9abae
commit c824172f37
2 changed files with 48 additions and 6 deletions

View File

@ -18,10 +18,12 @@
#include "SummaryPage.h" #include "SummaryPage.h"
#include "ViewManager.h" #include "SummaryViewStep.h"
#include "viewpages/ViewStep.h"
#include "ExecutionViewStep.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "ViewManager.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QLabel> #include <QLabel>
@ -29,11 +31,13 @@
static const int SECTION_SPACING = 12; static const int SECTION_SPACING = 12;
SummaryPage::SummaryPage( QWidget* parent ) SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent )
: QWidget() : QWidget()
, m_thisViewStep( thisViewStep )
, m_scrollArea( new QScrollArea( this ) ) , m_scrollArea( new QScrollArea( this ) )
, m_contentWidget( nullptr ) , m_contentWidget( nullptr )
{ {
Q_ASSERT( m_thisViewStep );
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 ); layout->setContentsMargins( 0, 0, 0, 0 );
@ -59,8 +63,10 @@ SummaryPage::onActivate()
QString text; QString text;
bool first = true; bool first = true;
foreach ( Calamares::ViewStep* step, Calamares::ViewStepList steps =
Calamares::ViewManager::instance()->prepareSteps() ) stepsForSummary( Calamares::ViewManager::instance()->viewSteps() );
foreach ( Calamares::ViewStep* step, steps )
{ {
QString text = step->prettyStatus(); QString text = step->prettyStatus();
QWidget* widget = step->createSummaryWidget(); QWidget* widget = step->createSummaryWidget();
@ -90,6 +96,35 @@ SummaryPage::onActivate()
m_layout->addStretch(); m_layout->addStretch();
} }
Calamares::ViewStepList
SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
{
Calamares::ViewStepList steps;
foreach ( Calamares::ViewStep* step, allSteps )
{
// We start from the beginning of the complete steps list. If we encounter any
// ExecutionViewStep, it means there was an execution phase in the past, and any
// jobs from before that phase were already executed, so we can safely clear the
// list of steps to summarize and start collecting from scratch.
if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) )
{
steps.clear();
continue;
}
// If we reach the parent step of this page, we're done collecting the list of
// steps to summarize.
if ( m_thisViewStep == step )
break;
steps.append( step );
}
return steps;
}
void void
SummaryPage::createContentWidget() SummaryPage::createContentWidget()
{ {

View File

@ -19,21 +19,28 @@
#ifndef SUMMARYPAGE_H #ifndef SUMMARYPAGE_H
#define SUMMARYPAGE_H #define SUMMARYPAGE_H
#include "Typedefs.h"
#include <QWidget> #include <QWidget>
class QLabel; class QLabel;
class QScrollArea; class QScrollArea;
class QVBoxLayout; class QVBoxLayout;
class SummaryViewStep;
class SummaryPage : public QWidget class SummaryPage : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SummaryPage( QWidget* parent = nullptr ); explicit SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent = nullptr );
void onActivate(); void onActivate();
private: private:
Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const;
const SummaryViewStep* m_thisViewStep;
QVBoxLayout* m_layout = nullptr; QVBoxLayout* m_layout = nullptr;
QWidget* m_contentWidget = nullptr; QWidget* m_contentWidget = nullptr;