[summaryq] Apply coding style

This commit is contained in:
Adriaan de Groot 2021-07-13 10:36:05 +02:00
parent b43759c6a5
commit d2e11dd5d1
4 changed files with 53 additions and 50 deletions

View file

@ -20,15 +20,19 @@
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include "viewpages/ExecutionViewStep.h" #include "viewpages/ExecutionViewStep.h"
SummaryModel::SummaryModel(QObject* parent) : QAbstractListModel(parent) SummaryModel::SummaryModel( QObject* parent )
{} : QAbstractListModel( parent )
{
}
QHash<int, QByteArray> SummaryModel::roleNames() const QHash< int, QByteArray >
SummaryModel::roleNames() const
{ {
return { { Qt::DisplayRole, "title" }, { Qt::UserRole, "message" } }; return { { Qt::DisplayRole, "title" }, { Qt::UserRole, "message" } };
} }
QVariant SummaryModel::data(const QModelIndex& index, int role) const QVariant
SummaryModel::data( const QModelIndex& index, int role ) const
{ {
if ( !index.isValid() ) if ( !index.isValid() )
{ {
@ -38,12 +42,14 @@ QVariant SummaryModel::data(const QModelIndex& index, int role) const
return role == Qt::DisplayRole ? item->title : item->message; return role == Qt::DisplayRole ? item->title : item->message;
} }
int SummaryModel::rowCount(const QModelIndex&) const int
SummaryModel::rowCount( const QModelIndex& ) const
{ {
return m_summary.count(); return m_summary.count();
} }
void SummaryModel::setSummary(const Calamares::ViewStepList& steps) void
SummaryModel::setSummary( const Calamares::ViewStepList& steps )
{ {
m_summary.clear(); m_summary.clear();
Q_EMIT beginResetModel(); Q_EMIT beginResetModel();
@ -54,15 +60,17 @@ void SummaryModel::setSummary(const Calamares::ViewStepList& steps)
QWidget* widget = step->createSummaryWidget(); QWidget* widget = step->createSummaryWidget();
if ( text.isEmpty() && !widget ) if ( text.isEmpty() && !widget )
{
continue; continue;
}
m_summary << new StepSummary { step->prettyName(), text }; m_summary << new StepSummary { step->prettyName(), text };
} }
Q_EMIT endResetModel(); Q_EMIT endResetModel();
} }
Config::Config(QObject *parent) : QObject(parent) Config::Config( QObject* parent )
: QObject( parent )
, m_thisViewStep( static_cast< SummaryQmlViewStep* >( parent ) ) , m_thisViewStep( static_cast< SummaryQmlViewStep* >( parent ) )
, m_summary( new SummaryModel( this ) ) , m_summary( new SummaryModel( this ) )
{ {
@ -76,22 +84,26 @@ Config::Config(QObject *parent) : QObject(parent)
"the install procedure." ) ); "the install procedure." ) );
} }
void Config::componentComplete() void
Config::componentComplete()
{ {
refresh(); refresh();
} }
void Config::refresh() void
Config::refresh()
{ {
m_summary->setSummary( stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ) ); m_summary->setSummary( stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ) );
} }
void Config::init() void
Config::init()
{ {
refresh(); refresh();
} }
Calamares::ViewStepList Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const Calamares::ViewStepList
Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
{ {
Calamares::ViewStepList steps; Calamares::ViewStepList steps;
for ( Calamares::ViewStep* step : allSteps ) for ( Calamares::ViewStep* step : allSteps )
@ -103,12 +115,12 @@ Calamares::ViewStepList Config::stepsForSummary( const Calamares::ViewStepList&
} }
if ( m_thisViewStep == step ) if ( m_thisViewStep == step )
{
break; break;
}
steps.append( step ); steps.append( step );
} }
return steps; return steps;
} }

View file

@ -11,10 +11,10 @@
#ifndef SUMMARY_CONFIG_H #ifndef SUMMARY_CONFIG_H
#define SUMMARY_CONFIG_H #define SUMMARY_CONFIG_H
#include <QObject>
#include <QAbstractListModel>
#include <QQmlParserStatus>
#include "viewpages/ViewStep.h" #include "viewpages/ViewStep.h"
#include <QAbstractListModel>
#include <QObject>
#include <QQmlParserStatus>
class SummaryQmlViewStep; class SummaryQmlViewStep;
@ -36,6 +36,7 @@ public:
protected: protected:
QHash< int, QByteArray > roleNames() const override; QHash< int, QByteArray > roleNames() const override;
private: private:
QVector< StepSummary* > m_summary; QVector< StepSummary* > m_summary;
}; };
@ -55,10 +56,7 @@ public:
void refresh(); void refresh();
void init(); void init();
SummaryModel * summaryModel() const SummaryModel* summaryModel() const { return m_summary; }
{
return m_summary;
}
private: private:
Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const;

View file

@ -20,10 +20,7 @@ SummaryQmlViewStep::SummaryQmlViewStep( QObject* parent )
} }
SummaryQmlViewStep::~SummaryQmlViewStep() SummaryQmlViewStep::~SummaryQmlViewStep() {}
{
}
QString QString
SummaryQmlViewStep::prettyName() const SummaryQmlViewStep::prettyName() const
@ -72,4 +69,3 @@ SummaryQmlViewStep::onActivate()
{ {
m_config->init(); m_config->init();
} }

View file

@ -12,9 +12,9 @@
#define SUMMARYQMLVIEWSTEP_H #define SUMMARYQMLVIEWSTEP_H
#include "Config.h" #include "Config.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h" #include "utils/PluginFactory.h"
#include "viewpages/QmlViewStep.h" #include "viewpages/QmlViewStep.h"
#include "DllMacro.h"
#include <QObject> #include <QObject>
@ -41,10 +41,7 @@ public:
void onActivate() override; void onActivate() override;
QObject * getConfig() override QObject* getConfig() override { return m_config; }
{
return m_config;
}
private: private:
Config* m_config; Config* m_config;