Added some classes from a stackoverflow to utilize Qt's concurrency functions especially cancellable QFuture's
This commit is contained in:
parent
ad3f605ada
commit
99d738ee65
5 changed files with 119 additions and 1 deletions
19
core/TaskControl.h
Normal file
19
core/TaskControl.h
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue