Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
cedf9e21
Commit
cedf9e21
authored
Jun 08, 2010
by
dt
Browse files
Optimize the taskCount tracking
Saving another 20%
parent
7bfb7a62
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/taskwindow.cpp
View file @
cedf9e21
...
...
@@ -128,6 +128,9 @@ public:
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)
...
...
@@ -137,6 +140,8 @@ private:
int
m_maxSizeOfFileName
;
const
QIcon
m_errorIcon
;
const
QIcon
m_warningIcon
;
int
m_taskCount
;
int
m_errorTaskCount
;
};
class
TaskFilterModel
:
public
QSortFilterProxyModel
...
...
@@ -214,8 +219,21 @@ void TaskView::keyPressEvent(QKeyEvent *e)
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
...
...
@@ -270,6 +288,9 @@ void TaskModel::addTask(const Task &task)
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
)
...
...
@@ -278,6 +299,9 @@ 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
();
}
}
...
...
@@ -290,11 +314,14 @@ void TaskModel::clearTasks(const QString &categoryId)
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
;
...
...
@@ -303,6 +330,8 @@ void TaskModel::clearTasks(const QString &categoryId)
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
...
...
@@ -314,6 +343,9 @@ void TaskModel::clearTasks(const QString &categoryId)
m_tasks
.
erase
(
m_tasks
.
begin
()
+
start
,
m_tasks
.
begin
()
+
index
);
m_taskCount
-=
index
-
start
;
m_errorTaskCount
-=
subErrorTaskCount
;
endRemoveRows
();
index
=
start
;
}
...
...
@@ -683,21 +715,14 @@ void TaskWindow::filterCategoryTriggered(QAction *action)
m_filter
->
setFilteredCategories
(
categories
);
}
int
TaskWindow
::
taskCount
(
const
QString
&
categoryId
)
const
int
TaskWindow
::
taskCount
()
const
{
return
m_model
->
task
s
(
categoryId
).
c
ount
();
return
m_model
->
task
C
ount
();
}
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
...
...
src/plugins/projectexplorer/taskwindow.h
View file @
cedf9e21
...
...
@@ -102,8 +102,8 @@ public:
void
removeTask
(
const
Task
&
task
);
void
clearTasks
(
const
QString
&
categoryId
=
QString
());
int
taskCount
(
const
QString
&
categoryId
=
QString
()
)
const
;
int
errorTaskCount
(
const
QString
&
categoryId
=
QString
()
)
const
;
int
taskCount
()
const
;
int
errorTaskCount
()
const
;
// IOutputPane
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment