From fa6e6bc742627cb609b51abeb10e512ebe53abe2 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Wed, 30 Jun 2010 16:37:07 +0200 Subject: [PATCH] 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 --- src/plugins/projectexplorer/task.cpp | 41 ++++++++-------------------- src/plugins/projectexplorer/task.h | 7 ++--- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp index 31054b339b7..947628ba823 100644 --- a/src/plugins/projectexplorer/task.cpp +++ b/src/plugins/projectexplorer/task.cpp @@ -32,31 +32,19 @@ 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_, const QString &file_, int line_, const QString &category_) : - 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) + taskId(s_nextId), type(type_), description(description_), file(file_), + line(line_), category(category_) { - type = source.type; - description = source.description; - file = source.file; - line = source.line; - category = source.category; - formats = source.formats; - return *this; + ++s_nextId; } // @@ -64,19 +52,12 @@ Task &Task::operator=(const Task &source) // bool operator==(const Task &t1, const Task &t2) { - return t1.type == t2.type - && t1.line == t2.line - && t1.description == t2.description - && t1.file == t2.file - && t1.category == t2.category; + return t1.taskId == t2.taskId; } uint qHash(const Task &task) { - return static_cast<int>(task.type) + - task.line + - qHash(task.file) + - qHash(task.category); + return task.taskId; } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h index e91c629e2c9..db6fa228e09 100644 --- a/src/plugins/projectexplorer/task.h +++ b/src/plugins/projectexplorer/task.h @@ -51,11 +51,8 @@ public: Task(); Task(TaskType type_, const QString &description_, const QString &file_, int line_, const QString &category_); - Task(const Task &source); - ~Task(); - - Task &operator=(const Task &source); + unsigned int taskId; TaskType type; QString description; QString file; @@ -70,6 +67,8 @@ public: // doesn't work if you split it up, nor are our parsers // anywhere near being that good QList<QTextLayout::FormatRange> formats; +private: + static unsigned int s_nextId; }; bool operator==(const Task &t1, const Task &t2); -- GitLab