1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "task.h"
6
7unsigned int Task::s_nextId = 1;
8
9static QIcon taskTypeIcon(Task::TaskType t)
10{
11 static QIcon icons[3] = {QIcon(),
12 QIcon(":/resources/icons/error.png"),
13 QIcon(":/resources/icons/attention.svg")};
14
15 if (t < 0 || t > 2)
16 t = Task::Unknown;
17
18 return icons[t];
19}
20
21Task::Task(TaskType type_, const QString &description_,
22 const Utils::FileName &file_, int line_, QString category_,
23 const QIcon &icon, Options options) :
24 taskId(s_nextId), type(type_), options(options), description(description_),
25 file(file_), line(line_), movedLine(line_), category(category_),
26 icon(icon.isNull() ? taskTypeIcon(type_) : icon)
27{
28 ++s_nextId;
29}
30
31bool Task::isNull() const
32{
33 return taskId == 0;
34}
35
36void Task::clear()
37{
38 taskId = 0;
39 type = Task::Unknown;
40 description.clear();
41 file = Utils::FileName();
42 line = -1;
43 movedLine = -1;
44 category = "";
45 icon = QIcon();
46}
47
48bool operator==(const Task &t1, const Task &t2)
49{
50 return t1.taskId == t2.taskId;
51}
52