From 08138f5a41e5df36f269f196ffd2fc4f1028fcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Mon, 5 Oct 2020 11:39:04 +0200 Subject: [PATCH] [partition] Reduce direct dependency of PartUtils on PartitionCoreModule --- src/modules/partition/core/PartUtils.cpp | 9 +++------ src/modules/partition/core/PartUtils.h | 10 +++++----- src/modules/partition/core/PartitionCoreModule.cpp | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 099cdf299..36b5cefe2 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -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 ); } } diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index f5ca0ddaa..f210cc3ab 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -22,7 +22,7 @@ // Qt #include -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 diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index d78ef70c7..dc2324061 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -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