forked from qt-creator/qt-creator
TaskModel: Sort task by id
Makes it easier to later find the task again, and does actually not change the order in the normal case Change-Id: I2f36f2e7a6ab52c06e35be22820438a809ecb012 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -114,14 +114,21 @@ QList<Task> TaskModel::tasks(const Core::Id &categoryId) const
|
||||
return taskList;
|
||||
}
|
||||
|
||||
bool sortById(const Task &task, unsigned int id)
|
||||
{
|
||||
return task.taskId < id;
|
||||
}
|
||||
|
||||
void TaskModel::addTask(const Task &task)
|
||||
{
|
||||
Q_ASSERT(m_categories.keys().contains(task.category));
|
||||
CategoryData &data = m_categories[task.category];
|
||||
CategoryData &global = m_categories[Core::Id()];
|
||||
|
||||
beginInsertRows(QModelIndex(), m_tasks.count(), m_tasks.count());
|
||||
m_tasks.append(task);
|
||||
QList<Task>::iterator it = qLowerBound(m_tasks.begin(), m_tasks.end(),task.taskId, sortById);
|
||||
int i = it - m_tasks.begin();
|
||||
beginInsertRows(QModelIndex(), i, i);
|
||||
m_tasks.insert(it, task);
|
||||
data.addTask(task);
|
||||
global.addTask(task);
|
||||
endInsertRows();
|
||||
|
||||
@@ -116,7 +116,7 @@ private:
|
||||
};
|
||||
|
||||
QHash<Core::Id,CategoryData> m_categories; // category id to data
|
||||
QList<Task> m_tasks; // all tasks (in order of insertion)
|
||||
QList<Task> m_tasks; // all tasks (in order of id)
|
||||
|
||||
QHash<QString,bool> m_fileNotFound;
|
||||
int m_maxSizeOfFileName;
|
||||
|
||||
Reference in New Issue
Block a user