fort/src/ui/task/taskmanager.h
2017-09-21 19:16:50 +05:00

52 lines
1.1 KiB
C++

#ifndef TASKMANAGER_H
#define TASKMANAGER_H
#include <QObject>
#include <QQmlListProperty>
#include <QTimer>
class FortManager;
class FortSettings;
class TaskInfo;
class TaskManager : public QObject
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<TaskInfo> taskInfos READ taskInfos NOTIFY taskInfosChanged)
Q_CLASSINFO("DefaultProperty", "taskInfos")
public:
explicit TaskManager(FortManager *fortManager,
QObject *parent = nullptr);
FortManager *fortManager() const { return m_fortManager; }
const QList<TaskInfo *> &taskInfosList() const { return m_taskInfos; }
QQmlListProperty<TaskInfo> taskInfos();
signals:
void taskInfosChanged();
public slots:
void loadSettings(const FortSettings *fortSettings);
bool saveSettings(FortSettings *fortSettings);
private slots:
void handleTaskFinished(bool success);
void runExpiredTasks();
private:
void setupTasks();
void appendTaskInfo(TaskInfo *taskInfo);
private:
FortManager *m_fortManager;
QList<TaskInfo *> m_taskInfos;
QTimer m_timer;
};
#endif // TASKMANAGER_H