mirror of
https://github.com/linuxdeepin/gio-qt.git
synced 2024-11-10 12:03:46 +01:00
parent
fa0bf3da6b
commit
238173e860
@ -65,6 +65,8 @@ DGioFile::~DGioFile()
|
|||||||
* This operation never fails since Gio::File::create_for_path never fails, but the returned
|
* This operation never fails since Gio::File::create_for_path never fails, but the returned
|
||||||
* object might not support any I/O operation if path is malformed.
|
* object might not support any I/O operation if path is malformed.
|
||||||
*
|
*
|
||||||
|
* Caller take the ownership of the created object, you can also provide a \a parent object.
|
||||||
|
*
|
||||||
* \return the created DGioFile instance
|
* \return the created DGioFile instance
|
||||||
*/
|
*/
|
||||||
DGioFile *DGioFile::createFromPath(QString path, QObject *parent)
|
DGioFile *DGioFile::createFromPath(QString path, QObject *parent)
|
||||||
@ -78,6 +80,27 @@ DGioFile *DGioFile::createFromPath(QString path, QObject *parent)
|
|||||||
return new DGioFile(gmmFile.release(), parent);
|
return new DGioFile(gmmFile.release(), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create a DGioFile instance by given \a uri
|
||||||
|
*
|
||||||
|
* This operation never fails since Gio::File::create_for_uri never fails, but the returned
|
||||||
|
* object might not support any I/O operation if uri is malformed.
|
||||||
|
*
|
||||||
|
* Caller take the ownership of the created object, you can also provide a \a parent object.
|
||||||
|
*
|
||||||
|
* \return the created DGioFile instance
|
||||||
|
*/
|
||||||
|
DGioFile *DGioFile::createFromUri(QString uri, QObject *parent)
|
||||||
|
{
|
||||||
|
// ensure GIO got initialized
|
||||||
|
Gio::init();
|
||||||
|
|
||||||
|
// File::create_for_path never falls.
|
||||||
|
Glib::RefPtr<File> gmmFile = File::create_for_uri(uri.toStdString());
|
||||||
|
|
||||||
|
return new DGioFile(gmmFile.release(), parent);
|
||||||
|
}
|
||||||
|
|
||||||
QString DGioFile::basename() const
|
QString DGioFile::basename() const
|
||||||
{
|
{
|
||||||
Q_D(const DGioFile);
|
Q_D(const DGioFile);
|
||||||
|
@ -18,6 +18,7 @@ public:
|
|||||||
~DGioFile();
|
~DGioFile();
|
||||||
|
|
||||||
static DGioFile * createFromPath(QString path, QObject *parent = nullptr);
|
static DGioFile * createFromPath(QString path, QObject *parent = nullptr);
|
||||||
|
static DGioFile * createFromUri(QString uri, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString basename() const;
|
QString basename() const;
|
||||||
QString path() const;
|
QString path() const;
|
||||||
|
@ -22,6 +22,9 @@ private:
|
|||||||
void slot_mountRemoved(const Glib::RefPtr< Mount >& gmmMount);
|
void slot_mountRemoved(const Glib::RefPtr< Mount >& gmmMount);
|
||||||
void slot_mountPreRemoved(const Glib::RefPtr< Mount >& gmmMount);
|
void slot_mountPreRemoved(const Glib::RefPtr< Mount >& gmmMount);
|
||||||
void slot_mountChanged(const Glib::RefPtr< Mount >& gmmMount);
|
void slot_mountChanged(const Glib::RefPtr< Mount >& gmmMount);
|
||||||
|
void slot_volumeAdded(const Glib::RefPtr< Volume >& gmmVolume);
|
||||||
|
void slot_volumeRemoved(const Glib::RefPtr< Volume >& gmmVolume);
|
||||||
|
void slot_volumeChanged(const Glib::RefPtr< Volume >& gmmVolume);
|
||||||
|
|
||||||
Q_DECLARE_PUBLIC(DGioVolumeManager)
|
Q_DECLARE_PUBLIC(DGioVolumeManager)
|
||||||
};
|
};
|
||||||
@ -39,6 +42,10 @@ DGioVolumeManagerPrivate::DGioVolumeManagerPrivate(DGioVolumeManager *qq)
|
|||||||
m_gmmVolumeMonitorPtr->signal_mount_removed().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_mountRemoved));
|
m_gmmVolumeMonitorPtr->signal_mount_removed().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_mountRemoved));
|
||||||
m_gmmVolumeMonitorPtr->signal_mount_pre_unmount().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_mountPreRemoved));
|
m_gmmVolumeMonitorPtr->signal_mount_pre_unmount().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_mountPreRemoved));
|
||||||
m_gmmVolumeMonitorPtr->signal_mount_changed().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_mountChanged));
|
m_gmmVolumeMonitorPtr->signal_mount_changed().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_mountChanged));
|
||||||
|
|
||||||
|
m_gmmVolumeMonitorPtr->signal_volume_added().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_volumeAdded));
|
||||||
|
m_gmmVolumeMonitorPtr->signal_volume_removed().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_volumeRemoved));
|
||||||
|
m_gmmVolumeMonitorPtr->signal_volume_changed().connect(sigc::mem_fun(*this, &DGioVolumeManagerPrivate::slot_volumeChanged));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DGioVolumeManagerPrivate::slot_mountAdded(const Glib::RefPtr<Mount> &gmmMount)
|
void DGioVolumeManagerPrivate::slot_mountAdded(const Glib::RefPtr<Mount> &gmmMount)
|
||||||
@ -85,6 +92,39 @@ void DGioVolumeManagerPrivate::slot_mountChanged(const Glib::RefPtr<Mount> &gmmM
|
|||||||
Q_EMIT q->mountChanged(mount);
|
Q_EMIT q->mountChanged(mount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DGioVolumeManagerPrivate::slot_volumeAdded(const Glib::RefPtr<Volume> &gmmVolume)
|
||||||
|
{
|
||||||
|
Q_Q(DGioVolumeManager);
|
||||||
|
|
||||||
|
Glib::RefPtr<Volume> copy(gmmVolume);
|
||||||
|
|
||||||
|
QExplicitlySharedDataPointer<DGioVolume> volume(new DGioVolume(copy.release()));
|
||||||
|
|
||||||
|
Q_EMIT q->volumeAdded(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DGioVolumeManagerPrivate::slot_volumeRemoved(const Glib::RefPtr<Volume> &gmmVolume)
|
||||||
|
{
|
||||||
|
Q_Q(DGioVolumeManager);
|
||||||
|
|
||||||
|
Glib::RefPtr<Volume> copy(gmmVolume);
|
||||||
|
|
||||||
|
QExplicitlySharedDataPointer<DGioVolume> volume(new DGioVolume(copy.release()));
|
||||||
|
|
||||||
|
Q_EMIT q->volumeRemoved(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DGioVolumeManagerPrivate::slot_volumeChanged(const Glib::RefPtr<Volume> &gmmVolume)
|
||||||
|
{
|
||||||
|
Q_Q(DGioVolumeManager);
|
||||||
|
|
||||||
|
Glib::RefPtr<Volume> copy(gmmVolume);
|
||||||
|
|
||||||
|
QExplicitlySharedDataPointer<DGioVolume> volume(new DGioVolume(copy.release()));
|
||||||
|
|
||||||
|
Q_EMIT q->volumeChanged(volume);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
DGioVolumeManager::DGioVolumeManager(QObject *parent)
|
DGioVolumeManager::DGioVolumeManager(QObject *parent)
|
||||||
|
@ -22,6 +22,9 @@ Q_SIGNALS:
|
|||||||
void mountRemoved(QExplicitlySharedDataPointer<DGioMount> mount);
|
void mountRemoved(QExplicitlySharedDataPointer<DGioMount> mount);
|
||||||
void mountPreRemoved(QExplicitlySharedDataPointer<DGioMount> mount);
|
void mountPreRemoved(QExplicitlySharedDataPointer<DGioMount> mount);
|
||||||
void mountChanged(QExplicitlySharedDataPointer<DGioMount> mount);
|
void mountChanged(QExplicitlySharedDataPointer<DGioMount> mount);
|
||||||
|
void volumeAdded(QExplicitlySharedDataPointer<DGioVolume> volume);
|
||||||
|
void volumeRemoved(QExplicitlySharedDataPointer<DGioVolume> volume);
|
||||||
|
void volumeChanged(QExplicitlySharedDataPointer<DGioVolume> volume);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<DGioVolumeManagerPrivate> d_ptr;
|
QScopedPointer<DGioVolumeManagerPrivate> d_ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user