[netinstall] Various refactoring
- move ready-indication to Config - don't check pointers that can't be null - hand the whole Config to the page
This commit is contained in:
parent
4cdfe1276a
commit
85551f0fdb
@ -66,6 +66,7 @@ void
|
||||
Config::loadGroupList( const QVariantList& groupData )
|
||||
{
|
||||
m_model->setupModelData( groupData );
|
||||
emit statusReady();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -71,7 +71,8 @@ public:
|
||||
PackageModel* model() const { return m_model; }
|
||||
|
||||
signals:
|
||||
void statusChanged( QString status );
|
||||
void statusChanged( QString status ); ///< Something changed
|
||||
void statusReady(); ///< Loading groups is complete
|
||||
|
||||
private slots:
|
||||
void receivedGroupData(); ///< From async-loading group data
|
||||
|
@ -34,11 +34,16 @@
|
||||
#include <QHeaderView>
|
||||
#include <QNetworkReply>
|
||||
|
||||
NetInstallPage::NetInstallPage( QWidget* parent )
|
||||
NetInstallPage::NetInstallPage( Config* c, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_config( c )
|
||||
, ui( new Ui::Page_NetInst )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
ui->groupswidget->setModel( c->model() );
|
||||
connect( c, &Config::statusChanged, this, &NetInstallPage::setStatus );
|
||||
connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups );
|
||||
|
||||
setPageTitle( nullptr );
|
||||
CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate );
|
||||
}
|
||||
@ -63,16 +68,17 @@ NetInstallPage::setPageTitle( CalamaresUtils::Locale::TranslatedString* t )
|
||||
void
|
||||
NetInstallPage::retranslate()
|
||||
{
|
||||
if ( ui && m_title )
|
||||
if ( m_title )
|
||||
{
|
||||
ui->label->setText( m_title->get() ); // That's get() on the TranslatedString
|
||||
}
|
||||
ui->netinst_status->setText( m_config->status() );
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallPage::setModel( QAbstractItemModel* model )
|
||||
NetInstallPage::expandGroups()
|
||||
{
|
||||
ui->groupswidget->setModel( model );
|
||||
auto* model = m_config->model();
|
||||
// Go backwards because expanding a group may cause rows to appear below it
|
||||
for ( int i = model->rowCount() - 1; i >= 0; --i )
|
||||
{
|
||||
@ -84,6 +90,11 @@ NetInstallPage::setModel( QAbstractItemModel* model )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallPage::setStatus( QString s )
|
||||
{
|
||||
ui->netinst_status->setText( s );
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallPage::onActivate()
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef NETINSTALLPAGE_H
|
||||
#define NETINSTALLPAGE_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "PackageModel.h"
|
||||
#include "PackageTreeItem.h"
|
||||
|
||||
@ -42,7 +43,7 @@ class NetInstallPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetInstallPage( QWidget* parent = nullptr );
|
||||
NetInstallPage( Config* config, QWidget* parent = nullptr );
|
||||
virtual ~NetInstallPage();
|
||||
|
||||
/** @brief Sets the page title
|
||||
@ -56,24 +57,21 @@ public:
|
||||
*/
|
||||
void setPageTitle( CalamaresUtils::Locale::TranslatedString* );
|
||||
|
||||
/** @brief Sets the model of packages to display
|
||||
*
|
||||
* While setting up the UI, expand entries that should be pre-expanded.
|
||||
*
|
||||
* Follows the *expanded* key / the startExpanded field in the
|
||||
* group entries of the model. Call this after filling up the model.
|
||||
*/
|
||||
void setModel( QAbstractItemModel* );
|
||||
|
||||
void onActivate();
|
||||
|
||||
public slots:
|
||||
void retranslate();
|
||||
void setStatus( QString s );
|
||||
|
||||
signals:
|
||||
void checkReady( bool );
|
||||
/** @brief Expand entries that should be pre-expanded.
|
||||
*
|
||||
* Follows the *expanded* key / the startExpanded field in the
|
||||
* group entries of the model. Call this after filling up the model.
|
||||
*/
|
||||
void expandGroups();
|
||||
|
||||
private:
|
||||
Config* m_config;
|
||||
Ui::Page_NetInst* ui;
|
||||
|
||||
std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_title; // Above the treeview
|
||||
|
@ -32,12 +32,11 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin<
|
||||
|
||||
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_widget( new NetInstallPage() )
|
||||
, m_widget( new NetInstallPage( &m_config ) )
|
||||
, m_sidebarLabel( nullptr )
|
||||
, m_nextEnabled( false )
|
||||
{
|
||||
emit nextStatusChanged( true );
|
||||
connect( m_widget, &NetInstallPage::checkReady, this, &NetInstallViewStep::nextIsReady );
|
||||
connect( &m_config, &Config::statusReady, this, &NetInstallViewStep::nextIsReady );
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +85,7 @@ NetInstallViewStep::widget()
|
||||
bool
|
||||
NetInstallViewStep::isNextEnabled() const
|
||||
{
|
||||
return m_nextEnabled;
|
||||
return !m_config.required() || m_nextEnabled;
|
||||
}
|
||||
|
||||
|
||||
@ -192,17 +191,16 @@ NetInstallViewStep::onLeave()
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallViewStep::nextIsReady( bool b )
|
||||
NetInstallViewStep::nextIsReady()
|
||||
{
|
||||
m_nextEnabled = b;
|
||||
emit nextStatusChanged( b );
|
||||
m_nextEnabled = true;
|
||||
emit nextStatusChanged( true );
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_config.setRequired( CalamaresUtils::getBool( configurationMap, "required", false ) );
|
||||
m_widget->setModel( m_config.model() );
|
||||
|
||||
QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" );
|
||||
if ( !groupsUrl.isEmpty() )
|
||||
|
@ -59,14 +59,14 @@ public:
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
public slots:
|
||||
void nextIsReady( bool );
|
||||
void nextIsReady();
|
||||
|
||||
private:
|
||||
Config m_config;
|
||||
|
||||
NetInstallPage* m_widget;
|
||||
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel; // As it appears in the sidebar
|
||||
bool m_nextEnabled;
|
||||
bool m_nextEnabled = false;
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( NetInstallViewStepFactory )
|
||||
|
Loading…
Reference in New Issue
Block a user