|
|
|
|
@ -36,6 +36,9 @@
|
|
|
|
|
#include <backend/corebackend.h>
|
|
|
|
|
#include <backend/corebackendmanager.h>
|
|
|
|
|
|
|
|
|
|
// Qt
|
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
|
|
|
|
|
class PartitionIterator
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
@ -149,6 +152,7 @@ PartitionCoreModule::DeviceInfo::forgetChanges()
|
|
|
|
|
PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
|
|
|
|
: QObject( parent )
|
|
|
|
|
, m_deviceModel( new DeviceModel( this ) )
|
|
|
|
|
, m_bootLoaderModel( new QStandardItemModel( this ) )
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Should be done at startup
|
|
|
|
|
if ( !CalaPM::init() )
|
|
|
|
|
@ -178,6 +182,12 @@ PartitionCoreModule::deviceModel() const
|
|
|
|
|
return m_deviceModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel*
|
|
|
|
|
PartitionCoreModule::bootLoaderModel() const
|
|
|
|
|
{
|
|
|
|
|
return m_bootLoaderModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PartitionModel*
|
|
|
|
|
PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
|
|
|
|
{
|
|
|
|
|
@ -322,6 +332,7 @@ PartitionCoreModule::refresh( Device* device )
|
|
|
|
|
Q_ASSERT( model );
|
|
|
|
|
model->reload();
|
|
|
|
|
updateHasRootMountPoint();
|
|
|
|
|
updateBootLoaderModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PartitionCoreModule::updateHasRootMountPoint()
|
|
|
|
|
@ -352,3 +363,54 @@ PartitionCoreModule::infoForDevice( Device* device ) const
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QStandardItem*
|
|
|
|
|
createBootLoaderItem( const QString& description, const QString& path )
|
|
|
|
|
{
|
|
|
|
|
QString text = PartitionCoreModule::tr( "%1 (%2)" )
|
|
|
|
|
.arg( description )
|
|
|
|
|
.arg( path );
|
|
|
|
|
QStandardItem* item = new QStandardItem( text );
|
|
|
|
|
item->setData( path, PartitionCoreModule::BootLoaderPathRole );
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
PartitionCoreModule::updateBootLoaderModel()
|
|
|
|
|
{
|
|
|
|
|
m_bootLoaderModel->clear();
|
|
|
|
|
// Can contain up to 2 entries:
|
|
|
|
|
// - MBR of disk which contains /boot or /
|
|
|
|
|
// - /boot or / partition
|
|
|
|
|
QString partitionText;
|
|
|
|
|
Partition* partition = findPartitionByMountPoint( "/boot" );
|
|
|
|
|
if ( partition )
|
|
|
|
|
partitionText = tr( "Boot Partition" );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
partition = findPartitionByMountPoint( "/" );
|
|
|
|
|
if ( partition )
|
|
|
|
|
partitionText = tr( "System Partition" );
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_bootLoaderModel->appendRow(
|
|
|
|
|
createBootLoaderItem( tr( "Master Boot Record" ), partition->devicePath() )
|
|
|
|
|
);
|
|
|
|
|
m_bootLoaderModel->appendRow(
|
|
|
|
|
createBootLoaderItem( partitionText, partition->partitionPath() )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Partition*
|
|
|
|
|
PartitionCoreModule::findPartitionByMountPoint( const QString& mountPoint ) const
|
|
|
|
|
{
|
|
|
|
|
for ( auto deviceInfo : m_deviceInfos )
|
|
|
|
|
{
|
|
|
|
|
Device* device = deviceInfo->device.data();
|
|
|
|
|
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
|
|
|
|
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
|
|
|
|
return *it;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|