put the filemonitor into a seperate thread and connected an update signal

This commit is contained in:
Crylia
2024-06-08 03:39:04 +02:00
parent 322659d210
commit b1cfa155f9
8 changed files with 97 additions and 48 deletions

View File

@@ -1,16 +1,26 @@
#include "FileController.hpp"
#include <chrono>
#include <memory>
#include <iostream>
FileController::FileController() {
m_fmWorker = std::make_unique<FileMonitor>(QString("/home/crylia/"),
std::chrono::milliseconds(1000));
FileController::FileController( ) {
m_fmWorker = std::make_shared<FileMonitor>(QString("/home/crylia/Dokumente"),
std::chrono::milliseconds(1000));
m_fmWorker->moveToThread(&m_fsThread);
m_fmWorker->start(QString("/home/crylia/"));
connect(this, &FileController::operate, m_fmWorker.get( ), &FileMonitor::start);
connect(m_fmWorker.get( ), &FileMonitor::update, this, &FileController::update);
m_fsThread.start( );
emit operate( );
}
FileController::~FileController() {
m_fsThread.quit();
m_fsThread.wait();
FileController::~FileController( ) {
m_fsThread.quit( );
m_fsThread.wait( );
}
void FileController::update(const QString path, const FileEvent event) {
std::cout << path.toStdString( ) << std::endl;
}