[packagechooser] Enforce selection mode on the next-button
This commit is contained in:
parent
7609546d8b
commit
86d8db6bbf
@ -80,6 +80,7 @@ PackageChooserPage::updateLabels()
|
||||
{
|
||||
currentChanged( QModelIndex() );
|
||||
}
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
void
|
||||
@ -91,3 +92,9 @@ PackageChooserPage::setModel( QAbstractItemModel* model )
|
||||
this,
|
||||
&PackageChooserPage::updateLabels );
|
||||
}
|
||||
|
||||
bool
|
||||
PackageChooserPage::hasSelection() const
|
||||
{
|
||||
return ui && ui->products && ui->products->selectionModel() && ui->products->selectionModel()->hasSelection();
|
||||
}
|
||||
|
@ -37,10 +37,15 @@ public:
|
||||
|
||||
void setModel( QAbstractItemModel* model );
|
||||
|
||||
bool hasSelection() const;
|
||||
|
||||
public slots:
|
||||
void currentChanged( const QModelIndex& index );
|
||||
void updateLabels();
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
Ui::PackageChooserPage* ui;
|
||||
PackageItem m_introduction;
|
||||
|
@ -37,7 +37,7 @@ PackageChooserViewStep::PackageChooserViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_widget( nullptr )
|
||||
, m_model( nullptr )
|
||||
, m_mode( PackageChooserMode::Optional )
|
||||
, m_mode( PackageChooserMode::Exclusive )
|
||||
{
|
||||
emit nextStatusChanged( false );
|
||||
}
|
||||
@ -66,6 +66,10 @@ PackageChooserViewStep::widget()
|
||||
if ( !m_widget )
|
||||
{
|
||||
m_widget = new PackageChooserPage( m_mode, nullptr );
|
||||
connect( m_widget, &PackageChooserPage::selectionChanged, [=]() {
|
||||
emit nextStatusChanged( this->isNextEnabled() );
|
||||
} );
|
||||
|
||||
if ( m_model )
|
||||
{
|
||||
hookupModel();
|
||||
@ -96,17 +100,13 @@ PackageChooserViewStep::isNextEnabled() const
|
||||
switch ( m_mode )
|
||||
{
|
||||
case PackageChooserMode::Optional:
|
||||
// zero or one
|
||||
return false;
|
||||
case PackageChooserMode::Exclusive:
|
||||
// exactly one
|
||||
return false;
|
||||
case PackageChooserMode::Multiple:
|
||||
// zero or more
|
||||
// zero or one OR zero or more
|
||||
return true;
|
||||
case PackageChooserMode::Exclusive:
|
||||
case PackageChooserMode::RequiredMultiple:
|
||||
// one or more
|
||||
return false;
|
||||
// exactly one OR one or more
|
||||
return m_widget->hasSelection();
|
||||
}
|
||||
|
||||
NOTREACHED return true;
|
||||
|
Loading…
Reference in New Issue
Block a user