mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[welcome] Add a filtered model for unsatisfied requirements
This commit is contained in:
parent
d1165bea56
commit
f68d0f0628
2 changed files with 28 additions and 1 deletions
|
@ -32,6 +32,7 @@
|
|||
Config::Config( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_languages( CalamaresUtils::Locale::availableTranslations() )
|
||||
, m_filtermodel( std::make_unique< QSortFilterProxyModel >() )
|
||||
{
|
||||
initLanguages();
|
||||
|
||||
|
@ -97,6 +98,18 @@ Config::requirementsModel() const
|
|||
return Calamares::ModuleManager::instance()->requirementsModel();
|
||||
}
|
||||
|
||||
QAbstractItemModel*
|
||||
Config::unsatisfiedRequirements() const
|
||||
{
|
||||
if ( !m_filtermodel->sourceModel() )
|
||||
{
|
||||
m_filtermodel->setFilterRole( Calamares::RequirementsModel::Roles::Satisfied );
|
||||
m_filtermodel->setFilterFixedString( QStringLiteral( "false" ) );
|
||||
m_filtermodel->setSourceModel( requirementsModel() );
|
||||
}
|
||||
return m_filtermodel.get();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
Config::languageIcon() const
|
||||
|
|
|
@ -23,8 +23,11 @@
|
|||
#include "modulesystem/RequirementsModel.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QUrl>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Config : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -43,6 +46,14 @@ class Config : public QObject
|
|||
* satisfied. See the model documentation for details.
|
||||
*/
|
||||
Q_PROPERTY( Calamares::RequirementsModel* requirementsModel READ requirementsModel CONSTANT FINAL )
|
||||
/** @brief The requirements (from modules) that are **unsatisfied**
|
||||
*
|
||||
* This is the same as requirementsModel(), except filtered so
|
||||
* that only those requirements that are not satisfied are exposed.
|
||||
* Note that the type is different, so you should still use the
|
||||
* requirementsModel() for overall status like *satisfiedMandatory*.
|
||||
*/
|
||||
Q_PROPERTY( QAbstractItemModel* unsatisfiedRequirements READ unsatisfiedRequirements CONSTANT FINAL )
|
||||
|
||||
Q_PROPERTY( QString languageIcon READ languageIcon CONSTANT FINAL )
|
||||
|
||||
|
@ -96,6 +107,8 @@ public slots:
|
|||
///@brief The **global** requirements model, from ModuleManager
|
||||
Calamares::RequirementsModel* requirementsModel() const;
|
||||
|
||||
QAbstractItemModel* unsatisfiedRequirements() const;
|
||||
|
||||
signals:
|
||||
void countryCodeChanged( QString countryCode );
|
||||
void localeIndexChanged( int localeIndex );
|
||||
|
@ -112,7 +125,8 @@ signals:
|
|||
private:
|
||||
void initLanguages();
|
||||
|
||||
CalamaresUtils::Locale::LabelModel* m_languages;
|
||||
CalamaresUtils::Locale::LabelModel* m_languages = nullptr;
|
||||
std::unique_ptr< QSortFilterProxyModel > m_filtermodel;
|
||||
|
||||
QString m_languageIcon;
|
||||
QString m_countryCode;
|
||||
|
|
Loading…
Add table
Reference in a new issue