mirror of
https://github.com/linuxdeepin/gio-qt.git
synced 2024-11-10 12:03:46 +01:00
feat: add interface for g_volume_get_identifier.
This commit is contained in:
parent
8cc7cde492
commit
3f21a4a1b7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
|||||||
# User
|
# User
|
||||||
*.user
|
*.user
|
||||||
|
|
||||||
|
# Build directory
|
||||||
|
build/
|
||||||
|
@ -28,6 +28,14 @@ namespace Gio {
|
|||||||
class Volume;
|
class Volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum DGioVolumeIdentifierType {
|
||||||
|
VOLUME_IDENTIFIER_TYPE_LABEL,
|
||||||
|
VOLUME_IDENTIFIER_TYPE_NFS_MOUNT,
|
||||||
|
VOLUME_IDENTIFIER_TYPE_UUID,
|
||||||
|
VOLUME_IDENTIFIER_TYPE_CLASS
|
||||||
|
};
|
||||||
|
Q_ENUMS(DGioVolumeIdentifierType);
|
||||||
|
|
||||||
class DGioMount;
|
class DGioMount;
|
||||||
class DGioVolumePrivate;
|
class DGioVolumePrivate;
|
||||||
class DGioVolume : public QObject, public QSharedData
|
class DGioVolume : public QObject, public QSharedData
|
||||||
@ -44,6 +52,8 @@ public:
|
|||||||
|
|
||||||
QExplicitlySharedDataPointer<DGioMount> getMount();
|
QExplicitlySharedDataPointer<DGioMount> getMount();
|
||||||
|
|
||||||
|
QString identifier(DGioVolumeIdentifierType id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<DGioVolumePrivate> d_ptr;
|
QScopedPointer<DGioVolumePrivate> d_ptr;
|
||||||
|
|
||||||
|
@ -115,3 +115,17 @@ QExplicitlySharedDataPointer<DGioMount> DGioVolume::getMount()
|
|||||||
|
|
||||||
return mntPtr;
|
return mntPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DGioVolume::identifier(DGioVolumeIdentifierType id) const
|
||||||
|
{
|
||||||
|
Q_D(const DGioVolume);
|
||||||
|
|
||||||
|
const static QHash<DGioVolumeIdentifierType, std::string> idtmap = {
|
||||||
|
{DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_LABEL, G_VOLUME_IDENTIFIER_KIND_LABEL},
|
||||||
|
{DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_NFS_MOUNT, G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT},
|
||||||
|
{DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_UUID, G_VOLUME_IDENTIFIER_KIND_UUID},
|
||||||
|
{DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_CLASS, G_VOLUME_IDENTIFIER_KIND_CLASS}
|
||||||
|
};
|
||||||
|
|
||||||
|
return QString::fromStdString(d->getGmmVolumeInstance()->get_identifier(idtmap[id]));
|
||||||
|
}
|
||||||
|
@ -123,7 +123,10 @@ int main(int argc, char * argv[])
|
|||||||
const QList<QExplicitlySharedDataPointer<DGioVolume> > vols = DGioVolumeManager::getVolumes();
|
const QList<QExplicitlySharedDataPointer<DGioVolume> > vols = DGioVolumeManager::getVolumes();
|
||||||
|
|
||||||
for (const QExplicitlySharedDataPointer<DGioVolume> &p : vols) {
|
for (const QExplicitlySharedDataPointer<DGioVolume> &p : vols) {
|
||||||
qDebug() << p->name();
|
qDebug() << p->name()
|
||||||
|
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_UUID)
|
||||||
|
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_CLASS)
|
||||||
|
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "----------drives------------";
|
qDebug() << "----------drives------------";
|
||||||
|
Loading…
Reference in New Issue
Block a user