Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Switch to scoped name PartitionTable::Flag::

Deprecated old style enum PartitionTable::FlagName.
This will allow to switch to scoped enum class in some future version.
parent 3df5acb9
......@@ -193,7 +193,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
startSector,
endSector,
lvPath,
PartitionTable::Flag::FlagNone,
PartitionTable::Flag::None,
mountPoint,
mounted);
return part;
......
......@@ -86,7 +86,7 @@ public:
StateRestore [[deprecated("Use Partition::State::Restore")]] = Restore
};
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = State::None);
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::Flag::None, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::Flag::None, State state = State::None);
~Partition() override;
Partition(const Partition& other, PartitionNode* parent = nullptr);
......@@ -238,10 +238,10 @@ public:
void setMounted(bool b);
void setFlag(PartitionTable::Flag f) {
m_ActiveFlags |= f;
m_ActiveFlags = m_ActiveFlags.setFlag(f);
}
void unsetFlag(PartitionTable::Flag f) {
m_ActiveFlags &= ~f;
m_ActiveFlags = m_ActiveFlags.setFlag(f, false);
}
void setParent(PartitionNode* p) {
m_Parent = p;
......
......@@ -182,39 +182,39 @@ void PartitionTable::append(Partition* partition)
QString PartitionTable::flagName(Flag f)
{
switch (f) {
case PartitionTable::FlagBoot:
case PartitionTable::Flag::Boot:
return xi18nc("@item partition flag", "boot");
case PartitionTable::FlagRoot:
case PartitionTable::Flag::Root:
return xi18nc("@item partition flag", "root");
case PartitionTable::FlagSwap:
case PartitionTable::Flag::Swap:
return xi18nc("@item partition flag", "swap");
case PartitionTable::FlagHidden:
case PartitionTable::Flag::Hidden:
return xi18nc("@item partition flag", "hidden");
case PartitionTable::FlagRaid:
case PartitionTable::Flag::Raid:
return xi18nc("@item partition flag", "raid");
case PartitionTable::FlagLvm:
case PartitionTable::Flag::Lvm:
return xi18nc("@item partition flag", "lvm");
case PartitionTable::FlagLba:
case PartitionTable::Flag::Lba:
return xi18nc("@item partition flag", "lba");
case PartitionTable::FlagHpService:
case PartitionTable::Flag::HpService:
return xi18nc("@item partition flag", "hpservice");
case PartitionTable::FlagPalo:
case PartitionTable::Flag::Palo:
return xi18nc("@item partition flag", "palo");
case PartitionTable::FlagPrep:
case PartitionTable::Flag::Prep:
return xi18nc("@item partition flag", "prep");
case PartitionTable::FlagMsftReserved:
case PartitionTable::Flag::MsftReserved:
return xi18nc("@item partition flag", "msft-reserved");
case PartitionTable::FlagBiosGrub:
case PartitionTable::Flag::BiosGrub:
return xi18nc("@item partition flag", "bios-grub");
case PartitionTable::FlagAppleTvRecovery:
case PartitionTable::Flag::AppleTvRecovery:
return xi18nc("@item partition flag", "apple-tv-recovery");
case PartitionTable::FlagDiag:
case PartitionTable::Flag::Diag:
return xi18nc("@item partition flag", "diag");
case PartitionTable::FlagLegacyBoot:
case PartitionTable::Flag::LegacyBoot:
return xi18nc("@item partition flag", "legacy-boot");
case PartitionTable::FlagMsftData:
case PartitionTable::Flag::MsftData:
return xi18nc("@item partition flag", "msft-data");
case PartitionTable::FlagIrst:
case PartitionTable::Flag::Irst:
return xi18nc("@item partition flag", "irst");
default:
break;
......@@ -228,23 +228,23 @@ const QList<PartitionTable::Flag> PartitionTable::flagList()
{
QList<PartitionTable::Flag> rval;
rval.append(PartitionTable::FlagBoot);
rval.append(PartitionTable::FlagRoot);
rval.append(PartitionTable::FlagSwap);
rval.append(PartitionTable::FlagHidden);
rval.append(PartitionTable::FlagRaid);
rval.append(PartitionTable::FlagLvm);
rval.append(PartitionTable::FlagLba);
rval.append(PartitionTable::FlagHpService);
rval.append(PartitionTable::FlagPalo);
rval.append(PartitionTable::FlagPrep);
rval.append(PartitionTable::FlagMsftReserved);
rval.append(PartitionTable::FlagBiosGrub);
rval.append(PartitionTable::FlagAppleTvRecovery);
rval.append(PartitionTable::FlagDiag);
rval.append(PartitionTable::FlagLegacyBoot);
rval.append(PartitionTable::FlagMsftData);
rval.append(PartitionTable::FlagIrst);
rval.append(PartitionTable::Flag::Boot);
rval.append(PartitionTable::Flag::Root);
rval.append(PartitionTable::Flag::Swap);
rval.append(PartitionTable::Flag::Hidden);
rval.append(PartitionTable::Flag::Raid);
rval.append(PartitionTable::Flag::Lvm);
rval.append(PartitionTable::Flag::Lba);
rval.append(PartitionTable::Flag::HpService);
rval.append(PartitionTable::Flag::Palo);
rval.append(PartitionTable::Flag::Prep);
rval.append(PartitionTable::Flag::MsftReserved);
rval.append(PartitionTable::Flag::BiosGrub);
rval.append(PartitionTable::Flag::AppleTvRecovery);
rval.append(PartitionTable::Flag::Diag);
rval.append(PartitionTable::Flag::LegacyBoot);
rval.append(PartitionTable::Flag::MsftData);
rval.append(PartitionTable::Flag::Irst);
return rval;
}
......
......@@ -69,30 +69,47 @@ public:
};
/** Partition flags */
enum Flag : qint32 {
FlagNone = 0,
FlagBoot = 1,
FlagRoot = 2,
FlagSwap = 4,
FlagHidden = 8,
FlagRaid = 16,
FlagLvm = 32,
FlagLba = 64,
FlagHpService = 128,
FlagPalo = 256,
FlagPrep = 512,
FlagMsftReserved = 1024,
FlagBiosGrub = 2048,
FlagAppleTvRecovery = 4096,
FlagDiag = 8192,
FlagLegacyBoot = 16384,
FlagMsftData = 32768,
FlagIrst = 65536,
FlagEsp [[deprecated]] = FlagBoot
enum Flag : uint32_t {
None = 0x0,
Boot = 0x1,
Root = 0x2,
Swap = 0x4,
Hidden = 0x8,
Raid = 0x10,
Lvm = 0x20,
Lba = 0x40,
HpService = 0x80,
Palo = 0x100,
Prep = 0x200,
MsftReserved = 0x400,
BiosGrub = 0x800,
AppleTvRecovery = 0x1000,
Diag = 0x2000,
LegacyBoot = 0x4000,
MsftData = 0x8000,
Irst = 0x100000,
FlagNone [[deprecated("Use PartitionTable::Flag::None")]] = None,
FlagBoot [[deprecated("Use PartitionTable::Flag::Boot")]] = Boot,
FlagRoot [[deprecated("Use PartitionTable::Flag::Root")]] = Root,
FlagSwap [[deprecated("Use PartitionTable::Flag::Swap")]] = Swap,
FlagHidden [[deprecated("Use PartitionTable::Flag::Hidden")]] = Hidden,
FlagRaid [[deprecated("Use PartitionTable::Flag::Raid")]] = Raid,
FlagLvm [[deprecated("Use PartitionTable::Flag::Lvm")]] = Lvm,
FlagLba [[deprecated("Use PartitionTable::Flag::Lba")]] = Lba,
FlagHpService [[deprecated("Use PartitionTable::Flag::HpService")]] = HpService,
FlagPalo [[deprecated("Use PartitionTable::Flag::Palo")]] = Palo,
FlagPrep [[deprecated("Use PartitionTable::Flag::Prep")]] = Prep,
FlagMsftReserved [[deprecated("Use PartitionTable::Flag::MsftReserved")]] = MsftReserved,
FlagBiosGrub [[deprecated("Use PartitionTable::Flag::BiosGrub")]] = BiosGrub,
FlagAppleTvRecovery [[deprecated("Use PartitionTable::Flag::AppleTvRecovery")]] = AppleTvRecovery,
FlagDiag [[deprecated("Use PartitionTable::Flag::Diag")]] = Diag,
FlagLegacyBoot [[deprecated("Use PartitionTable::Flag::LegacyBoot")]] = LegacyBoot,
FlagMsftData [[deprecated("Use PartitionTable::Flag::MsftData")]] = MsftData,
FlagIrst [[deprecated("Use PartitionTable::Flag::Irst")]] = Irst,
FlagEsp [[deprecated("Use PartitionTable::Flag::Boot")]] = Boot
};
Q_DECLARE_FLAGS(Flags, Flag)
Q_FLAG(Flag)
public:
PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable);
......
......@@ -267,7 +267,7 @@ Partition* CopyOperation::createCopy(const Partition& target, const Partition& s
p->fileSystem().setFirstSector(p->firstSector());
p->fileSystem().setLastSector(p->lastSector());
p->setFlags(PartitionTable::FlagNone);
p->setFlags(PartitionTable::Flag::None);
return p;
}
......
......@@ -66,7 +66,7 @@ NewOperation::NewOperation(Device& d, Partition* p) :
addJob(createFileSystemJob());
if (fs.type() == FileSystem::Type::Lvm2_PV) {
m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::FlagLvm);
m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::Flag::Lvm);
addJob(setPartFlagsJob());
}
......
......@@ -251,12 +251,12 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit
const qint64 start = partitionObject[QLatin1String("start")].toVariant().toLongLong();
const qint64 size = partitionObject[QLatin1String("size")].toVariant().toLongLong();
const QString partitionType = partitionObject[QLatin1String("type")].toString();
PartitionTable::Flags activeFlags = partitionObject[QLatin1String("bootable")].toBool() ? PartitionTable::FlagBoot : PartitionTable::FlagNone;
PartitionTable::Flags activeFlags = partitionObject[QLatin1String("bootable")].toBool() ? PartitionTable::Flag::Boot : PartitionTable::Flag::None;
if (partitionType == QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"))
activeFlags |= PartitionTable::FlagBoot;
activeFlags |= PartitionTable::Flag::Boot;
else if (partitionType == QStringLiteral("21686148-6449-6E6F-744E-656564454649"))
activeFlags |= PartitionTable::FlagBiosGrub;
activeFlags |= PartitionTable::Flag::BiosGrub;
FileSystem::Type type = FileSystem::Type::Unknown;
type = detectFileSystem(partitionNode);
......@@ -506,11 +506,11 @@ PartitionTable::Flags SfdiskBackend::availableFlags(PartitionTable::TableType ty
if (type == PartitionTable::gpt) {
// These are not really flags but for now keep them for compatibility
// We should implement changing partition type
flags = PartitionTable::Flag::FlagBiosGrub |
PartitionTable::Flag::FlagBoot;
flags = PartitionTable::Flag::BiosGrub |
PartitionTable::Flag::Boot;
}
else if (type == PartitionTable::msdos || type == PartitionTable::msdos_sectorbased)
flags = PartitionTable::FlagBoot;
flags = PartitionTable::Flag::Boot;
return flags;
}
......
......@@ -227,13 +227,13 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
if (m_device->partitionTable()->type() == PartitionTable::TableType::msdos ||
m_device->partitionTable()->type() == PartitionTable::TableType::msdos_sectorbased) {
// We only allow setting one active partition per device
if (flag == PartitionTable::Flag::FlagBoot && state == true) {
if (flag == PartitionTable::Flag::Boot && state == true) {
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QString::number(partition.number()) } );
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
return true;
else
return false;
} else if (flag == PartitionTable::Flag::FlagBoot && state == false) {
} else if (flag == PartitionTable::Flag::Boot && state == false) {
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QStringLiteral("-") } );
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
return true;
......@@ -242,7 +242,7 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
}
}
if (flag == PartitionTable::Flag::FlagBoot && state == true) {
if (flag == PartitionTable::Flag::Boot && state == true) {
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B") } );
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
......@@ -250,10 +250,10 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
else
return false;
}
if (flag == PartitionTable::Flag::FlagBoot && state == false)
if (flag == PartitionTable::Flag::Boot && state == false)
setPartitionSystemType(report, partition);
if (flag == PartitionTable::Flag::FlagBiosGrub && state == true) {
if (flag == PartitionTable::Flag::BiosGrub && state == true) {
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
QStringLiteral("21686148-6449-6E6F-744E-656564454649") } );
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
......@@ -261,7 +261,7 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
else
return false;
}
if (flag == PartitionTable::Flag::FlagBiosGrub && state == false)
if (flag == PartitionTable::Flag::BiosGrub && state == false)
setPartitionSystemType(report, partition);
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment