some changes on the filemonitor signals
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
class FileController : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FileController( );
|
||||
~FileController( );
|
||||
FileController();
|
||||
~FileController();
|
||||
|
||||
private:
|
||||
QThread m_fsThread;
|
||||
@@ -19,15 +19,19 @@ private:
|
||||
private slots:
|
||||
|
||||
void update(const std::filesystem::path path, const FileEvent);
|
||||
void emitNewPath(const std::unordered_map<std::filesystem::path, std::filesystem::file_time_type> paths);
|
||||
void newPath(const std::unordered_map<std::filesystem::path,
|
||||
std::filesystem::file_time_type>
|
||||
paths);
|
||||
|
||||
signals:
|
||||
// Start signal to start the function in the thread
|
||||
void operate( );
|
||||
void operate();
|
||||
// Stop signal to stop the function in the thread
|
||||
void pause( );
|
||||
void pause();
|
||||
// Signal to update the path inside the thread
|
||||
void updatePath(const std::filesystem::path&);
|
||||
void updatePath(const std::filesystem::path &);
|
||||
|
||||
void newPathEntered(const std::unordered_map<std::filesystem::path, std::filesystem::file_time_type> paths);
|
||||
void pathChanged(const std::unordered_map<std::filesystem::path,
|
||||
std::filesystem::file_time_type>
|
||||
paths);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user