Convert more enums to scoped enums.
This commit is contained in:
parent
ee2688d4d9
commit
622def3b56
|
@ -31,7 +31,7 @@
|
|||
#include <QTemporaryFile>
|
||||
#include <QTextStream>
|
||||
|
||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QString& m_deviceNode);
|
||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode);
|
||||
static QString findBlkIdDevice(const char *token, const QString& value);
|
||||
|
||||
struct FstabEntryPrivate
|
||||
|
@ -44,7 +44,7 @@ struct FstabEntryPrivate
|
|||
int m_dumpFreq;
|
||||
int m_passNumber;
|
||||
QString m_comment;
|
||||
FstabEntryType m_entryType;
|
||||
FstabEntry::Type m_entryType;
|
||||
};
|
||||
|
||||
FstabEntry::FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq, int passNumber, const QString& comment) :
|
||||
|
@ -103,7 +103,7 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
|
|||
}
|
||||
|
||||
fstabFile.close();
|
||||
if (fstabEntries.back().entryType() == comment && fstabEntries.back().comment().isEmpty())
|
||||
if (fstabEntries.back().entryType() == FstabEntry::Type::comment && fstabEntries.back().comment().isEmpty())
|
||||
fstabEntries.pop_back();
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ const QString& FstabEntry::comment() const
|
|||
return d->m_comment;
|
||||
}
|
||||
|
||||
FstabEntryType FstabEntry::entryType() const
|
||||
FstabEntry::Type FstabEntry::entryType() const
|
||||
{
|
||||
return d->m_entryType;
|
||||
}
|
||||
|
@ -207,23 +207,23 @@ static QString findBlkIdDevice(const char *token, const QString& value)
|
|||
return rval;
|
||||
}
|
||||
|
||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QString& m_deviceNode)
|
||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode)
|
||||
{
|
||||
m_entryType = FstabEntryType::comment;
|
||||
m_entryType = FstabEntry::Type::comment;
|
||||
if (m_fsSpec.startsWith(QStringLiteral("UUID="))) {
|
||||
m_entryType = FstabEntryType::uuid;
|
||||
m_entryType = FstabEntry::Type::uuid;
|
||||
m_deviceNode = findBlkIdDevice("UUID", QString(m_fsSpec).remove(QStringLiteral("UUID=")));
|
||||
} else if (m_fsSpec.startsWith(QStringLiteral("LABEL="))) {
|
||||
m_entryType = FstabEntryType::label;
|
||||
m_entryType = FstabEntry::Type::label;
|
||||
m_deviceNode = findBlkIdDevice("LABEL", QString(m_fsSpec).remove(QStringLiteral("LABEL=")));
|
||||
} else if (m_fsSpec.startsWith(QStringLiteral("PARTUUID="))) {
|
||||
m_entryType = FstabEntryType::uuid;
|
||||
m_entryType = FstabEntry::Type::uuid;
|
||||
m_deviceNode = findBlkIdDevice("PARTUUID", QString(m_fsSpec).remove(QStringLiteral("PARTUUID=")));
|
||||
} else if (m_fsSpec.startsWith(QStringLiteral("PARTLABEL="))) {
|
||||
m_entryType = FstabEntryType::label;
|
||||
m_entryType = FstabEntry::Type::label;
|
||||
m_deviceNode = findBlkIdDevice("PARTLABEL", QString(m_fsSpec).remove(QStringLiteral("PARTLABEL=")));
|
||||
} else if (m_fsSpec.startsWith(QStringLiteral("/"))) {
|
||||
m_entryType = FstabEntryType::deviceNode;
|
||||
m_entryType = FstabEntry::Type::deviceNode;
|
||||
m_deviceNode = m_fsSpec;
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QS
|
|||
static void writeEntry(QFile& output, const FstabEntry& entry)
|
||||
{
|
||||
QTextStream s(&output);
|
||||
if (entry.entryType() == FstabEntryType::comment) {
|
||||
if (entry.entryType() == FstabEntry::Type::comment) {
|
||||
s << entry.comment() << "\n";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
struct FstabEntryPrivate;
|
||||
|
||||
enum FstabEntryType { deviceNode, uuid, label, partlabel, partuuid, comment };
|
||||
|
||||
/** Base class for fstab handling.
|
||||
|
||||
FstabEntry stores a single line of /etc/fstab file which can be a comment
|
||||
|
@ -39,6 +37,8 @@ enum FstabEntryType { deviceNode, uuid, label, partlabel, partuuid, comment };
|
|||
class LIBKPMCORE_EXPORT FstabEntry
|
||||
{
|
||||
public:
|
||||
enum class Type { deviceNode, uuid, label, partlabel, partuuid, comment };
|
||||
|
||||
FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq = 0, int passNumber = 0, const QString& comment = QString());
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
/**
|
||||
* @return the type of fstab entry, e.g. device node or UUID or comment only
|
||||
*/
|
||||
FstabEntryType entryType() const;
|
||||
Type entryType() const;
|
||||
|
||||
/**
|
||||
* @param s the new value for the fs_spec field of fstab entry
|
||||
|
|
|
@ -85,10 +85,10 @@ bool PartitionAlignment::isAligned(const Device& d, const Partition& p, bool qui
|
|||
bool PartitionAlignment::isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet)
|
||||
{
|
||||
if (firstDelta(d, p, newFirst) && !quiet)
|
||||
Log(Log::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst));
|
||||
Log(Log::Level::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst));
|
||||
|
||||
if (lastDelta(d, p, newLast) && !quiet)
|
||||
Log(Log::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast));
|
||||
Log(Log::Level::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast));
|
||||
|
||||
return firstDelta(d, p, newFirst) == 0 && lastDelta(d, p, newLast) == 0;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ SmartAttribute::SmartAttribute(const SmartAttributeParsedData& a) :
|
|||
m_Id(a.id()),
|
||||
m_Name(getAttrName(a.id())),
|
||||
m_Desc(getAttrDescription(a.id())),
|
||||
m_FailureType(a.prefailure() ? PreFailure : OldAge),
|
||||
m_UpdateType(a.online() ? Online : Offline),
|
||||
m_FailureType(a.prefailure() ? FailureType::PreFailure : FailureType::OldAge),
|
||||
m_UpdateType(a.online() ? UpdateType::Online : UpdateType::Offline),
|
||||
m_Current(a.currentValueValid() ? a.currentValue() : -1),
|
||||
m_Worst(a.worstValueValid() ? a.worstValue() : -1),
|
||||
m_Threshold(a.thresholdValid() ? a.threshold() : -1),
|
||||
|
@ -50,19 +50,19 @@ SmartAttribute::SmartAttribute(const SmartAttributeParsedData& a) :
|
|||
QString SmartAttribute::assessmentToString(Assessment a)
|
||||
{
|
||||
switch (a) {
|
||||
case Failing:
|
||||
case Assessment::Failing:
|
||||
return xi18nc("@item:intable", "failing");
|
||||
|
||||
case HasFailed:
|
||||
case Assessment::HasFailed:
|
||||
return xi18nc("@item:intable", "has failed");
|
||||
|
||||
case Warning:
|
||||
case Assessment::Warning:
|
||||
return xi18nc("@item:intable", "warning");
|
||||
|
||||
case Good:
|
||||
case Assessment::Good:
|
||||
return xi18nc("@item:intable", "good");
|
||||
|
||||
case NotApplicable:
|
||||
case Assessment::NotApplicable:
|
||||
default:
|
||||
return xi18nc("@item:intable not applicable", "N/A");
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ static QString getAttrDescription(qint32 id)
|
|||
|
||||
static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData& a)
|
||||
{
|
||||
SmartAttribute::Assessment rval = SmartAttribute::NotApplicable;
|
||||
SmartAttribute::Assessment rval = SmartAttribute::Assessment::NotApplicable;
|
||||
|
||||
bool failed = false;
|
||||
bool hasFailed = false;
|
||||
|
@ -235,13 +235,13 @@ static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData&
|
|||
}
|
||||
|
||||
if (failed)
|
||||
rval = SmartAttribute::Failing;
|
||||
rval = SmartAttribute::Assessment::Failing;
|
||||
else if (hasFailed)
|
||||
rval = SmartAttribute::HasFailed;
|
||||
rval = SmartAttribute::Assessment::HasFailed;
|
||||
else if (a.warn())
|
||||
rval = SmartAttribute::Warning;
|
||||
rval = SmartAttribute::Assessment::Warning;
|
||||
else if (a.goodNowValid())
|
||||
rval = SmartAttribute::Good;
|
||||
rval = SmartAttribute::Assessment::Good;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
|
|
@ -27,17 +27,17 @@ class SmartAttributeParsedData;
|
|||
class LIBKPMCORE_EXPORT SmartAttribute
|
||||
{
|
||||
public:
|
||||
enum FailureType {
|
||||
enum class FailureType {
|
||||
PreFailure,
|
||||
OldAge
|
||||
};
|
||||
|
||||
enum UpdateType {
|
||||
enum class UpdateType {
|
||||
Online,
|
||||
Offline
|
||||
};
|
||||
|
||||
enum Assessment {
|
||||
enum class Assessment {
|
||||
NotApplicable,
|
||||
Failing,
|
||||
HasFailed,
|
||||
|
|
|
@ -34,7 +34,7 @@ SmartDiskInformation::SmartDiskInformation() :
|
|||
m_BadAttributeNow(false),
|
||||
m_BadAttributeInThePast(false),
|
||||
m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER),
|
||||
m_Overall(SmartDiskInformation::SMART_OVERALL_BAD_STATUS)
|
||||
m_Overall(SmartDiskInformation::Overall::BadStatus)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -62,36 +62,35 @@ void SmartDiskInformation::updateBadSectors()
|
|||
void SmartDiskInformation::updateOverall()
|
||||
{
|
||||
if (!smartStatus()) {
|
||||
m_Overall = SMART_OVERALL_BAD_STATUS;
|
||||
m_Overall = Overall::BadStatus;
|
||||
return;
|
||||
}
|
||||
|
||||
quint64 sector_threshold = u64log2(size() / 512) * 1024;
|
||||
|
||||
if (badSectors() >= sector_threshold) {
|
||||
m_Overall = SMART_OVERALL_BAD_SECTOR_MANY;
|
||||
m_Overall = Overall::BadSectorsMany;
|
||||
return;
|
||||
}
|
||||
|
||||
validateBadAttributes();
|
||||
|
||||
if (m_BadAttributeNow) {
|
||||
m_Overall = SMART_OVERALL_BAD_ATTRIBUTE_NOW;
|
||||
m_Overall = Overall::BadAttributeNow;
|
||||
return;
|
||||
}
|
||||
|
||||
if (badSectors() > 0) {
|
||||
m_Overall = SMART_OVERALL_BAD_SECTOR;
|
||||
m_Overall = Overall::BadSector;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_BadAttributeInThePast) {
|
||||
m_Overall = SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST;
|
||||
m_Overall = Overall::BadAttributeInThePast;
|
||||
return;
|
||||
}
|
||||
|
||||
m_Overall = SMART_OVERALL_GOOD;
|
||||
|
||||
m_Overall = Overall::Good;
|
||||
}
|
||||
|
||||
/** Update the temperature value based on SMART attributes
|
||||
|
|
|
@ -48,14 +48,13 @@ public:
|
|||
};
|
||||
|
||||
/** SMART overall state */
|
||||
enum SmartOverall {
|
||||
SMART_OVERALL_GOOD,
|
||||
SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST,
|
||||
SMART_OVERALL_BAD_SECTOR,
|
||||
SMART_OVERALL_BAD_ATTRIBUTE_NOW,
|
||||
SMART_OVERALL_BAD_SECTOR_MANY,
|
||||
SMART_OVERALL_BAD_STATUS,
|
||||
_SMART_OVERALL_MAX
|
||||
enum class Overall {
|
||||
Good,
|
||||
BadAttributeInThePast,
|
||||
BadSector,
|
||||
BadAttributeNow,
|
||||
BadSectorsMany,
|
||||
BadStatus,
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -105,7 +104,7 @@ public:
|
|||
return m_SelfTestExecutionStatus; /**< @return SMART self execution status */
|
||||
}
|
||||
|
||||
SmartOverall overall() const
|
||||
Overall overall() const
|
||||
{
|
||||
return m_Overall; /**< @return SMART overall status */
|
||||
}
|
||||
|
@ -192,7 +191,7 @@ private:
|
|||
bool m_BadAttributeNow;
|
||||
bool m_BadAttributeInThePast;
|
||||
SmartSelfTestExecutionStatus m_SelfTestExecutionStatus;
|
||||
SmartOverall m_Overall;
|
||||
Overall m_Overall;
|
||||
QList<SmartAttributeParsedData> m_Attributes;
|
||||
|
||||
};
|
||||
|
|
|
@ -37,8 +37,8 @@ SmartStatus::SmartStatus(const QString &device_path) :
|
|||
m_ModelName(),
|
||||
m_Serial(),
|
||||
m_Firmware(),
|
||||
m_Overall(Bad),
|
||||
m_SelfTestStatus(Success),
|
||||
m_Overall(Overall::Bad),
|
||||
m_SelfTestStatus(SelfTestStatus::Success),
|
||||
m_Temp(0),
|
||||
m_BadSectors(0),
|
||||
m_PowerCycles(0),
|
||||
|
@ -73,72 +73,72 @@ void SmartStatus::update()
|
|||
|
||||
switch (disk->selfTestExecutionStatus()) {
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ABORTED:
|
||||
setSelfTestStatus(Aborted);
|
||||
setSelfTestStatus(SelfTestStatus::Aborted);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED:
|
||||
setSelfTestStatus(Interrupted);
|
||||
setSelfTestStatus(SelfTestStatus::Interrupted);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_FATAL:
|
||||
setSelfTestStatus(Fatal);
|
||||
setSelfTestStatus(SelfTestStatus::Fatal);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN:
|
||||
setSelfTestStatus(ErrorUnknown);
|
||||
setSelfTestStatus(SelfTestStatus::ErrorUnknown);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL:
|
||||
setSelfTestStatus(ErrorEletrical);
|
||||
setSelfTestStatus(SelfTestStatus::ErrorEletrical);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO:
|
||||
setSelfTestStatus(ErrorServo);
|
||||
setSelfTestStatus(SelfTestStatus::ErrorServo);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ:
|
||||
setSelfTestStatus(ErrorRead);
|
||||
setSelfTestStatus(SelfTestStatus::ErrorRead);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING:
|
||||
setSelfTestStatus(ErrorHandling);
|
||||
setSelfTestStatus(SelfTestStatus::ErrorHandling);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS:
|
||||
setSelfTestStatus(InProgress);
|
||||
setSelfTestStatus(SelfTestStatus::InProgress);
|
||||
break;
|
||||
|
||||
default:
|
||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER:
|
||||
setSelfTestStatus(Success);
|
||||
setSelfTestStatus(SelfTestStatus::Success);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
switch (disk->overall()) {
|
||||
case SmartDiskInformation::SMART_OVERALL_GOOD:
|
||||
setOverall(Good);
|
||||
case SmartDiskInformation::Overall::Good:
|
||||
setOverall(Overall::Good);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST:
|
||||
setOverall(BadPast);
|
||||
case SmartDiskInformation::Overall::BadAttributeInThePast:
|
||||
setOverall(Overall::BadPast);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_OVERALL_BAD_SECTOR:
|
||||
setOverall(BadSectors);
|
||||
case SmartDiskInformation::Overall::BadSector:
|
||||
setOverall(Overall::BadSectors);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_OVERALL_BAD_ATTRIBUTE_NOW:
|
||||
setOverall(BadNow);
|
||||
case SmartDiskInformation::Overall::BadAttributeNow:
|
||||
setOverall(Overall::BadNow);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::SMART_OVERALL_BAD_SECTOR_MANY:
|
||||
setOverall(BadSectorsMany);
|
||||
case SmartDiskInformation::Overall::BadSectorsMany:
|
||||
setOverall(Overall::BadSectorsMany);
|
||||
break;
|
||||
|
||||
default:
|
||||
case SmartDiskInformation::SMART_OVERALL_BAD_STATUS:
|
||||
setOverall(Bad);
|
||||
case SmartDiskInformation::Overall::BadStatus:
|
||||
setOverall(Overall::Bad);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -167,34 +167,34 @@ QString SmartStatus::tempToString(quint64 mkelvin)
|
|||
QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s)
|
||||
{
|
||||
switch (s) {
|
||||
case Aborted:
|
||||
case SelfTestStatus::Aborted:
|
||||
return xi18nc("@item", "Aborted");
|
||||
|
||||
case Interrupted:
|
||||
case SelfTestStatus::Interrupted:
|
||||
return xi18nc("@item", "Interrupted");
|
||||
|
||||
case Fatal:
|
||||
case SelfTestStatus::Fatal:
|
||||
return xi18nc("@item", "Fatal error");
|
||||
|
||||
case ErrorUnknown:
|
||||
case SelfTestStatus::ErrorUnknown:
|
||||
return xi18nc("@item", "Unknown error");
|
||||
|
||||
case ErrorEletrical:
|
||||
case SelfTestStatus::ErrorEletrical:
|
||||
return xi18nc("@item", "Electrical error");
|
||||
|
||||
case ErrorServo:
|
||||
case SelfTestStatus::ErrorServo:
|
||||
return xi18nc("@item", "Servo error");
|
||||
|
||||
case ErrorRead:
|
||||
case SelfTestStatus::ErrorRead:
|
||||
return xi18nc("@item", "Read error");
|
||||
|
||||
case ErrorHandling:
|
||||
case SelfTestStatus::ErrorHandling:
|
||||
return xi18nc("@item", "Handling error");
|
||||
|
||||
case InProgress:
|
||||
case SelfTestStatus::InProgress:
|
||||
return xi18nc("@item", "Self test in progress");
|
||||
|
||||
case Success:
|
||||
case SelfTestStatus::Success:
|
||||
default:
|
||||
return xi18nc("@item", "Success");
|
||||
}
|
||||
|
@ -204,22 +204,22 @@ QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s)
|
|||
QString SmartStatus::overallAssessmentToString(Overall o)
|
||||
{
|
||||
switch (o) {
|
||||
case Good:
|
||||
case Overall::Good:
|
||||
return xi18nc("@item", "Healthy");
|
||||
|
||||
case BadPast:
|
||||
case Overall::BadPast:
|
||||
return xi18nc("@item", "Has been used outside of its design parameters in the past.");
|
||||
|
||||
case BadSectors:
|
||||
case Overall::BadSectors:
|
||||
return xi18nc("@item", "Has some bad sectors.");
|
||||
|
||||
case BadNow:
|
||||
case Overall::BadNow:
|
||||
return xi18nc("@item", "Is being used outside of its design parameters right now.");
|
||||
|
||||
case BadSectorsMany:
|
||||
case Overall::BadSectorsMany:
|
||||
return xi18nc("@item", "Has many bad sectors.");
|
||||
|
||||
case Bad:
|
||||
case Overall::Bad:
|
||||
default:
|
||||
return xi18nc("@item", "Disk failure is imminent. Backup all data!");
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ struct SkDisk;
|
|||
class LIBKPMCORE_EXPORT SmartStatus
|
||||
{
|
||||
public:
|
||||
enum Overall {
|
||||
enum class Overall {
|
||||
Good,
|
||||
BadPast,
|
||||
BadSectors,
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
Bad
|
||||
};
|
||||
|
||||
enum SelfTestStatus {
|
||||
enum class SelfTestStatus {
|
||||
Success,
|
||||
Aborted,
|
||||
Interrupted,
|
||||
|
|
|
@ -91,12 +91,12 @@ FileSystem::SupportTool btrfs::supportToolName() const
|
|||
|
||||
qint64 btrfs::minCapacity() const
|
||||
{
|
||||
return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 256 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 btrfs::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
int btrfs::maxLabelLength() const
|
||||
|
|
|
@ -84,7 +84,7 @@ FileSystem::SupportTool exfat::supportToolName() const
|
|||
|
||||
qint64 exfat::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
int exfat::maxLabelLength() const
|
||||
|
|
|
@ -84,7 +84,7 @@ FileSystem::SupportTool ext2::supportToolName() const
|
|||
|
||||
qint64 ext2::maxCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
int ext2::maxLabelLength() const
|
||||
|
|
|
@ -31,7 +31,7 @@ ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
|||
|
||||
qint64 ext3::maxCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
bool ext3::create(Report& report, const QString& deviceNode)
|
||||
|
|
|
@ -31,7 +31,7 @@ ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
|||
|
||||
qint64 ext4::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
bool ext4::create(Report& report, const QString& deviceNode)
|
||||
|
|
|
@ -100,12 +100,12 @@ FileSystem::SupportTool f2fs::supportToolName() const
|
|||
|
||||
qint64 f2fs::minCapacity() const
|
||||
{
|
||||
return 30 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 30 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 f2fs::maxCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||
}
|
||||
|
||||
int f2fs::maxLabelLength() const
|
||||
|
|
|
@ -87,12 +87,12 @@ FileSystem::SupportTool fat12::supportToolName() const
|
|||
|
||||
qint64 fat12::minCapacity() const
|
||||
{
|
||||
return 1 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 1 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 fat12::maxCapacity() const
|
||||
{
|
||||
return 255 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 255 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
int fat12::maxLabelLength() const
|
||||
|
|
|
@ -75,12 +75,12 @@ bool fat16::supportToolFound() const
|
|||
|
||||
qint64 fat16::minCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 fat16::maxCapacity() const
|
||||
{
|
||||
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::GiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::GiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
bool fat16::create(Report& report, const QString& deviceNode)
|
||||
|
|
|
@ -32,12 +32,12 @@ fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QS
|
|||
|
||||
qint64 fat32::minCapacity() const
|
||||
{
|
||||
return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 fat32::maxCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
bool fat32::create(Report& report, const QString& deviceNode)
|
||||
|
|
|
@ -376,13 +376,13 @@ bool FileSystem::updateBootSector(Report& report, const QString& deviceNode) con
|
|||
/** @return the minimum capacity valid for this FileSystem in bytes */
|
||||
qint64 FileSystem::minCapacity() const
|
||||
{
|
||||
return 8 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 8 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
/** @return the maximum capacity valid for this FileSystem in bytes */
|
||||
qint64 FileSystem::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
/** @return the maximum label length valid for this FileSystem */
|
||||
|
|
|
@ -73,7 +73,7 @@ FileSystem::SupportTool hfs::supportToolName() const
|
|||
|
||||
qint64 hfs::maxCapacity() const
|
||||
{
|
||||
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
||||
return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||
}
|
||||
|
||||
int hfs::maxLabelLength() const
|
||||
|
|
|
@ -73,7 +73,7 @@ FileSystem::SupportTool hfsplus::supportToolName() const
|
|||
|
||||
qint64 hfsplus::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
int hfsplus::maxLabelLength() const
|
||||
|
|
|
@ -43,6 +43,6 @@ hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
|||
|
||||
qint64 hpfs::maxCapacity() const
|
||||
{
|
||||
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
||||
return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,12 +79,12 @@ FileSystem::SupportTool jfs::supportToolName() const
|
|||
|
||||
qint64 jfs::minCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 jfs::maxCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||
}
|
||||
|
||||
int jfs::maxLabelLength() const
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#if !defined(KPMCORE_LUKS_H)
|
||||
|
||||
#ifndef KPMCORE_LUKS_H
|
||||
#define KPMCORE_LUKS_H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
@ -43,7 +42,7 @@ public:
|
|||
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Luks);
|
||||
~luks() override;
|
||||
|
||||
enum KeyLocation {
|
||||
enum class KeyLocation {
|
||||
unknown,
|
||||
dmcrypt,
|
||||
keyring
|
||||
|
@ -225,7 +224,7 @@ protected:
|
|||
qint64 m_PayloadSize;
|
||||
QString m_outerUuid;
|
||||
|
||||
luks::KeyLocation m_KeyLocation = unknown;
|
||||
luks::KeyLocation m_KeyLocation = KeyLocation::unknown;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
|
|||
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() });
|
||||
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||
|
||||
if (m_KeyLocation == keyring) {
|
||||
if (m_KeyLocation == KeyLocation::keyring) {
|
||||
if (m_passphrase.isEmpty())
|
||||
return false;
|
||||
cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n');
|
||||
|
@ -110,7 +110,7 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
|
|||
{ QStringLiteral("--size"), QString::number(m_PayloadSize / 512), // FIXME, LUKS2 can have different sector sizes
|
||||
QStringLiteral("resize"), mapperName() });
|
||||
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||
if (m_KeyLocation == keyring) {
|
||||
if (m_KeyLocation == KeyLocation::keyring) {
|
||||
if (m_passphrase.isEmpty())
|
||||
return false;
|
||||
cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n');
|
||||
|
@ -126,16 +126,16 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
|
|||
|
||||
luks::KeyLocation luks2::keyLocation()
|
||||
{
|
||||
m_KeyLocation = unknown;
|
||||
m_KeyLocation = KeyLocation::unknown;
|
||||
ExternalCommand statusCmd(QStringLiteral("cryptsetup"), { QStringLiteral("status"), mapperName() });
|
||||
if (statusCmd.run(-1) && statusCmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("key location:\\s+(\\w+)"));
|
||||
QRegularExpressionMatch rem = re.match(statusCmd.output());
|
||||
if (rem.hasMatch()) {
|
||||
if (rem.captured(1) == QStringLiteral("keyring"))
|
||||
m_KeyLocation = keyring;
|
||||
m_KeyLocation = KeyLocation::keyring;
|
||||
else if (rem.captured(1) == QStringLiteral("dm-crypt"))
|
||||
m_KeyLocation = dmcrypt;
|
||||
m_KeyLocation = KeyLocation::dmcrypt;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ FileSystem::SupportTool lvm2_pv::supportToolName() const
|
|||
|
||||
qint64 lvm2_pv::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
qint64 lvm2_pv::readUsedCapacity(const QString& deviceNode) const
|
||||
|
|
|
@ -96,12 +96,12 @@ FileSystem::SupportTool nilfs2::supportToolName() const
|
|||
|
||||
qint64 nilfs2::minCapacity() const
|
||||
{
|
||||
return 128 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 128 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 nilfs2::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
int nilfs2::maxLabelLength() const
|
||||
|
|
|
@ -91,12 +91,12 @@ FileSystem::SupportTool ntfs::supportToolName() const
|
|||
|
||||
qint64 ntfs::minCapacity() const
|
||||
{
|
||||
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 ntfs::maxCapacity() const
|
||||
{
|
||||
return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
||||
return 256 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||
}
|
||||
|
||||
int ntfs::maxLabelLength() const
|
||||
|
|
|
@ -89,12 +89,12 @@ FileSystem::SupportTool ocfs2::supportToolName() const
|
|||
|
||||
qint64 ocfs2::minCapacity() const
|
||||
{
|
||||
return 14000 * Capacity::unitFactor(Capacity::Byte, Capacity::KiB);
|
||||
return 14000 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::KiB);
|
||||
}
|
||||
|
||||
qint64 ocfs2::maxCapacity() const
|
||||
{
|
||||
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::PiB);
|
||||
return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::PiB);
|
||||
}
|
||||
|
||||
qint64 ocfs2::readUsedCapacity(const QString& deviceNode) const
|
||||
|
|
|
@ -75,7 +75,7 @@ qint64 reiser4::maxCapacity() const
|
|||
{
|
||||
// looks like it's actually unknown. see
|
||||
// http://en.wikipedia.org/wiki/Comparison_of_file_systems
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
int reiser4::maxLabelLength() const
|
||||
|
|
|
@ -85,12 +85,12 @@ FileSystem::SupportTool reiserfs::supportToolName() const
|
|||
|
||||
qint64 reiserfs::minCapacity() const
|
||||
{
|
||||
return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 reiserfs::maxCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
int reiserfs::maxLabelLength() const
|
||||
|
|
|
@ -83,12 +83,12 @@ FileSystem::SupportTool xfs::supportToolName() const
|
|||
|
||||
qint64 xfs::minCapacity() const
|
||||
{
|
||||
return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 xfs::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
int xfs::maxLabelLength() const
|
||||
|
|
|
@ -77,12 +77,12 @@ FileSystem::SupportTool zfs::supportToolName() const
|
|||
|
||||
qint64 zfs::minCapacity() const
|
||||
{
|
||||
return 64 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 64 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
}
|
||||
|
||||
qint64 zfs::maxCapacity() const
|
||||
{
|
||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
||||
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||
}
|
||||
|
||||
bool zfs::remove(Report& report, const QString& deviceNode) const
|
||||
|
|
|
@ -88,7 +88,7 @@ bool ResizeFileSystemJob::run(Report& parent)
|
|||
}
|
||||
|
||||
case FileSystem::cmdSupportFileSystem: {
|
||||
const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Byte);
|
||||
const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Unit::Byte);
|
||||
if (partition().isMounted())
|
||||
rval = partition().fileSystem().resizeOnline(*report, partition().deviceNode(), partition().mountPoint(), newLengthInByte);
|
||||
else
|
||||
|
|
|
@ -43,9 +43,9 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
|||
|
||||
for (const auto &p : partList()) {
|
||||
const QString deviceNode = p->roles().has(PartitionRole::Luks) ? static_cast<const FS::luks*>(&p->fileSystem())->mapperName() : p->partitionPath();
|
||||
if (type() == ResizeVolumeGroupJob::Grow)
|
||||
if (type() == ResizeVolumeGroupJob::Type::Grow)
|
||||
rval = LvmDevice::insertPV(*report, device(), deviceNode);
|
||||
else if (type() == ResizeVolumeGroupJob::Shrink)
|
||||
else if (type() == ResizeVolumeGroupJob::Type::Shrink)
|
||||
rval = LvmDevice::removePV(*report, device(), deviceNode);
|
||||
|
||||
if (rval == false)
|
||||
|
@ -66,10 +66,10 @@ QString ResizeVolumeGroupJob::description() const
|
|||
partitionList.chop(2);
|
||||
const qint32 count = partList().count();
|
||||
|
||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
||||
if (type() == ResizeVolumeGroupJob::Type::Grow) {
|
||||
return xi18ncp("@info/plain", "Adding LVM Physical Volume %2 to %3.", "Adding LVM Physical Volumes %2 to %3.", count, partitionList, device().name());
|
||||
}
|
||||
if (type() == ResizeVolumeGroupJob::Shrink) {
|
||||
if (type() == ResizeVolumeGroupJob::Type::Shrink) {
|
||||
return xi18ncp("@info/plain", "Removing LVM Physical Volume %2 from %3.", "Removing LVM Physical Volumes %2 from %3.", count, partitionList, device().name());
|
||||
}
|
||||
return xi18nc("@info/plain", "Resizing Volume Group %1 to %2.", device().name(), partitionList);
|
||||
|
|
|
@ -31,9 +31,9 @@ class ResizeVolumeGroupJob : public Job
|
|||
{
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
Grow = 0,
|
||||
Shrink = 1
|
||||
enum class Type {
|
||||
Grow,
|
||||
Shrink
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
|
@ -45,13 +45,13 @@ DeleteOperation::DeleteOperation(Device& d, Partition* p, ShredAction shred) :
|
|||
m_DeletePartitionJob(new DeletePartitionJob(targetDevice(), deletedPartition()))
|
||||
{
|
||||
switch (shredAction()) {
|
||||
case NoShred:
|
||||
case ShredAction::NoShred:
|
||||
m_DeleteFileSystemJob = static_cast<Job*>(new DeleteFileSystemJob(targetDevice(), deletedPartition()));
|
||||
break;
|
||||
case ZeroShred:
|
||||
case ShredAction::ZeroShred:
|
||||
m_DeleteFileSystemJob = static_cast<Job*>(new ShredFileSystemJob(targetDevice(), deletedPartition(), false));
|
||||
break;
|
||||
case RandomShred:
|
||||
case ShredAction::RandomShred:
|
||||
m_DeleteFileSystemJob = static_cast<Job*>(new ShredFileSystemJob(targetDevice(), deletedPartition(), true));
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ void DeleteOperation::undo()
|
|||
|
||||
QString DeleteOperation::description() const
|
||||
{
|
||||
if (shredAction() != NoShred)
|
||||
if (shredAction() != ShredAction::NoShred)
|
||||
return xi18nc("@info:status", "Shred partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name());
|
||||
else
|
||||
return xi18nc("@info:status", "Delete partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name());
|
||||
|
|
|
@ -43,18 +43,18 @@ class LIBKPMCORE_EXPORT DeleteOperation : public Operation
|
|||
Q_DISABLE_COPY(DeleteOperation)
|
||||
|
||||
public:
|
||||
enum ShredAction {
|
||||
NoShred = 0,
|
||||
enum class ShredAction {
|
||||
NoShred,
|
||||
ZeroShred,
|
||||
RandomShred
|
||||
};
|
||||
|
||||
DeleteOperation(Device& d, Partition* p, ShredAction shred = NoShred);
|
||||
DeleteOperation(Device& d, Partition* p, ShredAction shred = ShredAction::NoShred);
|
||||
~DeleteOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const override {
|
||||
return shredAction() == NoShred ?
|
||||
return shredAction() == ShredAction::NoShred ?
|
||||
QStringLiteral("edit-delete") :
|
||||
QStringLiteral("edit-delete-shred");
|
||||
}
|
||||
|
|
|
@ -89,12 +89,12 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QVect
|
|||
// *DO NOTHING*
|
||||
} else {
|
||||
if (!toInsertList.isEmpty()) {
|
||||
m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Grow);
|
||||
m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Type::Grow);
|
||||
addJob(growVolumeGroupJob());
|
||||
}
|
||||
if (!toRemoveList.isEmpty()) {
|
||||
m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(d, toRemoveList);
|
||||
m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Shrink);
|
||||
m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Type::Shrink);
|
||||
addJob(movePhysicalVolumeJob());
|
||||
addJob(shrinkvolumegroupjob());
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
|||
modelName = modelName.left(modelName.length() - 1);
|
||||
qint64 deviceSize = sizeCommand.output().trimmed().toLongLong();
|
||||
|
||||
Log(Log::information) << xi18nc("@info:status", "Device found: %1", modelName);
|
||||
Log(Log::Level::information) << xi18nc("@info:status", "Device found: %1", modelName);
|
||||
int logicalSectorSize = sizeCommand2.output().trimmed().toLongLong();
|
||||
DiskDevice* d = new DiskDevice(modelName, deviceNode, 255, 63, deviceSize / logicalSectorSize / 255 / 63, logicalSectorSize);
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ Capacity::Capacity(const Partition& p, Type t) :
|
|||
m_Size(-1)
|
||||
{
|
||||
switch (t) {
|
||||
case Used: m_Size = p.used(); break;
|
||||
case Available: m_Size = p.available(); break;
|
||||
case Total: m_Size = p.capacity();
|
||||
case Type::Used: m_Size = p.used(); break;
|
||||
case Type::Available: m_Size = p.available(); break;
|
||||
case Type::Total: m_Size = p.capacity();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ Capacity::Capacity(const Device& d) :
|
|||
*/
|
||||
qint64 Capacity::toInt(Unit u) const
|
||||
{
|
||||
return static_cast<qint64>(m_Size / unitFactor(Byte, u));
|
||||
return static_cast<qint64>(m_Size / unitFactor(Unit::Byte, u));
|
||||
}
|
||||
|
||||
/** Returns the Capacity as double converted to the given Unit.
|
||||
|
@ -73,7 +73,7 @@ qint64 Capacity::toInt(Unit u) const
|
|||
*/
|
||||
double Capacity::toDouble(Unit u) const
|
||||
{
|
||||
return static_cast<double>(m_Size) / unitFactor(Byte, u);
|
||||
return static_cast<double>(m_Size) / unitFactor(Unit::Byte, u);
|
||||
}
|
||||
|
||||
/** Returns a factor to convert between two Units.
|
||||
|
@ -86,14 +86,14 @@ qint64 Capacity::unitFactor(Unit from, Unit to)
|
|||
Q_ASSERT(from <= to);
|
||||
|
||||
if (from > to) {
|
||||
qWarning() << "from: " << from << ", to: " << to;
|
||||
qWarning() << "from: " << static_cast<uint>(from) << ", to: " << static_cast<uint>(to);
|
||||
return 1;
|
||||
}
|
||||
|
||||
qint64 result = 1;
|
||||
|
||||
qint32 a = from;
|
||||
qint32 b = to;
|
||||
qint32 a = static_cast<uint>(from);
|
||||
qint32 b = static_cast<uint>(to);
|
||||
|
||||
while (b-- > a)
|
||||
result *= 1024;
|
||||
|
@ -122,7 +122,7 @@ QString Capacity::unitName(Unit u, qint64 val)
|
|||
if (static_cast<quint32>(u) >= sizeof(unitNames) / sizeof(unitNames[0]))
|
||||
return xi18nc("@item:intext unit", "(unknown unit)");
|
||||
|
||||
return unitNames[u];
|
||||
return unitNames[static_cast<quint32>(u)];
|
||||
}
|
||||
|
||||
/** Determine if the capacity is valid.
|
||||
|
|
|
@ -36,16 +36,16 @@ class LIBKPMCORE_EXPORT Capacity
|
|||
{
|
||||
public:
|
||||
/** Units we can deal with */
|
||||
enum Unit { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB };
|
||||
enum class Unit : uint { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB };
|
||||
/** Type of capacity to print */
|
||||
enum Type { Used, Available, Total };
|
||||
enum class Type { Used, Available, Total };
|
||||
/** Flags for printing */
|
||||
enum Flag { NoFlags = 0, AppendUnit = 1, AppendBytes = 2 };
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
public:
|
||||
explicit Capacity(qint64 size);
|
||||
explicit Capacity(const Partition& p, Type t = Total);
|
||||
explicit Capacity(const Partition& p, Type t = Type::Total);
|
||||
Capacity(const Device& d);
|
||||
|
||||
public:
|
||||
|
|
|
@ -28,15 +28,15 @@
|
|||
class LIBKPMCORE_EXPORT Log
|
||||
{
|
||||
public:
|
||||
enum Level {
|
||||
debug = 0,
|
||||
information = 1,
|
||||
warning = 2,
|
||||
error = 3
|
||||
enum class Level {
|
||||
debug,
|
||||
information,
|
||||
warning,
|
||||
error,
|
||||
};
|
||||
|
||||
public:
|
||||
Log(Level lev = information) : ref(1), level(lev) {}
|
||||
Log(Level lev = Level::information) : ref(1), level(lev) {}
|
||||
~Log();
|
||||
Log(const Log& other) : ref(other.ref + 1), level(other.level) {}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static bool testSmartStatus()
|
|||
if (smart.serial() == QString())
|
||||
return false;
|
||||
|
||||
if (smart.selfTestStatus())
|
||||
if (smart.selfTestStatus() != SmartStatus::SelfTestStatus::Success)
|
||||
return false;
|
||||
|
||||
if (!smart.isValid())
|
||||
|
|
Loading…
Reference in New Issue