2022-10-21 11:21:35 +08:00
|
|
|
#include "file-system-watcher-test.h"
|
|
|
|
#include <QDebug>
|
|
|
|
using namespace UkuiSearch;
|
|
|
|
FileSystemWatcherTest::FileSystemWatcherTest(QObject *parent) : QObject(parent)
|
|
|
|
{
|
2022-10-26 18:01:40 +08:00
|
|
|
m_watcher = new FileSystemWatcher(true, FileSystemWatcher::WatchEvents(FileSystemWatcher::EventMove | FileSystemWatcher::EventMoveSelf |
|
2022-10-21 11:21:35 +08:00
|
|
|
FileSystemWatcher::EventCreate | FileSystemWatcher::EventDelete |
|
|
|
|
FileSystemWatcher::EventDeleteSelf | FileSystemWatcher::EventUnmount |
|
|
|
|
FileSystemWatcher::EventModify | FileSystemWatcher::EventAttributeChange));
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemWatcherTest::beginSignalTest()
|
|
|
|
{
|
2023-02-24 19:14:24 +08:00
|
|
|
m_watcher->addWatch("");
|
2022-10-21 11:21:35 +08:00
|
|
|
|
|
|
|
connect(m_watcher, &FileSystemWatcher::attributeChanged,
|
|
|
|
[](const QString& fileUrl) { qDebug() << "AttrbuteChanged:" << fileUrl; });
|
2022-10-26 18:01:40 +08:00
|
|
|
|
2022-10-21 11:21:35 +08:00
|
|
|
connect(m_watcher, &FileSystemWatcher::created,
|
|
|
|
[](const QString& fileUrl, bool isDir) { qDebug() << "Created:" << fileUrl << isDir; });
|
2022-10-26 18:01:40 +08:00
|
|
|
|
2022-10-21 11:21:35 +08:00
|
|
|
connect(m_watcher, &FileSystemWatcher::deleted,
|
|
|
|
[](const QString& fileUrl, bool isDir) { qDebug() << "Deleted:" << fileUrl << isDir; });
|
2022-10-26 18:01:40 +08:00
|
|
|
|
2022-10-21 11:21:35 +08:00
|
|
|
connect(m_watcher, &FileSystemWatcher::modified,
|
|
|
|
[](const QString& fileUrl) { qDebug() << "Modified:" << fileUrl; });
|
2022-10-26 18:01:40 +08:00
|
|
|
|
2022-10-21 11:21:35 +08:00
|
|
|
connect(m_watcher, &FileSystemWatcher::moved,
|
2022-10-26 18:01:40 +08:00
|
|
|
[](const QString& fileUrl, bool isDir) { qDebug() << "moved:" << fileUrl << isDir; });
|
|
|
|
|
2022-10-21 11:21:35 +08:00
|
|
|
connect(m_watcher, &FileSystemWatcher::closedWrite,
|
|
|
|
[](const QString& fileUrl) { qDebug() << "ClosedWrite:" << fileUrl; });
|
2023-03-15 16:39:38 +08:00
|
|
|
connect(m_watcher, &FileSystemWatcher::moveTo,
|
|
|
|
[](const QString& fileUrl) { qDebug() << "moveTo:" << fileUrl; });
|
2022-10-21 11:21:35 +08:00
|
|
|
}
|