Added some classes from a stackoverflow to utilize Qt's concurrency functions especially cancellable QFuture's

This commit is contained in:
eelke 2018-02-14 19:18:51 +01:00
parent ad3f605ada
commit 99d738ee65
5 changed files with 119 additions and 1 deletions

19
core/TaskControl.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef TASKCONTROL_H
#define TASKCONTROL_H
/** From answer by Hatter
*
* https://stackoverflow.com/questions/5423058/qfuture-that-can-be-cancelled-and-report-progress
*/
#include <QFutureInterfaceBase>
class TaskControl
{
public:
TaskControl(QFutureInterfaceBase *f) : fu(f) { }
bool shouldRun() const { return !fu->isCanceled(); }
private:
QFutureInterfaceBase *fu;
};
#endif // TASKCONTROL_H