From d2e11dd5d1f1fac9560426f9eb94d7f0a673284f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Jul 2021 10:36:05 +0200 Subject: [PATCH] [summaryq] Apply coding style --- src/modules/summaryq/Config.cpp | 54 +++++++++++++-------- src/modules/summaryq/Config.h | 30 ++++++------ src/modules/summaryq/SummaryQmlViewStep.cpp | 8 +-- src/modules/summaryq/SummaryQmlViewStep.h | 11 ++--- 4 files changed, 53 insertions(+), 50 deletions(-) diff --git a/src/modules/summaryq/Config.cpp b/src/modules/summaryq/Config.cpp index 64e43a0ba..8314802a9 100644 --- a/src/modules/summaryq/Config.cpp +++ b/src/modules/summaryq/Config.cpp @@ -20,15 +20,19 @@ #include "utils/Retranslator.h" #include "viewpages/ExecutionViewStep.h" -SummaryModel::SummaryModel(QObject* parent) : QAbstractListModel(parent) -{} +SummaryModel::SummaryModel( QObject* parent ) + : QAbstractListModel( parent ) +{ +} -QHash SummaryModel::roleNames() const +QHash< int, QByteArray > +SummaryModel::roleNames() const { 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() ) { @@ -38,12 +42,14 @@ QVariant SummaryModel::data(const QModelIndex& index, int role) const return role == Qt::DisplayRole ? item->title : item->message; } -int SummaryModel::rowCount(const QModelIndex&) const +int +SummaryModel::rowCount( const QModelIndex& ) const { return m_summary.count(); } -void SummaryModel::setSummary(const Calamares::ViewStepList& steps) +void +SummaryModel::setSummary( const Calamares::ViewStepList& steps ) { m_summary.clear(); Q_EMIT beginResetModel(); @@ -54,44 +60,50 @@ void SummaryModel::setSummary(const Calamares::ViewStepList& steps) QWidget* widget = step->createSummaryWidget(); if ( text.isEmpty() && !widget ) + { continue; + } - m_summary << new StepSummary {step->prettyName(), text}; - + m_summary << new StepSummary { step->prettyName(), text }; } Q_EMIT endResetModel(); } -Config::Config(QObject *parent) : QObject(parent) -, m_thisViewStep(static_cast(parent)) -, m_summary( new SummaryModel(this) ) +Config::Config( QObject* parent ) + : QObject( parent ) + , m_thisViewStep( static_cast< SummaryQmlViewStep* >( parent ) ) + , m_summary( new SummaryModel( this ) ) { m_title = m_thisViewStep->prettyName(); if ( Calamares::Settings::instance()->isSetupMode() ) - m_message =( tr( "This is an overview of what will happen once you start " - "the setup procedure." ) ); + m_message = ( tr( "This is an overview of what will happen once you start " + "the setup procedure." ) ); else m_message = ( tr( "This is an overview of what will happen once you start " - "the install procedure." ) ); + "the install procedure." ) ); } -void Config::componentComplete() +void +Config::componentComplete() { 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(); } -Calamares::ViewStepList Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const +Calamares::ViewStepList +Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const { Calamares::ViewStepList steps; for ( Calamares::ViewStep* step : allSteps ) @@ -103,12 +115,12 @@ Calamares::ViewStepList Config::stepsForSummary( const Calamares::ViewStepList& } if ( m_thisViewStep == step ) + { break; + } steps.append( step ); } return steps; } - - diff --git a/src/modules/summaryq/Config.h b/src/modules/summaryq/Config.h index 162ff2c5f..39732a9e5 100644 --- a/src/modules/summaryq/Config.h +++ b/src/modules/summaryq/Config.h @@ -11,10 +11,10 @@ #ifndef SUMMARY_CONFIG_H #define SUMMARY_CONFIG_H -#include -#include -#include #include "viewpages/ViewStep.h" +#include +#include +#include class SummaryQmlViewStep; @@ -26,44 +26,42 @@ struct StepSummary class SummaryModel : public QAbstractListModel { - Q_OBJECT + Q_OBJECT public: - explicit SummaryModel(QObject *parent = nullptr); + explicit SummaryModel( QObject* parent = nullptr ); int rowCount( const QModelIndex& = QModelIndex() ) const override; QVariant data( const QModelIndex& index, int role ) const override; - void setSummary(const Calamares::ViewStepList &steps); + void setSummary( const Calamares::ViewStepList& steps ); protected: QHash< int, QByteArray > roleNames() const override; + private: - QVector m_summary; + QVector< StepSummary* > m_summary; }; class Config : public QObject, public QQmlParserStatus { Q_OBJECT - Q_PROPERTY(QString message MEMBER m_message NOTIFY messageChanged CONSTANT) - Q_PROPERTY(QString title MEMBER m_title NOTIFY titleChanged CONSTANT) - Q_PROPERTY(SummaryModel * summaryModel READ summaryModel CONSTANT FINAL) + Q_PROPERTY( QString message MEMBER m_message NOTIFY messageChanged CONSTANT ) + Q_PROPERTY( QString title MEMBER m_title NOTIFY titleChanged CONSTANT ) + Q_PROPERTY( SummaryModel* summaryModel READ summaryModel CONSTANT FINAL ) public: - explicit Config(QObject *parent = nullptr); + explicit Config( QObject* parent = nullptr ); virtual void componentComplete() override; virtual void classBegin() override {} void refresh(); void init(); - SummaryModel * summaryModel() const - { - return m_summary; - } + SummaryModel* summaryModel() const { return m_summary; } private: Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; const SummaryQmlViewStep* m_thisViewStep; - SummaryModel *m_summary; + SummaryModel* m_summary; QString m_message; QString m_title; diff --git a/src/modules/summaryq/SummaryQmlViewStep.cpp b/src/modules/summaryq/SummaryQmlViewStep.cpp index 8f7360212..2ea159984 100644 --- a/src/modules/summaryq/SummaryQmlViewStep.cpp +++ b/src/modules/summaryq/SummaryQmlViewStep.cpp @@ -10,7 +10,7 @@ #include "SummaryQmlViewStep.h" -CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryQmlViewStepFactory, registerPlugin(); ) +CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryQmlViewStepFactory, registerPlugin< SummaryQmlViewStep >(); ) SummaryQmlViewStep::SummaryQmlViewStep( QObject* parent ) : Calamares::QmlViewStep( parent ) @@ -20,10 +20,7 @@ SummaryQmlViewStep::SummaryQmlViewStep( QObject* parent ) } -SummaryQmlViewStep::~SummaryQmlViewStep() -{ - -} +SummaryQmlViewStep::~SummaryQmlViewStep() {} QString SummaryQmlViewStep::prettyName() const @@ -72,4 +69,3 @@ SummaryQmlViewStep::onActivate() { m_config->init(); } - diff --git a/src/modules/summaryq/SummaryQmlViewStep.h b/src/modules/summaryq/SummaryQmlViewStep.h index f42ec9f5c..42febd145 100644 --- a/src/modules/summaryq/SummaryQmlViewStep.h +++ b/src/modules/summaryq/SummaryQmlViewStep.h @@ -12,9 +12,9 @@ #define SUMMARYQMLVIEWSTEP_H #include "Config.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" #include "viewpages/QmlViewStep.h" -#include "DllMacro.h" #include @@ -41,15 +41,12 @@ public: void onActivate() override; - QObject * getConfig() override - { - return m_config; - } + QObject* getConfig() override { return m_config; } private: - Config *m_config; + Config* m_config; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( SummaryQmlViewStepFactory ) -#endif // SUMMARYQMLVIEWSTEP_H +#endif // SUMMARYQMLVIEWSTEP_H