Skip to content
Snippets Groups Projects
Commit fa6e6bc7 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Add a task id to the task class

 * Add a id that is uniquely identifying a task.

   Simplify operator == and qHash functions using this
   id.

 * Remove some code that was added in preparation for a patch
   that got rejected.

Reviewed-by: dt
parent 52b33a75
No related branches found
No related tags found
No related merge requests found
...@@ -32,31 +32,19 @@ ...@@ -32,31 +32,19 @@
namespace ProjectExplorer namespace ProjectExplorer
{ {
Task::Task() : type(Unknown), line(-1) unsigned int Task::s_nextId = 0;
{ }
Task::Task() : taskId(s_nextId), type(Unknown), line(-1)
{
++s_nextId;
}
Task::Task(TaskType type_, const QString &description_, Task::Task(TaskType type_, const QString &description_,
const QString &file_, int line_, const QString &category_) : const QString &file_, int line_, const QString &category_) :
type(type_), description(description_), file(file_), line(line_), category(category_) taskId(s_nextId), type(type_), description(description_), file(file_),
{ } line(line_), category(category_)
Task::Task(const Task &source) :
type(source.type), description(source.description), file(source.file),
line(source.line), category(source.category), formats(source.formats)
{ }
Task::~Task()
{ }
Task &Task::operator=(const Task &source)
{ {
type = source.type; ++s_nextId;
description = source.description;
file = source.file;
line = source.line;
category = source.category;
formats = source.formats;
return *this;
} }
// //
...@@ -64,19 +52,12 @@ Task &Task::operator=(const Task &source) ...@@ -64,19 +52,12 @@ Task &Task::operator=(const Task &source)
// //
bool operator==(const Task &t1, const Task &t2) bool operator==(const Task &t1, const Task &t2)
{ {
return t1.type == t2.type return t1.taskId == t2.taskId;
&& t1.line == t2.line
&& t1.description == t2.description
&& t1.file == t2.file
&& t1.category == t2.category;
} }
uint qHash(const Task &task) uint qHash(const Task &task)
{ {
return static_cast<int>(task.type) + return task.taskId;
task.line +
qHash(task.file) +
qHash(task.category);
} }
} // namespace ProjectExplorer } // namespace ProjectExplorer
...@@ -51,11 +51,8 @@ public: ...@@ -51,11 +51,8 @@ public:
Task(); Task();
Task(TaskType type_, const QString &description_, Task(TaskType type_, const QString &description_,
const QString &file_, int line_, const QString &category_); const QString &file_, int line_, const QString &category_);
Task(const Task &source);
~Task();
Task &operator=(const Task &source);
unsigned int taskId;
TaskType type; TaskType type;
QString description; QString description;
QString file; QString file;
...@@ -70,6 +67,8 @@ public: ...@@ -70,6 +67,8 @@ public:
// doesn't work if you split it up, nor are our parsers // doesn't work if you split it up, nor are our parsers
// anywhere near being that good // anywhere near being that good
QList<QTextLayout::FormatRange> formats; QList<QTextLayout::FormatRange> formats;
private:
static unsigned int s_nextId;
}; };
bool operator==(const Task &t1, const Task &t2); bool operator==(const Task &t1, const Task &t2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment