#include "filesaver.h" // Qt #include #include // Project #include "filehandler.h" using namespace Storage; FileSaver::FileSaver(QObject *parent) : QObject(parent) { connect(&_futureWatcher, SIGNAL(finished()), this , SLOT(onFileSaved())); } /** * @brief FileSaver::concurrentSave * @param filename (QString) contains the path to the file to be written to * @param content (QString) the content to write to the file * @param append (bool) if True, append the content. Otherwise, overwrite it */ void FileSaver::concurrentSave(const QString &filename, const QString &content, bool append) { QFuture future = QtConcurrent::run(&FileHandler::write, filename, content, append); _futureWatcher.setFuture(future); } /** * @brief FileSaver::onFileSaved * Emits when the file save operation is complete and true if the save was successful, false otherwise */ void FileSaver::onFileSaved() { // coco begin validated: Has been validated manually emit fileSaved(_futureWatcher.result()); } // coco end