[libcalamares] Move progress signal to RequirementsModel

- It is the requirements model (checking) that reports progress, and now
  the model is accessible (ask for it with requirementsModel(), make the
  messages come from there.
This commit is contained in:
Adriaan de Groot 2020-05-12 16:09:13 +02:00
parent 90f8e748ef
commit f856c07b04
5 changed files with 18 additions and 4 deletions

View File

@ -41,6 +41,7 @@ RequirementsChecker::RequirementsChecker( QVector< Module* > modules, Requiremen
, m_progressTimeouts( 0 ) , m_progressTimeouts( 0 )
{ {
m_watchers.reserve( m_modules.count() ); m_watchers.reserve( m_modules.count() );
connect( this, &RequirementsChecker::requirementsProgress, model, &RequirementsModel::setProgressMessage );
} }
RequirementsChecker::~RequirementsChecker() {} RequirementsChecker::~RequirementsChecker() {}
@ -97,8 +98,7 @@ RequirementsChecker::addCheckedRequirements( Module* m )
m_model->addRequirementsList( l ); m_model->addRequirementsList( l );
} }
requirementsProgress( requirementsProgress( tr( "Requirements checking for module <i>%1</i> is complete." ).arg( m->name() ) );
tr( "Requirements checking for module <i>%1</i> is complete." ).arg( m->name() ) );
} }
void void

View File

@ -105,4 +105,11 @@ RequirementsModel::describe() const
} }
} }
void
RequirementsModel::setProgressMessage( const QString& m )
{
m_progressMessage = m;
emit progressMessageChanged( m_progressMessage );
}
} // namespace Calamares } // namespace Calamares

View File

@ -46,6 +46,7 @@ class DLLEXPORT RequirementsModel : public QAbstractListModel
Q_OBJECT Q_OBJECT
Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL ) Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL )
Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL ) Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL )
Q_PROPERTY( QString progressMessage READ progressMessage NOTIFY progressMessageChanged FINAL )
public: public:
using QAbstractListModel::QAbstractListModel; using QAbstractListModel::QAbstractListModel;
@ -65,6 +66,9 @@ public:
bool satisfiedRequirements() const { return m_satisfiedRequirements; } bool satisfiedRequirements() const { return m_satisfiedRequirements; }
///@brief Are all the **mandatory** requirements satisfied? ///@brief Are all the **mandatory** requirements satisfied?
bool satisfiedMandatory() const { return m_satisfiedMandatory; } bool satisfiedMandatory() const { return m_satisfiedMandatory; }
///@brief Message (from an ongoing check) about progress
QString progressMessage() const { return m_progressMessage; }
QVariant data( const QModelIndex& index, int role ) const override; QVariant data( const QModelIndex& index, int role ) const override;
int rowCount( const QModelIndex& ) const override; int rowCount( const QModelIndex& ) const override;
@ -76,6 +80,7 @@ public:
signals: signals:
void satisfiedRequirementsChanged( bool value ); void satisfiedRequirementsChanged( bool value );
void satisfiedMandatoryChanged( bool value ); void satisfiedMandatoryChanged( bool value );
void progressMessageChanged( QString message );
protected: protected:
QHash< int, QByteArray > roleNames() const override; QHash< int, QByteArray > roleNames() const override;
@ -83,10 +88,14 @@ protected:
///@brief Append some requirements; resets the model ///@brief Append some requirements; resets the model
void addRequirementsList( const Calamares::RequirementsList& requirements ); void addRequirementsList( const Calamares::RequirementsList& requirements );
///@brief Update progress message (called by the checker)
void setProgressMessage( const QString& m );
private: private:
///@brief Implementation for {set,add}RequirementsList ///@brief Implementation for {set,add}RequirementsList
void changeRequirementsList(); void changeRequirementsList();
QString m_progressMessage;
QMutex m_addLock; QMutex m_addLock;
RequirementsList m_requirements; RequirementsList m_requirements;
bool m_satisfiedRequirements = false; bool m_satisfiedRequirements = false;

View File

@ -358,7 +358,6 @@ ModuleManager::checkRequirements()
} }
RequirementsChecker* rq = new RequirementsChecker( modules, m_requirementsModel, this ); RequirementsChecker* rq = new RequirementsChecker( modules, m_requirementsModel, this );
connect( rq, &RequirementsChecker::requirementsProgress, this, &ModuleManager::requirementsProgress );
connect( rq, &RequirementsChecker::done, rq, &RequirementsChecker::deleteLater ); connect( rq, &RequirementsChecker::done, rq, &RequirementsChecker::deleteLater );
connect( rq, &RequirementsChecker::done, this, [=](){ this->requirementsComplete( m_requirementsModel->satisfiedMandatory() ); } ); connect( rq, &RequirementsChecker::done, this, [=](){ this->requirementsComplete( m_requirementsModel->satisfiedMandatory() ); } );

View File

@ -100,7 +100,6 @@ signals:
void modulesFailed( QStringList ); /// .. or not void modulesFailed( QStringList ); /// .. or not
// Below, see RequirementsChecker documentation // Below, see RequirementsChecker documentation
void requirementsComplete( bool ); void requirementsComplete( bool );
void requirementsProgress( const QString& );
private slots: private slots:
void doInit(); void doInit();