Instantiate DeviceModel in PartitionCoreModule
This commit is contained in:
parent
4d2354fb56
commit
578f2e4baa
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <PartitionCoreModule.h>
|
#include <PartitionCoreModule.h>
|
||||||
|
|
||||||
|
#include <DeviceModel.h>
|
||||||
|
|
||||||
// CalaPM
|
// CalaPM
|
||||||
#include <CalaPM.h>
|
#include <CalaPM.h>
|
||||||
#include <backend/corebackend.h>
|
#include <backend/corebackend.h>
|
||||||
@ -25,6 +27,7 @@
|
|||||||
|
|
||||||
PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
|
, m_deviceModel( new DeviceModel( this ) )
|
||||||
{
|
{
|
||||||
// FIXME: Should be done at startup
|
// FIXME: Should be done at startup
|
||||||
if ( !CalaPM::init() )
|
if ( !CalaPM::init() )
|
||||||
@ -33,6 +36,8 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
|||||||
}
|
}
|
||||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||||
m_devices = backend->scanDevices();
|
m_devices = backend->scanDevices();
|
||||||
|
|
||||||
|
m_deviceModel->init( m_devices );
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< Device* >
|
QList< Device* >
|
||||||
@ -40,3 +45,9 @@ PartitionCoreModule::devices() const
|
|||||||
{
|
{
|
||||||
return m_devices;
|
return m_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceModel*
|
||||||
|
PartitionCoreModule::deviceModel() const
|
||||||
|
{
|
||||||
|
return m_deviceModel;
|
||||||
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
class DeviceModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Owns the Qt models and the PM devices
|
* Owns the Qt models and the PM devices
|
||||||
@ -34,8 +35,11 @@ public:
|
|||||||
|
|
||||||
QList< Device* > devices() const;
|
QList< Device* > devices() const;
|
||||||
|
|
||||||
|
DeviceModel* deviceModel() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList< Device* > m_devices;
|
QList< Device* > m_devices;
|
||||||
|
DeviceModel* m_deviceModel;
|
||||||
|
|
||||||
void listDevices();
|
void listDevices();
|
||||||
};
|
};
|
||||||
|
@ -32,17 +32,14 @@ PartitionPage::PartitionPage( QWidget* parent )
|
|||||||
: Calamares::AbstractPage( parent )
|
: Calamares::AbstractPage( parent )
|
||||||
, m_ui( new Ui_PartitionPage )
|
, m_ui( new Ui_PartitionPage )
|
||||||
, m_core( new PartitionCoreModule( this ) )
|
, m_core( new PartitionCoreModule( this ) )
|
||||||
, m_deviceModel( new DeviceModel( this ) )
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
m_ui->setupUi( this );
|
||||||
m_ui->deviceListView->setModel( m_deviceModel );
|
m_ui->deviceListView->setModel( m_core->deviceModel() );
|
||||||
|
|
||||||
m_deviceModel->init( m_core->devices() );
|
|
||||||
|
|
||||||
connect( m_ui->deviceListView->selectionModel(), &QItemSelectionModel::currentChanged,
|
connect( m_ui->deviceListView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||||
[ this ]( const QModelIndex& index, const QModelIndex& oldIndex )
|
[ 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 );
|
m_ui->partitionListView->setModel( model );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ public Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
QScopedPointer< Ui_PartitionPage > m_ui;
|
QScopedPointer< Ui_PartitionPage > m_ui;
|
||||||
PartitionCoreModule* m_core;
|
PartitionCoreModule* m_core;
|
||||||
DeviceModel* m_deviceModel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTITIONPAGE_H
|
#endif // PARTITIONPAGE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user