[welcome] Replace widgets in dialog with model+listview
While here, remove unused vars and functions, tidy code.
This commit is contained in:
parent
ab1c78ca23
commit
8b917ace4d
@ -43,22 +43,19 @@ public:
|
|||||||
* The list must continue to exist for the lifetime of the dialog,
|
* The list must continue to exist for the lifetime of the dialog,
|
||||||
* or UB happens.
|
* or UB happens.
|
||||||
*/
|
*/
|
||||||
ResultsListDialog( const Calamares::RequirementsModel& model, QWidget* parent );
|
ResultsListDialog( QAbstractItemModel* model, QWidget* parent );
|
||||||
~ResultsListDialog() override;
|
~ResultsListDialog() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel* m_title;
|
QLabel* m_title;
|
||||||
const Calamares::RequirementsModel& m_model;
|
|
||||||
|
|
||||||
void retranslate();
|
void retranslate();
|
||||||
};
|
};
|
||||||
|
|
||||||
ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model, QWidget* parent )
|
ResultsListDialog::ResultsListDialog( QAbstractItemModel* model, QWidget* parent )
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
, m_model( model )
|
|
||||||
{
|
{
|
||||||
auto* mainLayout = new QVBoxLayout;
|
auto* mainLayout = new QVBoxLayout;
|
||||||
auto* entriesLayout = new QVBoxLayout;
|
|
||||||
|
|
||||||
m_title = new QLabel( this );
|
m_title = new QLabel( this );
|
||||||
m_title->setObjectName( "resultDialogTitle" );
|
m_title->setObjectName( "resultDialogTitle" );
|
||||||
@ -67,7 +64,15 @@ ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model,
|
|||||||
buttonBox->setObjectName( "resultDialogButtons" );
|
buttonBox->setObjectName( "resultDialogButtons" );
|
||||||
|
|
||||||
mainLayout->addWidget( m_title );
|
mainLayout->addWidget( m_title );
|
||||||
mainLayout->addLayout( entriesLayout );
|
|
||||||
|
auto* listview = new QListView( this );
|
||||||
|
listview->setSelectionMode( QAbstractItemView::NoSelection );
|
||||||
|
listview->setDragDropMode( QAbstractItemView::NoDragDrop );
|
||||||
|
listview->setAcceptDrops( false );
|
||||||
|
listview->setItemDelegate( new ResultDelegate( this, Calamares::RequirementsModel::Details ) );
|
||||||
|
listview->setModel( model );
|
||||||
|
|
||||||
|
mainLayout->addWidget( listview );
|
||||||
mainLayout->addWidget( buttonBox );
|
mainLayout->addWidget( buttonBox );
|
||||||
|
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
@ -96,8 +101,6 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent )
|
|||||||
auto mainLayout = new QVBoxLayout;
|
auto mainLayout = new QVBoxLayout;
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
|
|
||||||
int paddingSize = qBound( 32, CalamaresUtils::defaultFontHeight() * 4, 128 );
|
|
||||||
|
|
||||||
QHBoxLayout* explanationLayout = new QHBoxLayout;
|
QHBoxLayout* explanationLayout = new QHBoxLayout;
|
||||||
m_explanation = new QLabel( m_config->warningMessage() );
|
m_explanation = new QLabel( m_config->warningMessage() );
|
||||||
m_explanation->setWordWrap( true );
|
m_explanation->setWordWrap( true );
|
||||||
@ -117,7 +120,7 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent )
|
|||||||
listview->setSelectionMode( QAbstractItemView::NoSelection );
|
listview->setSelectionMode( QAbstractItemView::NoSelection );
|
||||||
listview->setDragDropMode( QAbstractItemView::NoDragDrop );
|
listview->setDragDropMode( QAbstractItemView::NoDragDrop );
|
||||||
listview->setAcceptDrops( false );
|
listview->setAcceptDrops( false );
|
||||||
listview->setItemDelegate( new ResultDelegate( this ) );
|
listview->setItemDelegate( new ResultDelegate( this, Calamares::RequirementsModel::NegatedText ) );
|
||||||
listview->setModel( config->unsatisfiedRequirements() );
|
listview->setModel( config->unsatisfiedRequirements() );
|
||||||
m_centralWidget = listview;
|
m_centralWidget = listview;
|
||||||
m_centralLayout = mainLayout;
|
m_centralLayout = mainLayout;
|
||||||
@ -143,7 +146,7 @@ ResultsListWidget::linkClicked( const QString& link )
|
|||||||
{
|
{
|
||||||
if ( link == "#details" )
|
if ( link == "#details" )
|
||||||
{
|
{
|
||||||
auto* dialog = new ResultsListDialog( *( m_config->requirementsModel() ), this );
|
auto* dialog = new ResultsListDialog( m_config->requirementsModel(), this );
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
}
|
}
|
||||||
@ -161,8 +164,6 @@ ResultsListWidget::requirementsChanged()
|
|||||||
// all *mandatory* entries are satisfied (gives errors if not).
|
// all *mandatory* entries are satisfied (gives errors if not).
|
||||||
|
|
||||||
const bool requirementsSatisfied = m_config->requirementsModel()->satisfiedRequirements();
|
const bool requirementsSatisfied = m_config->requirementsModel()->satisfiedRequirements();
|
||||||
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i )
|
|
||||||
{ return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); };
|
|
||||||
|
|
||||||
if ( requirementsSatisfied )
|
if ( requirementsSatisfied )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user