[packagechooser] Update other parts of the window on selection
This commit is contained in:
parent
f8d159dfa4
commit
dc5cdbb38c
@ -28,29 +28,51 @@
|
||||
PackageChooserPage::PackageChooserPage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::PackageChooserPage )
|
||||
, m_introduction( QString(),
|
||||
QString(),
|
||||
tr( "Package Selection" ),
|
||||
tr( "Please pick a product from the list. The selected product will be installed." ) )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
CALAMARES_RETRANSLATE( updateLabels(); )
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::currentChanged( const QModelIndex& index )
|
||||
{
|
||||
if ( !index.isValid() || !ui->products->selectionModel()->hasSelection() )
|
||||
{
|
||||
ui->productName->setText( m_introduction.name );
|
||||
ui->productScreenshot->setPixmap( m_introduction.screenshot );
|
||||
ui->productDescription->setText( m_introduction.description );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->productName->setText( QString::number( index.row() ) );
|
||||
ui->productScreenshot->hide();
|
||||
ui->productDescription->setText( "derp" );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::updateLabels()
|
||||
{
|
||||
ui->productName->setText( QString() );
|
||||
ui->productScreenshot->hide();
|
||||
ui->productDescription->setText( tr( "Please pick a product from the list." ) );
|
||||
if ( ui && ui->products && ui->products->selectionModel() )
|
||||
{
|
||||
currentChanged( ui->products->selectionModel()->currentIndex() );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentChanged( QModelIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::setModel( QAbstractItemModel* model )
|
||||
{
|
||||
ui->products->setModel( model );
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::currentChanged( const QModelIndex& current )
|
||||
{
|
||||
updateLabels();
|
||||
cDebug() << "Current updated to" << current.row();
|
||||
cDebug() << ui->products->model()->data( current, Qt::DisplayRole );
|
||||
connect( ui->products->selectionModel(),
|
||||
&QItemSelectionModel::selectionChanged,
|
||||
this,
|
||||
&PackageChooserPage::updateLabels );
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef PACKAGECHOOSERPAGE_H
|
||||
#define PACKAGECHOOSERPAGE_H
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QWidget>
|
||||
|
||||
@ -36,11 +38,12 @@ public:
|
||||
void setModel( QAbstractItemModel* model );
|
||||
|
||||
public slots:
|
||||
void currentChanged( const QModelIndex& index );
|
||||
void updateLabels();
|
||||
void currentChanged( const QModelIndex& current );
|
||||
|
||||
private:
|
||||
Ui::PackageChooserPage* ui;
|
||||
PackageItem m_introduction;
|
||||
};
|
||||
|
||||
#endif // PACKAGECHOOSERPAGE_H
|
||||
|
@ -73,7 +73,6 @@ PackageListModel::rowCount( const QModelIndex& index ) const
|
||||
QVariant
|
||||
PackageListModel::data( const QModelIndex& index, int role ) const
|
||||
{
|
||||
cDebug() << "Data" << m_packages.count() << index.isValid() << ( index.isValid() ? index.row() : -1 );
|
||||
if ( !index.isValid() )
|
||||
{
|
||||
return QVariant();
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QVector>
|
||||
|
||||
struct PackageItem
|
||||
@ -32,9 +33,15 @@ struct PackageItem
|
||||
QString name;
|
||||
QString description;
|
||||
// TODO: may be more than one
|
||||
// QPixmap screenshot;
|
||||
QPixmap screenshot;
|
||||
|
||||
/// @brief Create blank PackageItem
|
||||
PackageItem();
|
||||
/** @brief Creates a PackageItem from given strings
|
||||
*
|
||||
* This constructor sets all the text members,
|
||||
* but leaves the screenshot blank. Set that separately.
|
||||
*/
|
||||
PackageItem( const QString& id, const QString& package, const QString& name, const QString& description );
|
||||
|
||||
// TODO: implement this
|
||||
|
Loading…
Reference in New Issue
Block a user