Explicitely specify the scope of FileSystem::Type enum.

This commit is contained in:
Andrius Štikonas 2018-04-07 19:54:55 +01:00
parent 3c9d85d842
commit 2137fa58b8
10 changed files with 31 additions and 31 deletions

View File

@ -84,8 +84,8 @@ void ConfigureOptionsDialog::updateSettings()
bool changed = false;
if (generalPageWidget().defaultFileSystem() != Config::defaultFileSystem()) {
Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem());
if (generalPageWidget().defaultFileSystem() != static_cast<FileSystem::Type>(Config::defaultFileSystem())) {
Config::setDefaultFileSystem(static_cast<int>(generalPageWidget().defaultFileSystem()));
changed = true;
}
@ -109,7 +109,7 @@ bool ConfigureOptionsDialog::hasChanged()
bool result = KConfigDialog::hasChanged();
KConfigSkeletonItem* kcItem = Config::self()->findItem(QStringLiteral("defaultFileSystem"));
result = result || !kcItem->isEqual(generalPageWidget().defaultFileSystem());
result = result || !kcItem->isEqual(static_cast<int>(generalPageWidget().defaultFileSystem()));
result = result || (generalPageWidget().kcfg_shredSource->checkedId() != Config::shredSource());
if (advancedPageWidget().isVisible()) {

View File

@ -48,7 +48,7 @@ void GeneralPageWidget::setupDialog()
{
QStringList fsNames;
for (const auto &fs : FileSystemFactory::map())
if (fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended && fs->type() != FileSystem::Luks)
if (fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Type::Extended && fs->type() != FileSystem::Type::Luks)
fsNames.append(fs->name());
std::sort(fsNames.begin(), fsNames.end(), caseInsensitiveLessThan);

View File

@ -42,7 +42,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
setupUi(this);
m_deviceNode = partition().deviceNode();
if (partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Luks) {
if (partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Type::Luks) {
const FS::luks* luksFs = dynamic_cast<const FS::luks*>(&partition().fileSystem());
m_deviceNode = luksFs->mapperName();
}
@ -54,7 +54,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
for (auto &e : m_fstabEntries) {
QString canonicalEntryPath = QFileInfo(e.deviceNode()).canonicalFilePath();
QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath();
if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints
if (canonicalEntryPath == canonicalDevicePath) {
entryFound = true;
entry.push_back(&e);
mountPointList = possibleMountPoints(e.deviceNode());
@ -65,11 +65,11 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
FileSystem::Type type = partition().fileSystem().type();
QString fsName;
switch (type) {
case FileSystem::LinuxSwap:
case FileSystem::Type::LinuxSwap:
fsName = QStringLiteral("swap");
break;
case FileSystem::Fat16:
case FileSystem::Fat32:
case FileSystem::Type::Fat16:
case FileSystem::Type::Fat32:
fsName = QStringLiteral("vfat");
break;
default:

View File

@ -72,8 +72,8 @@ void FileSystemSupportDialog::setupDialog()
dialogWidget().tree().clear();
for (const auto &fs : FileSystemFactory::map()) {
if (fs->type() == FileSystem::Unknown || fs->type() == FileSystem::Extended ||
fs->type() == FileSystem::Luks || fs->type() == FileSystem::Luks2) {
if (fs->type() == FileSystem::Type::Unknown || fs->type() == FileSystem::Type::Extended ||
fs->type() == FileSystem::Type::Luks || fs->type() == FileSystem::Type::Luks2) {
continue;
}

View File

@ -114,7 +114,7 @@ void InfoPane::showPartition(Qt::DockWidgetArea area, const Partition& p)
int x = 0;
int y = createHeader(p.deviceNode(), cols(area));
if (p.fileSystem().type() == FileSystem::Luks) { // inactive LUKS partition
if (p.fileSystem().type() == FileSystem::Type::Luks) { // inactive LUKS partition
const FS::luks* luksFs = static_cast<const FS::luks*>(&p.fileSystem());
QString deviceNode = p.partitionPath();
createLabels(i18nc("@label partition", "File system:"), p.fileSystem().name(), cols(area), x, y);
@ -127,7 +127,7 @@ void InfoPane::showPartition(Qt::DockWidgetArea area, const Partition& p)
createLabels(i18nc("@label partition", "First sector:"), QLocale().toString(p.firstSector()), cols(area), x, y);
createLabels(i18nc("@label partition", "Last sector:"), QLocale().toString(p.lastSector()), cols(area), x, y);
createLabels(i18nc("@label partition", "Number of sectors:"), QLocale().toString(p.length()), cols(area), x, y);
} else if (p.fileSystem().type() == FileSystem::Lvm2_PV) {
} else if (p.fileSystem().type() == FileSystem::Type::Lvm2_PV) {
FS::lvm2_pv *lvm2PVFs;
innerFS(&p, lvm2PVFs);
QString deviceNode = p.partitionPath();

View File

@ -73,9 +73,9 @@ void NewDialog::setupDialog()
QStringList fsNames;
for (const auto &fs : FileSystemFactory::map()) {
if (fs->supportCreate() != FileSystem::cmdSupportNone &&
fs->type() != FileSystem::Extended &&
fs->type() != FileSystem::Luks &&
fs->type() != FileSystem::Luks2)
fs->type() != FileSystem::Type::Extended &&
fs->type() != FileSystem::Type::Luks &&
fs->type() != FileSystem::Type::Luks2)
fsNames.append(fs->name());
}
@ -144,7 +144,7 @@ void NewDialog::accept()
{
if (partition().roles().has(PartitionRole::Extended)) {
partition().deleteFileSystem();
partition().setFileSystem(FileSystemFactory::create(FileSystem::Extended,
partition().setFileSystem(FileSystemFactory::create(FileSystem::Type::Extended,
partition().firstSector(),
partition().lastSector(),
partition().sectorSize()));
@ -153,7 +153,7 @@ void NewDialog::accept()
FileSystem::Type innerFsType = partition().fileSystem().type();
partition().deleteFileSystem();
FS::luks* luksFs = dynamic_cast< FS::luks* >(
FileSystemFactory::create(FileSystem::Luks,
FileSystemFactory::create(FileSystem::Type::Luks,
partition().firstSector(),
partition().lastSector(),
partition().sectorSize()));
@ -188,7 +188,7 @@ void NewDialog::onRoleChanged(bool)
// Also make sure to set a primary's or logical's file system once the user goes back from
// extended to any of those.
if (r == PartitionRole::Extended)
updateFileSystem(FileSystem::Extended);
updateFileSystem(FileSystem::Type::Extended);
else
updateFileSystem(FileSystem::typeForName(dialogWidget().comboFileSystem().currentText()));

View File

@ -208,7 +208,7 @@ static QTreeWidgetItem* createTreeWidgetItem(const Partition& p)
int i = 0;
item->setText(i++, p.deviceNode());
if (p.roles().has(PartitionRole::Luks) && (p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Luks) && p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Luks2)))
if (p.roles().has(PartitionRole::Luks) && (p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Type::Luks) && p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Type::Luks2)))
item->setText(i, xi18nc("@item:intable Encrypted file systems, e.g. btrfs[Encrypted]", "%1 [Encrypted]", p.fileSystem().name()));
else
item->setText(i, p.fileSystem().name());

View File

@ -232,7 +232,7 @@ void PartPropsDialog::updateHideAndShow()
partition().state() != Partition::StateNew && // not for new partitions
!partition().roles().has(PartitionRole::Extended) && // neither for extended
!partition().roles().has(PartitionRole::Unallocated) && // or for unallocated
newFileSystemType() != FileSystem::Unformatted; // and not for unformatted file systems
newFileSystemType() != FileSystem::Type::Unformatted; // and not for unformatted file systems
dialogWidget().showAvailable(showAvailableAndUsed);
dialogWidget().showUsed(showAvailableAndUsed);
@ -242,14 +242,14 @@ void PartPropsDialog::updateHideAndShow()
!partition().roles().has(PartitionRole::Extended) && // not for extended, they have no file system
!partition().roles().has(PartitionRole::Unallocated) && // and not for unallocated: no choice there
// do now show file system comboBox for open luks volumes.
!(partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Luks);
!(partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Type::Luks);
dialogWidget().showFileSystem(showFileSystem);
// when do we show the recreate file system check box?
const bool showCheckRecreate =
showFileSystem && // only if we also show the file system
partition().fileSystem().supportCreate() != FileSystem::cmdSupportNone && // and support creating this file system
partition().fileSystem().type() != FileSystem::Unknown && // and not for unknown file systems
partition().fileSystem().type() != FileSystem::Type::Unknown && // and not for unknown file systems
partition().state() != Partition::StateNew && // or new partitions
!partition().roles().has(PartitionRole::Luks); // or encrypted filesystems
@ -297,7 +297,7 @@ void PartPropsDialog::setupFileSystemComboBox()
for(const auto &fs : FileSystemFactory::map())
{
// If the partition isn't encrypted, skip the luks FS
if (fs->type() == FileSystem::Luks && partition().fileSystem().type() != FileSystem::Luks)
if (fs->type() == FileSystem::Type::Luks && partition().fileSystem().type() != FileSystem::Type::Luks)
continue;
if (partition().fileSystem().type() == fs->type() || (fs->supportCreate() != FileSystem::cmdSupportNone &&
partition().capacity() >= fs->minCapacity() && partition().capacity() <= fs->maxCapacity())) {
@ -307,16 +307,16 @@ void PartPropsDialog::setupFileSystemComboBox()
selected = name;
// If the partition isn't extended, skip the extended FS
if (fs->type() == FileSystem::Extended && !partition().roles().has(PartitionRole::Extended))
if (fs->type() == FileSystem::Type::Extended && !partition().roles().has(PartitionRole::Extended))
continue;
// The user cannot change the filesystem back to "unformatted" once a filesystem has been created.
if (fs->type() == FileSystem::Unformatted) {
if (fs->type() == FileSystem::Type::Unformatted) {
// .. but if the file system is unknown to us, show the unformatted option as the currently selected one
if (partition().fileSystem().type() == FileSystem::Unknown) {
name = FileSystem::nameForType(FileSystem::Unformatted);
if (partition().fileSystem().type() == FileSystem::Type::Unknown) {
name = FileSystem::nameForType(FileSystem::Type::Unformatted);
selected = name;
} else if (partition().fileSystem().type() != FileSystem::Unformatted && partition().state() != Partition::StateNew)
} else if (partition().fileSystem().type() != FileSystem::Type::Unformatted && partition().state() != Partition::StateNew)
continue;
}

View File

@ -130,7 +130,7 @@
<label context="@label">Backend plugin</label>
</entry>
<entry key="defaultFileSystem" type="Int">
<default>FileSystem::Type::Ext4</default>
<default>static_cast&lt;int&gt;(FileSystem::Type::Ext4)</default>
</entry>
<entry key="preferredUnit" type="Int">
<label context="@label">Preferred unit:</label>

View File

@ -45,7 +45,7 @@ QIcon createFileSystemColor(FileSystem::Type type, quint32 size)
QPixmap pixmap(size, size);
QPainter painter(&pixmap);
painter.setPen(QColor(0, 0, 0));
painter.setBrush(Config::fileSystemColorCode(type));
painter.setBrush(Config::fileSystemColorCode(static_cast<int>(type)));
painter.drawRect(QRect(0, 0, pixmap.width() - 1, pixmap.height() - 1));
painter.end();