2017-09-19 08:35:43 +00:00
|
|
|
#ifndef TASKMANAGER_H
|
|
|
|
#define TASKMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QQmlListProperty>
|
2017-09-21 14:16:50 +00:00
|
|
|
#include <QTimer>
|
2017-09-19 08:35:43 +00:00
|
|
|
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(FortManager)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(FortSettings)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(TaskInfo)
|
2017-09-19 08:35:43 +00:00
|
|
|
|
|
|
|
class TaskManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-09-20 15:43:43 +00:00
|
|
|
Q_PROPERTY(QQmlListProperty<TaskInfo> taskInfos READ taskInfos NOTIFY taskInfosChanged)
|
|
|
|
Q_CLASSINFO("DefaultProperty", "taskInfos")
|
2017-09-19 08:35:43 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TaskManager(FortManager *fortManager,
|
|
|
|
QObject *parent = nullptr);
|
|
|
|
|
|
|
|
FortManager *fortManager() const { return m_fortManager; }
|
|
|
|
|
2017-09-20 15:43:43 +00:00
|
|
|
const QList<TaskInfo *> &taskInfosList() const { return m_taskInfos; }
|
|
|
|
QQmlListProperty<TaskInfo> taskInfos();
|
2017-09-19 08:35:43 +00:00
|
|
|
|
|
|
|
signals:
|
2017-09-20 15:43:43 +00:00
|
|
|
void taskInfosChanged();
|
2017-09-19 08:35:43 +00:00
|
|
|
|
|
|
|
public slots:
|
2017-09-20 15:43:43 +00:00
|
|
|
void loadSettings(const FortSettings *fortSettings);
|
2017-09-21 14:16:50 +00:00
|
|
|
bool saveSettings(FortSettings *fortSettings);
|
2017-09-19 08:35:43 +00:00
|
|
|
|
2017-09-21 13:24:45 +00:00
|
|
|
private slots:
|
|
|
|
void handleTaskFinished(bool success);
|
2018-03-05 12:17:13 +00:00
|
|
|
|
2017-09-21 14:16:50 +00:00
|
|
|
void runExpiredTasks();
|
2017-09-21 13:24:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void setupTasks();
|
|
|
|
|
|
|
|
void appendTaskInfo(TaskInfo *taskInfo);
|
|
|
|
|
2017-09-19 08:35:43 +00:00
|
|
|
private:
|
|
|
|
FortManager *m_fortManager;
|
|
|
|
|
2017-09-20 15:43:43 +00:00
|
|
|
QList<TaskInfo *> m_taskInfos;
|
2017-09-21 14:16:50 +00:00
|
|
|
|
|
|
|
QTimer m_timer;
|
2017-09-19 08:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TASKMANAGER_H
|