/*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file filesaver.cpp * \author (last) Peter Lucia * \date (last) 15-Oct-2020 * \author (original) Peter Lucia * \date (original) 03-Aug-2020 * */ #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::onConcurrentSave(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