[summaryq] Hide internals of building the summary model
This commit is contained in:
parent
792ba8c0af
commit
768760793a
@ -48,7 +48,7 @@ SummaryModel::rowCount( const QModelIndex& ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SummaryModel::setSummary( const Calamares::ViewStepList& steps, bool withWidgets )
|
SummaryModel::setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets )
|
||||||
{
|
{
|
||||||
Q_EMIT beginResetModel();
|
Q_EMIT beginResetModel();
|
||||||
m_summary.clear();
|
m_summary.clear();
|
||||||
@ -105,28 +105,24 @@ Config::componentComplete()
|
|||||||
|
|
||||||
void
|
void
|
||||||
Config::refresh()
|
Config::refresh()
|
||||||
{
|
|
||||||
m_summary->setSummary( stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Config::init()
|
|
||||||
{
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
Calamares::ViewStepList
|
|
||||||
Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
|
|
||||||
{
|
{
|
||||||
Calamares::ViewStepList steps;
|
Calamares::ViewStepList steps;
|
||||||
for ( Calamares::ViewStep* step : allSteps )
|
for ( Calamares::ViewStep* step : Calamares::ViewManager::instance()->viewSteps() )
|
||||||
{
|
{
|
||||||
|
// *Assume* that if there's an exec step in the sequence,
|
||||||
|
// we don't need a summary for steps before it. This works in
|
||||||
|
// practice if there's a summary step before each exec --
|
||||||
|
// and in practice, there's only one of each.
|
||||||
if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) )
|
if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) )
|
||||||
{
|
{
|
||||||
steps.clear();
|
steps.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Having reached the parent view-step of the Config object,
|
||||||
|
// we know we're providing a summary of steps up until this
|
||||||
|
// view step, so we now have steps since the previous exec, up
|
||||||
|
// to this summary.
|
||||||
if ( m_thisViewStep == step )
|
if ( m_thisViewStep == step )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -135,5 +131,11 @@ Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
|
|||||||
steps.append( step );
|
steps.append( step );
|
||||||
}
|
}
|
||||||
|
|
||||||
return steps;
|
m_summary->setSummaryList( steps );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Config::init()
|
||||||
|
{
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlParserStatus>
|
#include <QQmlParserStatus>
|
||||||
|
|
||||||
|
class Config;
|
||||||
|
|
||||||
/** @brief Data for one step
|
/** @brief Data for one step
|
||||||
*
|
*
|
||||||
* A step generally has a text description, but **may** have a
|
* A step generally has a text description, but **may** have a
|
||||||
@ -33,17 +35,26 @@ struct StepSummary
|
|||||||
class SummaryModel : public QAbstractListModel
|
class SummaryModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
friend class Config;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SummaryModel( QObject* parent = nullptr );
|
explicit SummaryModel( QObject* parent = nullptr );
|
||||||
int rowCount( const QModelIndex& = QModelIndex() ) const override;
|
int rowCount( const QModelIndex& = QModelIndex() ) const override;
|
||||||
QVariant data( const QModelIndex& index, int role ) const override;
|
QVariant data( const QModelIndex& index, int role ) const override;
|
||||||
|
|
||||||
void setSummary( const Calamares::ViewStepList& steps, bool withWidgets = false );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash< int, QByteArray > roleNames() const override;
|
QHash< int, QByteArray > roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/** @brief Sets the model data from @p steps
|
||||||
|
*
|
||||||
|
* Replaces the list of summaries with summaries given by
|
||||||
|
* the jobs and ViewSteps objects in @p steps. If @p withWidgets
|
||||||
|
* is @c true, then also queries for widget summaries alongside
|
||||||
|
* the text summaries for each step.
|
||||||
|
*/
|
||||||
|
void setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets = false );
|
||||||
|
|
||||||
QVector< StepSummary > m_summary;
|
QVector< StepSummary > m_summary;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user