[partition] Reduce direct dependency of PartUtils on PartitionCoreModule
This commit is contained in:
parent
063482339f
commit
08138f5a41
@ -11,8 +11,6 @@
|
||||
|
||||
#include "PartUtils.h"
|
||||
|
||||
#include "PartitionCoreModule.h"
|
||||
|
||||
#include "core/DeviceModel.h"
|
||||
#include "core/KPMHelpers.h"
|
||||
#include "core/PartitionInfo.h"
|
||||
@ -198,13 +196,12 @@ canBeResized( Partition* candidate )
|
||||
|
||||
|
||||
bool
|
||||
canBeResized( PartitionCoreModule* core, const QString& partitionPath )
|
||||
canBeResized( DeviceModel* dm, const QString& partitionPath )
|
||||
{
|
||||
cDebug() << "Checking if" << partitionPath << "can be resized.";
|
||||
QString partitionWithOs = partitionPath;
|
||||
if ( partitionWithOs.startsWith( "/dev/" ) )
|
||||
{
|
||||
DeviceModel* dm = core->deviceModel();
|
||||
for ( int i = 0; i < dm->rowCount(); ++i )
|
||||
{
|
||||
Device* dev = dm->deviceForIndex( dm->index( i ) );
|
||||
@ -358,7 +355,7 @@ findPartitionPathForMountPoint( const FstabEntryList& fstab, const QString& moun
|
||||
|
||||
|
||||
OsproberEntryList
|
||||
runOsprober( PartitionCoreModule* core )
|
||||
runOsprober( DeviceModel* dm )
|
||||
{
|
||||
QString osproberOutput;
|
||||
QProcess osprober;
|
||||
@ -406,7 +403,7 @@ runOsprober( PartitionCoreModule* core )
|
||||
QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" );
|
||||
|
||||
osproberEntries.append(
|
||||
{ prettyName, path, QString(), canBeResized( core, path ), lineColumns, fstabEntries, homePath } );
|
||||
{ prettyName, path, QString(), canBeResized( dm, path ), lineColumns, fstabEntries, homePath } );
|
||||
osproberCleanLines.append( line );
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
// Qt
|
||||
#include <QString>
|
||||
|
||||
class PartitionCoreModule;
|
||||
class DeviceModel;
|
||||
class Partition;
|
||||
|
||||
namespace PartUtils
|
||||
@ -56,19 +56,19 @@ bool canBeResized( Partition* candidate );
|
||||
/**
|
||||
* @brief canBeReplaced checks whether the given Partition satisfies the criteria
|
||||
* for resizing (shrinking) it to make room for a new OS.
|
||||
* @param core the PartitionCoreModule instance.
|
||||
* @param dm the DeviceModel instance.
|
||||
* @param partitionPath the device path of the candidate partition to resize.
|
||||
* @return true if the criteria are met, otherwise false.
|
||||
*/
|
||||
bool canBeResized( PartitionCoreModule* core, const QString& partitionPath );
|
||||
bool canBeResized( DeviceModel* dm, const QString& partitionPath );
|
||||
|
||||
/**
|
||||
* @brief runOsprober executes os-prober, parses the output and writes relevant
|
||||
* data to GlobalStorage.
|
||||
* @param core the PartitionCoreModule instance.
|
||||
* @param dm the DeviceModel instance.
|
||||
* @return a list of os-prober entries, parsed.
|
||||
*/
|
||||
OsproberEntryList runOsprober( PartitionCoreModule* core );
|
||||
OsproberEntryList runOsprober( DeviceModel* dm );
|
||||
|
||||
/**
|
||||
* @brief Is this system EFI-enabled? Decides based on /sys/firmware/efi
|
||||
|
@ -180,7 +180,7 @@ PartitionCoreModule::doInit()
|
||||
|
||||
// The following PartUtils::runOsprober call in turn calls PartUtils::canBeResized,
|
||||
// which relies on a working DeviceModel.
|
||||
m_osproberLines = PartUtils::runOsprober( this );
|
||||
m_osproberLines = PartUtils::runOsprober( this->deviceModel() );
|
||||
|
||||
// We perform a best effort of filling out filesystem UUIDs in m_osproberLines
|
||||
// because we will need them later on in PartitionModel if partition paths
|
||||
|
Loading…
Reference in New Issue
Block a user