QIcon taskTypeIcon(Task::TaskType t) const;
+ int taskCount();
+ int errorTaskCount();
+
private:
QHash<QString,QString> m_categories; // category id -> display name
QList<Task> m_tasks; // all tasks (in order of insertion)
int m_maxSizeOfFileName;
const QIcon m_errorIcon;
const QIcon m_warningIcon;
+ int m_taskCount;
+ int m_errorTaskCount;
};
class TaskFilterModel : public QSortFilterProxyModel
TaskModel::TaskModel() :
m_maxSizeOfFileName(0),
m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")),
- m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
+ m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png")),
+ m_taskCount(0),
+ m_errorTaskCount(0)
+{
+
+}
+
+int TaskModel::taskCount()
+{
+ return m_taskCount;
+}
+
+int TaskModel::errorTaskCount()
{
+ return m_errorTaskCount;
}
QIcon TaskModel::taskTypeIcon(Task::TaskType t) const
filename = task.file.mid(pos +1);
m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));
+ ++m_taskCount;
+ if (task.type == Task::Error)
+ ++m_errorTaskCount;
}
void TaskModel::removeTask(const Task &task)
int index = m_tasks.indexOf(task);
beginRemoveRows(QModelIndex(), index, index);
m_tasks.removeAt(index);
+ --m_taskCount;
+ if (task.type == Task::Error)
+ --m_errorTaskCount;
endRemoveRows();
}
}
beginRemoveRows(QModelIndex(), 0, m_tasks.size() -1);
m_tasks.clear();
m_tasksInCategory.clear();
+ m_taskCount = 0;
+ m_errorTaskCount = 0;
endRemoveRows();
m_maxSizeOfFileName = 0;
} else {
int index = 0;
int start = 0;
+ int subErrorTaskCount = 0;
while (index < m_tasks.size()) {
while (index < m_tasks.size() && m_tasks.at(index).category != categoryId) {
++start;
if (index == m_tasks.size())
break;
while (index < m_tasks.size() && m_tasks.at(index).category == categoryId) {
+ if (m_tasks.at(index).type == Task::Error)
+ ++subErrorTaskCount;
++index;
}
// Index is now on the first non category
m_tasks.erase(m_tasks.begin() + start, m_tasks.begin() + index);
+ m_taskCount -= index - start;
+ m_errorTaskCount -= subErrorTaskCount;
+
endRemoveRows();
index = start;
}
m_filter->setFilteredCategories(categories);
}
-int TaskWindow::taskCount(const QString &categoryId) const
+int TaskWindow::taskCount() const
{
- return m_model->tasks(categoryId).count();
+ return m_model->taskCount();
}
-int TaskWindow::errorTaskCount(const QString &categoryId) const
+int TaskWindow::errorTaskCount() const
{
- int errorTaskCount = 0;
-
- foreach (const Task &task, m_model->tasks(categoryId)) {
- if (task.type == Task::Error)
- ++ errorTaskCount;
- }
-
- return errorTaskCount;
+ return m_model->errorTaskCount();
}
int TaskWindow::priorityInStatusBar() const