Example #1
0
/*!
    Creates thread
*/
RemoteFileInfoGatherer::RemoteFileInfoGatherer(QObject *parent)
    : AbstractFileInfoGatherer(parent), abort(false)
#ifndef QT_NO_FILESYSTEMWATCHER
    , watcher(0)
#endif
{
    qDebug() << "new RemoteFileInfoGatherer";
#ifndef QT_NO_FILESYSTEMWATCHER
    watcher = new QFileSystemWatcher(this);
    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
    connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));

#  if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
    const QVariant listener = watcher->property("_q_driveListener");
    if (listener.canConvert<QObject *>()) {
        if (QObject *driveListener = listener.value<QObject *>()) {
            connect(driveListener, SIGNAL(driveAdded()), this, SLOT(driveAdded()));
            connect(driveListener, SIGNAL(driveRemoved()), this, SLOT(driveRemoved()));
        }
    }
#  endif // Q_OS_WIN && !Q_OS_WINRT
#endif
    start(LowPriority);

    emit initialized();
}
Example #2
0
/*!
    Constructs a new drive controller object with the given \a parent.
*/
QDriveController::QDriveController(QObject *parent) :
    QObject(parent), d(new QDriveControllerPrivate)
{
    if (QDriveWatcher *watcher = theWatcher()) {
        connect(watcher, SIGNAL(driveAdded(QString)),
                this, SIGNAL(driveMounted(QString)), Qt::QueuedConnection);
        connect(watcher, SIGNAL(driveRemoved(QString)),
                this, SIGNAL(driveUnmounted(QString)), Qt::QueuedConnection);

        watcher->start();
    }
}