[summaryq] Apply coding style
This commit is contained in:
parent
b43759c6a5
commit
d2e11dd5d1
@ -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,44 +60,50 @@ 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 )
|
||||||
, m_thisViewStep(static_cast<SummaryQmlViewStep*>(parent))
|
: QObject( parent )
|
||||||
, m_summary( new SummaryModel(this) )
|
, m_thisViewStep( static_cast< SummaryQmlViewStep* >( parent ) )
|
||||||
|
, m_summary( new SummaryModel( this ) )
|
||||||
{
|
{
|
||||||
m_title = m_thisViewStep->prettyName();
|
m_title = m_thisViewStep->prettyName();
|
||||||
|
|
||||||
if ( Calamares::Settings::instance()->isSetupMode() )
|
if ( Calamares::Settings::instance()->isSetupMode() )
|
||||||
m_message =( tr( "This is an overview of what will happen once you start "
|
m_message = ( tr( "This is an overview of what will happen once you start "
|
||||||
"the setup procedure." ) );
|
"the setup procedure." ) );
|
||||||
else
|
else
|
||||||
m_message = ( tr( "This is an overview of what will happen once you start "
|
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();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -28,42 +28,40 @@ class SummaryModel : public QAbstractListModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
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);
|
void setSummary( const Calamares::ViewStepList& steps );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash< int, QByteArray > roleNames() const override;
|
QHash< int, QByteArray > roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<StepSummary*> m_summary;
|
QVector< StepSummary* > m_summary;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Config : public QObject, public QQmlParserStatus
|
class Config : public QObject, public QQmlParserStatus
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString message MEMBER m_message NOTIFY messageChanged CONSTANT)
|
Q_PROPERTY( QString message MEMBER m_message NOTIFY messageChanged CONSTANT )
|
||||||
Q_PROPERTY(QString title MEMBER m_title NOTIFY titleChanged CONSTANT)
|
Q_PROPERTY( QString title MEMBER m_title NOTIFY titleChanged CONSTANT )
|
||||||
Q_PROPERTY(SummaryModel * summaryModel READ summaryModel CONSTANT FINAL)
|
Q_PROPERTY( SummaryModel* summaryModel READ summaryModel CONSTANT FINAL )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Config(QObject *parent = nullptr);
|
explicit Config( QObject* parent = nullptr );
|
||||||
virtual void componentComplete() override;
|
virtual void componentComplete() override;
|
||||||
virtual void classBegin() override {}
|
virtual void classBegin() override {}
|
||||||
|
|
||||||
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;
|
||||||
const SummaryQmlViewStep* m_thisViewStep;
|
const SummaryQmlViewStep* m_thisViewStep;
|
||||||
SummaryModel *m_summary;
|
SummaryModel* m_summary;
|
||||||
|
|
||||||
QString m_message;
|
QString m_message;
|
||||||
QString m_title;
|
QString m_title;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "SummaryQmlViewStep.h"
|
#include "SummaryQmlViewStep.h"
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryQmlViewStepFactory, registerPlugin<SummaryQmlViewStep>(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryQmlViewStepFactory, registerPlugin< SummaryQmlViewStep >(); )
|
||||||
|
|
||||||
SummaryQmlViewStep::SummaryQmlViewStep( QObject* parent )
|
SummaryQmlViewStep::SummaryQmlViewStep( QObject* parent )
|
||||||
: Calamares::QmlViewStep( parent )
|
: Calamares::QmlViewStep( parent )
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,13 +41,10 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( SummaryQmlViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( SummaryQmlViewStepFactory )
|
||||||
|
Loading…
Reference in New Issue
Block a user