some changes on the filemonitor signals

This commit is contained in:
2024-06-12 15:41:12 +02:00
parent 09987eed01
commit df5e9bdfa9
5 changed files with 105 additions and 76 deletions

View File

@@ -1,38 +1,49 @@
#include "FileController.hpp"
#include <chrono>
#include <memory>
#include <filesystem>
#include <iostream>
#include <memory>
#include <unordered_map>
FileController::FileController( ) {
FileController::FileController() {
#ifdef _WIN32
m_fmWorker = std::make_shared<FileMonitor>(std::filesystem::path(std::getenv("USERPROFILE")),
std::chrono::milliseconds(1000));
m_fmWorker = std::make_shared<FileMonitor>(
std::filesystem::path(std::getenv("USERPROFILE")),
std::chrono::milliseconds(1000));
#else
m_fmWorker = std::make_shared<FileMonitor>(std::filesystem::path("/home/crylia/Dokumente"),
std::chrono::milliseconds(1000));
m_fmWorker = std::make_shared<FileMonitor>(
std::filesystem::path("/home/crylia/Dokumente"),
std::chrono::milliseconds(1000));
#endif
m_fmWorker->moveToThread(&m_fsThread);
connect(this, &FileController::operate, m_fmWorker.get( ), &FileMonitor::start);
connect(m_fmWorker.get( ), &FileMonitor::update, this, &FileController::update);
connect(m_fmWorker.get( ), &FileMonitor::newPathEntered, this, &FileController::emitNewPath);
connect(this, &FileController::operate, m_fmWorker.get(),
&FileMonitor::start);
connect(m_fmWorker.get(), &FileMonitor::fileCreated, this,
&FileController::update);
connect(m_fmWorker.get(), &FileMonitor::pathChanged, this,
&FileController::newPath);
m_fsThread.start( );
m_fsThread.start();
emit operate( );
emit operate();
}
FileController::~FileController( ) {
m_fsThread.quit( );
m_fsThread.wait( );
FileController::~FileController() {
m_fsThread.quit();
m_fsThread.wait();
}
void FileController::update(const std::filesystem::path path, const FileEvent event) {
std::cout << path.string( ) << std::endl;
}
void FileController::emitNewPath(const std::unordered_map<std::filesystem::path, std::filesystem::file_time_type> paths) {
void FileController::newPath(
std::unordered_map<std::filesystem::path, std::filesystem::file_time_type>
path) {
std::cout << "test" << std::endl;
emit newPathEntered(paths);
emit pathChanged(path);
}
void FileController::update(const std::filesystem::path path,
const FileEvent event) {
std::cout << "bruh" << std::endl;
std::cout << path.string() << std::endl;
}