-
Notifications
You must be signed in to change notification settings - Fork 1
/
TaskLogger.h
50 lines (38 loc) · 1.01 KB
/
TaskLogger.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef TASKLOGGER_H
#define TASKLOGGER_H
#include <QHash>
#include <QList>
#include <QTextStream>
#include <QTime>
#include "Task.h"
#include "Singleton.h"
#define LOG_FILENAME "task_log.dat"
struct TaskItem;
struct TaskSession {
int taskId;
unsigned int time;
int duration;
};
class TaskLogger : public QObject, public Singleton<TaskLogger>
{
Q_OBJECT
public:
TaskLogger();
void addTask(Task *task);
void deleteTaskHistory(Task *task);
const QList<TaskSession> getTaskSessions();
void setTaskItems(const QList<TaskItem *> *taskItems);
protected slots:
void taskToggled(bool active);
private:
QHash<int, int> initialTaskDuration;
QHash<int, QDateTime> taskActivationTime;
QList<TaskSession> taskSessions;
const QList<TaskItem*> *taskItems;
bool taskHistoriesLoaded;
void loadTaskHistories();
void saveTaskHistories();
void writeSessionToStream(const TaskSession taskSession, QTextStream &stream);
QString logDirectory;
};
#endif // TASKLOGGER_H