forked from qt-creator/qt-creator
Support badge on output panel buttons.
These are used to indicate number of issues and todos. Change-Id: I320b6c0f5835570f0b5e5898fb140bd8266090c8 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
committed by
Daniel Teske
parent
54569d5931
commit
8a57b7bcbf
@@ -220,6 +220,7 @@ public:
|
||||
QToolButton *m_categoriesButton;
|
||||
QMenu *m_categoriesMenu;
|
||||
TaskHub *m_taskHub;
|
||||
int m_badgeCount;
|
||||
};
|
||||
|
||||
static QToolButton *createFilterButton(QIcon icon, const QString &toolTip,
|
||||
@@ -256,6 +257,7 @@ TaskWindow::TaskWindow(TaskHub *taskhub) : d(new TaskWindowPrivate)
|
||||
|
||||
d->m_taskWindowContext = new Internal::TaskWindowContext(d->m_listview);
|
||||
d->m_taskHub = taskhub;
|
||||
d->m_badgeCount = 0;
|
||||
|
||||
Core::ICore::addContextObject(d->m_taskWindowContext);
|
||||
|
||||
@@ -336,11 +338,22 @@ QWidget *TaskWindow::outputWidget(QWidget *)
|
||||
|
||||
void TaskWindow::clearTasks(const Core::Id &categoryId)
|
||||
{
|
||||
if (categoryId.uniqueIdentifier() != 0 && !d->m_filter->filteredCategories().contains(categoryId)) {
|
||||
if (d->m_filter->filterIncludesErrors())
|
||||
d->m_badgeCount -= d->m_model->errorTaskCount(categoryId);
|
||||
if (d->m_filter->filterIncludesWarnings())
|
||||
d->m_badgeCount -= d->m_model->warningTaskCount(categoryId);
|
||||
} else {
|
||||
d->m_badgeCount = 0;
|
||||
}
|
||||
|
||||
d->m_model->clearTasks(categoryId);
|
||||
|
||||
emit tasksChanged();
|
||||
emit tasksCleared();
|
||||
navigateStateChanged();
|
||||
|
||||
setBadgeNumber(d->m_badgeCount);
|
||||
}
|
||||
|
||||
void TaskWindow::setCategoryVisibility(const Core::Id &categoryId, bool visible)
|
||||
@@ -357,6 +370,17 @@ void TaskWindow::setCategoryVisibility(const Core::Id &categoryId, bool visible)
|
||||
}
|
||||
|
||||
d->m_filter->setFilteredCategories(categories);
|
||||
|
||||
int count = 0;
|
||||
if (d->m_filter->filterIncludesErrors())
|
||||
count += d->m_model->errorTaskCount(categoryId);
|
||||
if (d->m_filter->filterIncludesWarnings())
|
||||
count += d->m_model->warningTaskCount(categoryId);
|
||||
if (visible)
|
||||
d->m_badgeCount += count;
|
||||
else
|
||||
d->m_badgeCount -= count;
|
||||
setBadgeNumber(d->m_badgeCount);
|
||||
}
|
||||
|
||||
void TaskWindow::visibilityChanged(bool /* b */)
|
||||
@@ -383,6 +407,11 @@ void TaskWindow::addTask(const Task &task)
|
||||
if (task.type == Task::Error && d->m_filter->filterIncludesErrors() &&
|
||||
!d->m_filter->filteredCategories().contains(task.category)) {
|
||||
flash();
|
||||
setBadgeNumber(++d->m_badgeCount);
|
||||
}
|
||||
if (task.type == Task::Warning && d->m_filter->filterIncludesWarnings() &&
|
||||
!d->m_filter->filteredCategories().contains(task.category)) {
|
||||
setBadgeNumber(++d->m_badgeCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,6 +421,15 @@ void TaskWindow::removeTask(const Task &task)
|
||||
|
||||
emit tasksChanged();
|
||||
navigateStateChanged();
|
||||
|
||||
if (task.type == Task::Error && d->m_filter->filterIncludesErrors() &&
|
||||
!d->m_filter->filteredCategories().contains(task.category)) {
|
||||
setBadgeNumber(--d->m_badgeCount);
|
||||
}
|
||||
if (task.type == Task::Warning && d->m_filter->filterIncludesWarnings() &&
|
||||
!d->m_filter->filteredCategories().contains(task.category)) {
|
||||
setBadgeNumber(--d->m_badgeCount);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskWindow::updatedTaskFileName(unsigned int id, const QString &fileName)
|
||||
@@ -500,6 +538,7 @@ void TaskWindow::setShowWarnings(bool show)
|
||||
{
|
||||
d->m_filter->setFilterIncludesWarnings(show);
|
||||
d->m_filter->setFilterIncludesUnknowns(show); // "Unknowns" are often associated with warnings
|
||||
setBadgeNumber(d->m_filter->rowCount());
|
||||
}
|
||||
|
||||
void TaskWindow::updateCategoriesMenu()
|
||||
|
||||
Reference in New Issue
Block a user