[packagechooser] Set GlobalStorage packagechooser_<id>
This commit is contained in:
parent
c59ffc7765
commit
140c0db7a4
@ -98,3 +98,24 @@ PackageChooserPage::hasSelection() const
|
||||
{
|
||||
return ui && ui->products && ui->products->selectionModel() && ui->products->selectionModel()->hasSelection();
|
||||
}
|
||||
|
||||
QStringList
|
||||
PackageChooserPage::selectedPackageIds() const
|
||||
{
|
||||
if ( !( ui && ui->products && ui->products->selectionModel() ) )
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
const auto* model = ui->products->model();
|
||||
QStringList ids;
|
||||
for ( const auto& index : ui->products->selectionModel()->selectedIndexes() )
|
||||
{
|
||||
QString pid = model->data( index, PackageListModel::IdRole ).toString();
|
||||
if ( !pid.isEmpty() )
|
||||
{
|
||||
ids.append( pid );
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
@ -37,7 +37,13 @@ public:
|
||||
|
||||
void setModel( QAbstractItemModel* model );
|
||||
|
||||
/// @brief Is anything selected?
|
||||
bool hasSelection() const;
|
||||
/** @brief Get the list of selected ids
|
||||
*
|
||||
* This list may be empty (if none is selected).
|
||||
*/
|
||||
QStringList selectedPackageIds() const;
|
||||
|
||||
public slots:
|
||||
void currentChanged( const QModelIndex& index );
|
||||
|
@ -137,6 +137,15 @@ PackageChooserViewStep::isAtEnd() const
|
||||
void
|
||||
PackageChooserViewStep::onLeave()
|
||||
{
|
||||
QString key = QStringLiteral( "packagechooser_%1" ).arg( m_id );
|
||||
QString value;
|
||||
if ( m_widget->hasSelection() )
|
||||
{
|
||||
value = m_widget->selectedPackageIds().join( ',' );
|
||||
}
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( key, value );
|
||||
|
||||
cDebug() << "PackageChooser" << key << "selected" << value;
|
||||
}
|
||||
|
||||
Calamares::JobList
|
||||
|
@ -128,6 +128,10 @@ PackageListModel::data( const QModelIndex& index, int role ) const
|
||||
{
|
||||
return m_packages[ row ].screenshot;
|
||||
}
|
||||
else if ( role == IdRole )
|
||||
{
|
||||
return m_packages[ row ].id;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -84,7 +84,8 @@ public:
|
||||
{
|
||||
NameRole = Qt::DisplayRole,
|
||||
DescriptionRole = Qt::UserRole,
|
||||
ScreenshotRole
|
||||
ScreenshotRole,
|
||||
IdRole
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -7,6 +7,9 @@
|
||||
# If there is just one packagechooser module, and no *id* is set,
|
||||
# resulting GS key is probably *packagechooser_packagechooser*.
|
||||
#
|
||||
# The GS value is a comma-separated list of the IDs of the selected
|
||||
# packages, or an empty string if none is selected.
|
||||
#
|
||||
# id: ""
|
||||
|
||||
# Software selection mode, to set whether the software packages
|
||||
|
Loading…
Reference in New Issue
Block a user