forked from mirrors/gio-qt
feat: add interface for g_volume_get_identifier.
This commit is contained in:
parent
8cc7cde492
commit
3f21a4a1b7
4 changed files with 31 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
# User
|
||||
*.user
|
||||
|
||||
# Build directory
|
||||
build/
|
||||
|
|
|
@ -28,6 +28,14 @@ namespace Gio {
|
|||
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 DGioVolumePrivate;
|
||||
class DGioVolume : public QObject, public QSharedData
|
||||
|
@ -44,6 +52,8 @@ public:
|
|||
|
||||
QExplicitlySharedDataPointer<DGioMount> getMount();
|
||||
|
||||
QString identifier(DGioVolumeIdentifierType id) const;
|
||||
|
||||
private:
|
||||
QScopedPointer<DGioVolumePrivate> d_ptr;
|
||||
|
||||
|
|
|
@ -115,3 +115,17 @@ QExplicitlySharedDataPointer<DGioMount> DGioVolume::getMount()
|
|||
|
||||
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();
|
||||
|
||||
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------------";
|
||||
|
|
Loading…
Reference in a new issue