Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[systemsettings] Expose isSupportedFileSystem role from partition mod…
…el. Contributes to JB#42526
  • Loading branch information
rainemak committed Sep 4, 2018
1 parent daedc48 commit 8cd3a87
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/partition.cpp
Expand Up @@ -121,6 +121,12 @@ QString Partition::filesystemType() const
return d ? d->filesystemType : QString();
}

bool Partition::isSupportedFileSystemType() const
{

return d ? d->isSupportedFileSystemType : false;
}

qint64 Partition::bytesAvailable() const
{
return d ? d->bytesAvailable : 0;
Expand Down
1 change: 1 addition & 0 deletions src/partition.h
Expand Up @@ -113,6 +113,7 @@ class SYSTEMSETTINGS_EXPORT Partition
QString mountPath() const;

QString filesystemType() const;
bool isSupportedFileSystemType() const;

qint64 bytesAvailable() const;
qint64 bytesTotal() const;
Expand Down
2 changes: 2 additions & 0 deletions src/partition_p.h
Expand Up @@ -49,6 +49,7 @@ class PartitionPrivate : public QSharedData
, readOnly(true)
, canMount(false)
, isCryptoDevice(false)
, isSupportedFileSystemType(false)
, mountFailed(false)
, deviceRoot(false)
, valid(false)
Expand Down Expand Up @@ -76,6 +77,7 @@ class PartitionPrivate : public QSharedData
bool readOnly;
bool canMount;
bool isCryptoDevice;
bool isSupportedFileSystemType;
bool mountFailed;
bool deviceRoot;
// If valid, only mount status and available bytes will be checked
Expand Down
1 change: 1 addition & 0 deletions src/partitionmanager.cpp
Expand Up @@ -244,6 +244,7 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &
partition->deviceName = deviceName;
partition->deviceRoot = deviceRoot.match(deviceName).hasMatch();
partition->filesystemType = QString::fromUtf8(mountEntry.mnt_type);
partition->isSupportedFileSystemType = supportedFileSystems().contains(partition->filesystemType);
partition->status = partition->activeState == QStringLiteral("deactivating")
? Partition::Unmounting
: Partition::Mounted;
Expand Down
3 changes: 3 additions & 0 deletions src/partitionmodel.cpp
Expand Up @@ -269,6 +269,7 @@ QHash<int, QByteArray> PartitionModel::roleNames() const
{ BytesFreeRole, "bytesFree" },
{ PartitionModelRole, "partitionModel" },
{ IsCryptoDeviceRoles, "isCryptoDevice"},
{ IsSupportedFileSystemType, "isSupportedFileSystemType"},
};

return roleNames;
Expand Down Expand Up @@ -317,6 +318,8 @@ QVariant PartitionModel::data(const QModelIndex &index, int role) const
return QVariant::fromValue(static_cast<QObject*>(const_cast<PartitionModel*>((this))));
case IsCryptoDeviceRoles:
return partition.isCryptoDevice();
case IsSupportedFileSystemType:
return partition.isSupportedFileSystemType();
default:
return QVariant();
}
Expand Down
1 change: 1 addition & 0 deletions src/partitionmodel.h
Expand Up @@ -63,6 +63,7 @@ class SYSTEMSETTINGS_EXPORT PartitionModel : public QAbstractListModel
BytesFreeRole,
PartitionModelRole,
IsCryptoDeviceRoles,
IsSupportedFileSystemType,
};

// For Status role
Expand Down
1 change: 1 addition & 0 deletions src/udisks2monitor.cpp
Expand Up @@ -287,6 +287,7 @@ void UDisks2::Monitor::setPartitionProperties(QExplicitlySharedDataPointer<Parti
partition->mountPath = blockDevice->mountPath();
partition->deviceLabel = label;
partition->filesystemType = blockDevice->idType();
partition->isSupportedFileSystemType = m_manager->supportedFileSystems().contains(partition->filesystemType);
partition->readOnly = blockDevice->isReadOnly();
partition->canMount = blockDevice->isMountable() && m_manager->supportedFileSystems().contains(partition->filesystemType);
partition->status = blockDevice->isEncrypted() ? Partition::Locked
Expand Down

0 comments on commit 8cd3a87

Please sign in to comment.