make Tasks sortable

Sorting according to severity then id

Reviewed-By: hunger
This commit is contained in:
dt
2011-05-12 11:51:17 +02:00
parent 8ad489664d
commit 9ef4ea40f2
2 changed files with 27 additions and 2 deletions

View File

@@ -65,6 +65,29 @@ bool operator==(const Task &t1, const Task &t2)
return t1.taskId == t2.taskId;
}
bool operator<(const Task &a, const Task &b)
{
if (a.type != b.type) {
if (a.type == ProjectExplorer::Task::Error)
return true;
if (b.type == ProjectExplorer::Task::Error)
return false;
if (a.type == ProjectExplorer::Task::Warning)
return true;
if (b.type == ProjectExplorer::Task::Warning)
return false;
// Can't happen
return true;
} else {
if (a.category < b.category)
return true;
if (b.category < a.category)
return false;
return a.taskId < b.taskId;
}
}
uint qHash(const Task &task)
{
return task.taskId;

View File

@@ -76,8 +76,10 @@ private:
static unsigned int s_nextId;
};
bool operator==(const Task &t1, const Task &t2);
uint qHash(const Task &task);
bool PROJECTEXPLORER_EXPORT operator==(const Task &t1, const Task &t2);
uint PROJECTEXPLORER_EXPORT qHash(const Task &task);
bool PROJECTEXPLORER_EXPORT operator<(const Task &a, const Task &b);
} //namespace ProjectExplorer