Make the TaskView 10% faster by caching how wide "8888" is.

This commit is contained in:
dt
2010-06-08 17:36:47 +02:00
parent 769e67c353
commit 27bdfe510e

View File

@@ -142,6 +142,7 @@ private:
const QIcon m_warningIcon; const QIcon m_warningIcon;
int m_taskCount; int m_taskCount;
int m_errorTaskCount; int m_errorTaskCount;
int m_sizeOfLineNumber;
}; };
class TaskFilterModel : public QSortFilterProxyModel class TaskFilterModel : public QSortFilterProxyModel
@@ -221,7 +222,8 @@ TaskModel::TaskModel() :
m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")), 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_taskCount(0),
m_errorTaskCount(0) m_errorTaskCount(0),
m_sizeOfLineNumber(0)
{ {
} }
@@ -422,9 +424,12 @@ int TaskModel::sizeOfFile()
int TaskModel::sizeOfLineNumber() int TaskModel::sizeOfLineNumber()
{ {
QFont font; if (m_sizeOfLineNumber == 0) {
QFontMetrics fm(font); QFont font;
return fm.width("8888"); QFontMetrics fm(font);
m_sizeOfLineNumber = fm.width("8888");
}
return m_sizeOfLineNumber;
} }
void TaskModel::setFileNotFound(const QModelIndex &idx, bool b) void TaskModel::setFileNotFound(const QModelIndex &idx, bool b)