Skip to content

Commit

Permalink
[systemsettings] Expose isEncrypted role from partition model. Contri…
Browse files Browse the repository at this point in the history
…butes to JB#42529
  • Loading branch information
rainemak committed Sep 12, 2018
1 parent a7f1c58 commit 767be3a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/partition.cpp
Expand Up @@ -86,6 +86,11 @@ bool Partition::mountFailed() const
return d && d->mountFailed;
}

bool Partition::isEncrypted() const
{
return d && d->isEncrypted;
}

bool Partition::isCryptoDevice() const
{
return d ? d->isCryptoDevice : false;
Expand Down
1 change: 1 addition & 0 deletions src/partition.h
Expand Up @@ -104,6 +104,7 @@ class SYSTEMSETTINGS_EXPORT Partition
bool canMount() const;
bool mountFailed() const;
bool isCryptoDevice() const;
bool isEncrypted() const;

StorageType storageType() const;

Expand Down
2 changes: 2 additions & 0 deletions src/partition_p.h
Expand Up @@ -48,6 +48,7 @@ class PartitionPrivate : public QSharedData
, status(Partition::Unmounted)
, readOnly(true)
, canMount(false)
, isEncrypted(false)
, isCryptoDevice(false)
, isSupportedFileSystemType(false)
, mountFailed(false)
Expand Down Expand Up @@ -76,6 +77,7 @@ class PartitionPrivate : public QSharedData
Partition::Status status;
bool readOnly;
bool canMount;
bool isEncrypted;
bool isCryptoDevice;
bool isSupportedFileSystemType;
bool mountFailed;
Expand Down
3 changes: 3 additions & 0 deletions src/partitionmodel.cpp
Expand Up @@ -252,6 +252,7 @@ QHash<int, QByteArray> PartitionModel::roleNames() const
{ PartitionModelRole, "partitionModel" },
{ IsCryptoDeviceRoles, "isCryptoDevice"},
{ IsSupportedFileSystemType, "isSupportedFileSystemType"},
{ IsEncryptedRoles, "isEncrypted"},
};

return roleNames;
Expand Down Expand Up @@ -302,6 +303,8 @@ QVariant PartitionModel::data(const QModelIndex &index, int role) const
return partition.isCryptoDevice();
case IsSupportedFileSystemType:
return partition.isSupportedFileSystemType();
case IsEncryptedRoles:
return partition.isEncrypted();
default:
return QVariant();
}
Expand Down
1 change: 1 addition & 0 deletions src/partitionmodel.h
Expand Up @@ -64,6 +64,7 @@ class SYSTEMSETTINGS_EXPORT PartitionModel : public QAbstractListModel
PartitionModelRole,
IsCryptoDeviceRoles,
IsSupportedFileSystemType,
IsEncryptedRoles,
};

// For Status role
Expand Down
1 change: 1 addition & 0 deletions src/udisks2monitor.cpp
Expand Up @@ -294,6 +294,7 @@ void UDisks2::Monitor::setPartitionProperties(QExplicitlySharedDataPointer<Parti
partition->status = blockDevice->isEncrypted() ? Partition::Locked
: blockDevice->mountPath().isEmpty() ? Partition::Unmounted : Partition::Mounted;
partition->isCryptoDevice = blockDevice->isEncrypted() || blockDevice->hasCryptoBackingDevice();
partition->isEncrypted = blockDevice->isEncrypted();
}

void UDisks2::Monitor::updatePartitionProperties(const UDisks2::Block *blockDevice)
Expand Down

0 comments on commit 767be3a

Please sign in to comment.