Merge branch 'development' into 3.2.x-stable
This commit is contained in:
commit
fd327aedc5
@ -53,10 +53,10 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @brief size the given @p pixmap to @p size
|
/** @brief size the given @p pixmap to @p size
|
||||||
*
|
*
|
||||||
* This is "smart" in the sense that it tries to keep the image un-scaled
|
* This is "smart" in the sense that it tries to keep the image un-scaled
|
||||||
* (if it's just a little too big) and otherwise scales as needed.
|
* (if it's just a little too big) and otherwise scales as needed.
|
||||||
*
|
*
|
||||||
* Returns a copy if any modifications are done.
|
* Returns a copy if any modifications are done.
|
||||||
*/
|
*/
|
||||||
static QPixmap
|
static QPixmap
|
||||||
@ -129,26 +129,7 @@ void
|
|||||||
PackageChooserPage::setModel( QAbstractItemModel* model )
|
PackageChooserPage::setModel( QAbstractItemModel* model )
|
||||||
{
|
{
|
||||||
ui->products->setModel( model );
|
ui->products->setModel( model );
|
||||||
|
currentChanged( QModelIndex() );
|
||||||
// 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,
|
||||||
@ -181,3 +162,10 @@ PackageChooserPage::selectedPackageIds() const
|
|||||||
}
|
}
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageChooserPage::setIntroduction( const PackageItem& item )
|
||||||
|
{
|
||||||
|
m_introduction.name = item.name;
|
||||||
|
m_introduction.description = item.description;
|
||||||
|
}
|
||||||
|
@ -37,6 +37,8 @@ public:
|
|||||||
|
|
||||||
void setModel( QAbstractItemModel* model );
|
void setModel( QAbstractItemModel* model );
|
||||||
|
|
||||||
|
/// @brief Sets the introductory (no-package-selected) texts
|
||||||
|
void setIntroduction( const PackageItem& item );
|
||||||
/// @brief Is anything selected?
|
/// @brief Is anything selected?
|
||||||
bool hasSelection() const;
|
bool hasSelection() const;
|
||||||
/** @brief Get the list of selected ids
|
/** @brief Get the list of selected ids
|
||||||
|
@ -283,4 +283,13 @@ PackageChooserViewStep::hookupModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_widget->setModel( m_model );
|
m_widget->setModel( m_model );
|
||||||
|
for ( int i = 0; i < m_model->packageCount(); ++i )
|
||||||
|
{
|
||||||
|
const auto& package = m_model->packageData( i );
|
||||||
|
if ( package.id.isEmpty() )
|
||||||
|
{
|
||||||
|
m_widget->setIntroduction( package );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ private:
|
|||||||
// Configuration
|
// Configuration
|
||||||
PackageChooserMode m_mode;
|
PackageChooserMode m_mode;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
CalamaresUtils::Locale::TranslatedString *m_stepName; // As it appears in the sidebar
|
CalamaresUtils::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )
|
||||||
|
@ -80,6 +80,14 @@ struct PackageItem
|
|||||||
* A valid item has an untranslated name available.
|
* A valid item has an untranslated name available.
|
||||||
*/
|
*/
|
||||||
bool isValid() const { return !name.isEmpty(); }
|
bool isValid() const { return !name.isEmpty(); }
|
||||||
|
|
||||||
|
/** @brief Is this a (the) No-Package package?
|
||||||
|
*
|
||||||
|
* There should be at most one No-Package item in a collection
|
||||||
|
* of PackageItems. That one will be used to describe a
|
||||||
|
* "no package" situation.
|
||||||
|
*/
|
||||||
|
bool isNonePackage() const { return id.isEmpty(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
using PackageList = QVector< PackageItem >;
|
using PackageList = QVector< PackageItem >;
|
||||||
@ -100,6 +108,11 @@ public:
|
|||||||
int rowCount( const QModelIndex& index ) const override;
|
int rowCount( const QModelIndex& index ) const override;
|
||||||
QVariant data( const QModelIndex& index, int role ) const override;
|
QVariant data( const QModelIndex& index, int role ) const override;
|
||||||
|
|
||||||
|
/// @brief Direct (non-abstract) access to package data
|
||||||
|
const PackageItem& packageData( int r ) const { return m_packages[ r ]; }
|
||||||
|
/// @brief Direct (non-abstract) count of package data
|
||||||
|
int packageCount() const { return m_packages.count(); }
|
||||||
|
|
||||||
enum Roles : int
|
enum Roles : int
|
||||||
{
|
{
|
||||||
NameRole = Qt::DisplayRole,
|
NameRole = Qt::DisplayRole,
|
||||||
|
Loading…
Reference in New Issue
Block a user