forked from qt-creator/qt-creator
Issues pane: Show the right number of issues on the pane button
While we do want to show contextual messages from the compiler, the
number displayed on the button should correspond to the actual number of
issues (i.e. errors or warnings), and should not include the notes
around them.
We used to do this correctly, but broke it in acd0d02e28
.
Fixes: QTCREATORBUG-18490
Change-Id: Ib6b36f24b4f6bfe53ed5b977f0f88586c4d95b16
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -341,6 +341,16 @@ void TaskFilterModel::setFilterIncludesWarnings(bool b)
|
|||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TaskFilterModel::issuesCount(int startRow, int endRow) const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int r = startRow; r <= endRow; ++r) {
|
||||||
|
if (task(index(r, 0)).type != Task::Unknown)
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
void TaskFilterModel::updateFilterProperties(const QString &filterText,
|
void TaskFilterModel::updateFilterProperties(const QString &filterText,
|
||||||
Qt::CaseSensitivity caseSensitivity, bool isRegexp)
|
Qt::CaseSensitivity caseSensitivity, bool isRegexp)
|
||||||
{
|
{
|
||||||
|
@@ -140,6 +140,7 @@ public:
|
|||||||
void setFilteredCategories(const QList<Core::Id> &categoryIds) { m_categoryIds = categoryIds; invalidateFilter(); }
|
void setFilteredCategories(const QList<Core::Id> &categoryIds) { m_categoryIds = categoryIds; invalidateFilter(); }
|
||||||
|
|
||||||
Task task(const QModelIndex &index) const { return taskModel()->task(mapToSource(index)); }
|
Task task(const QModelIndex &index) const { return taskModel()->task(mapToSource(index)); }
|
||||||
|
int issuesCount(int startRow, int endRow) const;
|
||||||
|
|
||||||
bool hasFile(const QModelIndex &index) const
|
bool hasFile(const QModelIndex &index) const
|
||||||
{ return taskModel()->hasFile(mapToSource(index)); }
|
{ return taskModel()->hasFile(mapToSource(index)); }
|
||||||
|
@@ -227,6 +227,7 @@ public:
|
|||||||
QToolButton *m_categoriesButton;
|
QToolButton *m_categoriesButton;
|
||||||
QMenu *m_categoriesMenu;
|
QMenu *m_categoriesMenu;
|
||||||
QList<QAction *> m_actions;
|
QList<QAction *> m_actions;
|
||||||
|
int m_visibleIssuesCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
static QToolButton *createFilterButton(const QIcon &icon, const QString &toolTip,
|
static QToolButton *createFilterButton(const QIcon &icon, const QString &toolTip,
|
||||||
@@ -304,12 +305,20 @@ TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>())
|
|||||||
connect(hub, &TaskHub::showTask, this, &TaskWindow::showTask);
|
connect(hub, &TaskHub::showTask, this, &TaskWindow::showTask);
|
||||||
connect(hub, &TaskHub::openTask, this, &TaskWindow::openTask);
|
connect(hub, &TaskHub::openTask, this, &TaskWindow::openTask);
|
||||||
|
|
||||||
connect(d->m_filter, &TaskFilterModel::rowsRemoved,
|
connect(d->m_filter, &TaskFilterModel::rowsAboutToBeRemoved,
|
||||||
[this]() { emit setBadgeNumber(d->m_filter->rowCount()); });
|
[this](const QModelIndex &, int first, int last) {
|
||||||
|
d->m_visibleIssuesCount -= d->m_filter->issuesCount(first, last);
|
||||||
|
emit setBadgeNumber(d->m_visibleIssuesCount);
|
||||||
|
});
|
||||||
connect(d->m_filter, &TaskFilterModel::rowsInserted,
|
connect(d->m_filter, &TaskFilterModel::rowsInserted,
|
||||||
[this]() { emit setBadgeNumber(d->m_filter->rowCount()); });
|
[this](const QModelIndex &, int first, int last) {
|
||||||
connect(d->m_filter, &TaskFilterModel::modelReset,
|
d->m_visibleIssuesCount += d->m_filter->issuesCount(first, last);
|
||||||
[this]() { emit setBadgeNumber(d->m_filter->rowCount()); });
|
emit setBadgeNumber(d->m_visibleIssuesCount);
|
||||||
|
});
|
||||||
|
connect(d->m_filter, &TaskFilterModel::modelReset, [this] {
|
||||||
|
d->m_visibleIssuesCount = d->m_filter->issuesCount(0, d->m_filter->rowCount());
|
||||||
|
emit setBadgeNumber(d->m_visibleIssuesCount);
|
||||||
|
});
|
||||||
|
|
||||||
SessionManager *session = SessionManager::instance();
|
SessionManager *session = SessionManager::instance();
|
||||||
connect(session, &SessionManager::aboutToSaveSession, this, &TaskWindow::saveSettings);
|
connect(session, &SessionManager::aboutToSaveSession, this, &TaskWindow::saveSettings);
|
||||||
|
Reference in New Issue
Block a user