fort/src/ui/task/taskmanager.h

52 lines
1.1 KiB
C
Raw Normal View History

2017-09-19 08:35:43 +00:00
#ifndef TASKMANAGER_H
#define TASKMANAGER_H
#include <QObject>
#include <QQmlListProperty>
#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);
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);
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;
QTimer m_timer;
2017-09-19 08:35:43 +00:00
};
#endif // TASKMANAGER_H