Instantiate DeviceModel in PartitionCoreModule

This commit is contained in:
Aurélien Gâteau 2014-06-30 13:48:40 +02:00
parent 4d2354fb56
commit 578f2e4baa
4 changed files with 17 additions and 6 deletions

View File

@ -18,6 +18,8 @@
#include <PartitionCoreModule.h>
#include <DeviceModel.h>
// CalaPM
#include <CalaPM.h>
#include <backend/corebackend.h>
@ -25,6 +27,7 @@
PartitionCoreModule::PartitionCoreModule( QObject* parent )
: QObject( parent )
, m_deviceModel( new DeviceModel( this ) )
{
// FIXME: Should be done at startup
if ( !CalaPM::init() )
@ -33,6 +36,8 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
}
CoreBackend* backend = CoreBackendManager::self()->backend();
m_devices = backend->scanDevices();
m_deviceModel->init( m_devices );
}
QList< Device* >
@ -40,3 +45,9 @@ PartitionCoreModule::devices() const
{
return m_devices;
}
DeviceModel*
PartitionCoreModule::deviceModel() const
{
return m_deviceModel;
}

View File

@ -23,6 +23,7 @@
#include <QObject>
class Device;
class DeviceModel;
/**
* Owns the Qt models and the PM devices
@ -34,8 +35,11 @@ public:
QList< Device* > devices() const;
DeviceModel* deviceModel() const;
private:
QList< Device* > m_devices;
DeviceModel* m_deviceModel;
void listDevices();
};

View File

@ -32,17 +32,14 @@ PartitionPage::PartitionPage( QWidget* parent )
: Calamares::AbstractPage( parent )
, m_ui( new Ui_PartitionPage )
, m_core( new PartitionCoreModule( this ) )
, m_deviceModel( new DeviceModel( this ) )
{
m_ui->setupUi( this );
m_ui->deviceListView->setModel( m_deviceModel );
m_deviceModel->init( m_core->devices() );
m_ui->deviceListView->setModel( m_core->deviceModel() );
connect( m_ui->deviceListView->selectionModel(), &QItemSelectionModel::currentChanged,
[ this ]( const QModelIndex& index, const QModelIndex& oldIndex )
{
PartitionModel* model = m_deviceModel->partitionModelForIndex( index );
PartitionModel* model = m_core->deviceModel()->partitionModelForIndex( index );
m_ui->partitionListView->setModel( model );
} );
}

View File

@ -42,7 +42,6 @@ public Q_SLOTS:
private:
QScopedPointer< Ui_PartitionPage > m_ui;
PartitionCoreModule* m_core;
DeviceModel* m_deviceModel;
};
#endif // PARTITIONPAGE_H