Commit 227fbf5b authored by Raine Makelainen's avatar Raine Makelainen

[systemsettings] Expose objectPath lookup from partition model. Contributes to JB#42530

parent 52661099
......@@ -327,6 +327,16 @@ void PartitionManagerPrivate::format(const Partition &partition, const QString &
}
}
QString PartitionManagerPrivate::objectPath(const Partition &partition) const
{
if (externalMedia.match(partition.deviceName()).hasMatch()) {
return m_udisksMonitor->instance()->objectPath(partition.deviceName());
} else {
qCWarning(lcMemoryCardLog) << "Object path existing only for external memory cards:" << partition.devicePath();
return QString();
}
}
QStringList PartitionManagerPrivate::supportedFileSystems() const
{
// Query filesystems supported by this device
......
......@@ -72,6 +72,8 @@ public:
void unmount(const Partition &partition);
void format(const Partition &partition, const QString &type, const QString &label, const QString &passphrase);
QString objectPath(const Partition &partition) const;
QStringList supportedFileSystems() const;
signals:
......
......@@ -169,6 +169,17 @@ void PartitionModel::format(const QString &deviceName, const QString &type, cons
}
}
QString PartitionModel::objectPath(const QString &deviceName) const
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName;
if (const Partition *partition = getPartition(deviceName)) {
return m_manager->objectPath(*partition);
} else {
qCWarning(lcMemoryCardLog) << "Unable to get object path for unknown device:" << deviceName;
return QString();
}
}
void PartitionModel::update()
{
const int count = m_partitions.count();
......
......@@ -131,6 +131,8 @@ public:
Q_INVOKABLE void unmount(const QString &deviceName);
Q_INVOKABLE void format(const QString &deviceName, const QString &type, const QString &label, const QString &passphrase = QString());
Q_INVOKABLE QString objectPath(const QString &deviceName) const;
QHash<int, QByteArray> roleNames() const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
......
......@@ -86,6 +86,8 @@ public:
void format(const QString &deviceName, const QString &type, const QString &label, const QString &passphrase);
QString objectPath(const QString &deviceName) const;
signals:
void status(const QString &deviceName, Partition::Status);
void errorMessage(const QString &objectPath, const QString &errorName);
......@@ -115,8 +117,6 @@ private:
void doFormat(const QString &deviceName, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments);
void getBlockDevices();
QString objectPath(const QString &deviceName) const;
private:
static Monitor *sharedInstance;
......
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