[packagechooser] Allow the model to set the introductory text
This commit is contained in:
parent
047a300a51
commit
d5275d5e10
@ -86,6 +86,26 @@ void
|
|||||||
PackageChooserPage::setModel( QAbstractItemModel* model )
|
PackageChooserPage::setModel( QAbstractItemModel* model )
|
||||||
{
|
{
|
||||||
ui->products->setModel( model );
|
ui->products->setModel( model );
|
||||||
|
|
||||||
|
// Check if any of the items in the model is the "none" option.
|
||||||
|
// If so, copy its values into the introduction / none item.
|
||||||
|
for ( int r = 0; r < model->rowCount(); ++r )
|
||||||
|
{
|
||||||
|
auto index = model->index( r, 0 );
|
||||||
|
if ( index.isValid() )
|
||||||
|
{
|
||||||
|
QVariant v = model->data( index, PackageListModel::IdRole );
|
||||||
|
if ( v.isValid() && v.toString().isEmpty() )
|
||||||
|
{
|
||||||
|
m_introduction.name = model->data( index, PackageListModel::NameRole ).toString();
|
||||||
|
m_introduction.description = model->data( index, PackageListModel::DescriptionRole ).toString();
|
||||||
|
m_introduction.screenshot = model->data( index, PackageListModel::ScreenshotRole ).value< QPixmap >();
|
||||||
|
currentChanged( QModelIndex() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect( ui->products->selectionModel(),
|
connect( ui->products->selectionModel(),
|
||||||
&QItemSelectionModel::selectionChanged,
|
&QItemSelectionModel::selectionChanged,
|
||||||
this,
|
this,
|
||||||
|
@ -180,8 +180,15 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
|
|||||||
// TODO: replace this hard-coded model
|
// TODO: replace this hard-coded model
|
||||||
if ( !m_model )
|
if ( !m_model )
|
||||||
{
|
{
|
||||||
|
|
||||||
m_model = new PackageListModel( nullptr );
|
m_model = new PackageListModel( nullptr );
|
||||||
|
m_model->addPackage( PackageItem { QString(),
|
||||||
|
QString(),
|
||||||
|
"No Desktop",
|
||||||
|
"Please pick a desktop environment from the list. "
|
||||||
|
"If you don't want to install a desktop, that's fine, "
|
||||||
|
"your system will start up in text-only mode and you can "
|
||||||
|
"install a desktop environment later.",
|
||||||
|
":/images/no-selection.png" } );
|
||||||
m_model->addPackage( PackageItem { "kde", "kde", "Plasma", "Plasma Desktop", ":/images/kde.png" } );
|
m_model->addPackage( PackageItem { "kde", "kde", "Plasma", "Plasma Desktop", ":/images/kde.png" } );
|
||||||
m_model->addPackage( PackageItem {
|
m_model->addPackage( PackageItem {
|
||||||
"gnome", "gnome", "GNOME", "GNU Networked Object Modeling Environment Desktop", ":/images/gnome.png" } );
|
"gnome", "gnome", "GNOME", "GNU Networked Object Modeling Environment Desktop", ":/images/gnome.png" } );
|
||||||
|
Loading…
Reference in New Issue
Block a user