forked from qt-creator/qt-creator
Issues: Prevent ever-growing session
The session contains a list of disabled issue categories, and that was growing with each start of Qt Creator, accumulating entries for categories that are added as "disabled by default". When adding a category as "disabled by default", it would unconditionally append it to the list of disabled categories. This list is saved and restored at Qt Creator restart, and then, when the category is added by the code as disabled by default, it was appended again, now appearing twice. Use a set for the disabled categories internally to avoid this. Change-Id: I0e2fae92d5b78d6bcc13d946f27241ddb8da84b6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -117,8 +117,12 @@ public:
|
||||
bool filterIncludesErrors() const { return m_includeErrors; }
|
||||
void setFilterIncludesErrors(bool b) { m_includeErrors = b; invalidateFilter(); }
|
||||
|
||||
QList<Utils::Id> filteredCategories() const { return m_categoryIds; }
|
||||
void setFilteredCategories(const QList<Utils::Id> &categoryIds) { m_categoryIds = categoryIds; invalidateFilter(); }
|
||||
QSet<Utils::Id> filteredCategories() const { return m_categoryIds; }
|
||||
void setFilteredCategories(const QSet<Utils::Id> &categoryIds)
|
||||
{
|
||||
m_categoryIds = categoryIds;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
Task task(const QModelIndex &index) const { return taskModel()->task(mapToSource(index)); }
|
||||
Tasks tasks(const QModelIndexList &indexes) const;
|
||||
@@ -144,7 +148,7 @@ private:
|
||||
bool m_filterStringIsRegexp = false;
|
||||
bool m_filterIsInverted = false;
|
||||
Qt::CaseSensitivity m_filterCaseSensitivity = Qt::CaseInsensitive;
|
||||
QList<Utils::Id> m_categoryIds;
|
||||
QSet<Utils::Id> m_categoryIds;
|
||||
QString m_filterText;
|
||||
QRegularExpression m_filterRegexp;
|
||||
};
|
||||
|
@@ -327,19 +327,20 @@ void TaskWindow::setCategoryVisibility(Id categoryId, bool visible)
|
||||
if (!categoryId.isValid())
|
||||
return;
|
||||
|
||||
QList<Id> categories = d->m_filter->filteredCategories();
|
||||
QSet<Id> categories = d->m_filter->filteredCategories();
|
||||
|
||||
if (visible)
|
||||
categories.removeOne(categoryId);
|
||||
categories.remove(categoryId);
|
||||
else
|
||||
categories.append(categoryId);
|
||||
categories.insert(categoryId);
|
||||
|
||||
d->m_filter->setFilteredCategories(categories);
|
||||
}
|
||||
|
||||
void TaskWindow::saveSettings()
|
||||
{
|
||||
QStringList categories = Utils::transform(d->m_filter->filteredCategories(), &Id::toString);
|
||||
const QStringList categories = Utils::toList(
|
||||
Utils::transform(d->m_filter->filteredCategories(), &Id::toString));
|
||||
SessionManager::setValue(QLatin1String(SESSION_FILTER_CATEGORIES), categories);
|
||||
SessionManager::setValue(QLatin1String(SESSION_FILTER_WARNINGS), d->m_filter->filterIncludesWarnings());
|
||||
}
|
||||
@@ -348,7 +349,8 @@ void TaskWindow::loadSettings()
|
||||
{
|
||||
QVariant value = SessionManager::value(QLatin1String(SESSION_FILTER_CATEGORIES));
|
||||
if (value.isValid()) {
|
||||
QList<Id> categories = Utils::transform(value.toStringList(), &Id::fromString);
|
||||
const QSet<Id> categories = Utils::toSet(
|
||||
Utils::transform(value.toStringList(), &Id::fromString));
|
||||
d->m_filter->setFilteredCategories(categories);
|
||||
}
|
||||
value = SessionManager::value(QLatin1String(SESSION_FILTER_WARNINGS));
|
||||
@@ -369,8 +371,8 @@ void TaskWindow::addCategory(Id categoryId, const QString &displayName, bool vis
|
||||
{
|
||||
d->m_model->addCategory(categoryId, displayName, priority);
|
||||
if (!visible) {
|
||||
QList<Id> filters = d->m_filter->filteredCategories();
|
||||
filters += categoryId;
|
||||
QSet<Id> filters = d->m_filter->filteredCategories();
|
||||
filters.insert(categoryId);
|
||||
d->m_filter->setFilteredCategories(filters);
|
||||
}
|
||||
}
|
||||
@@ -469,7 +471,7 @@ void TaskWindow::updateCategoriesMenu()
|
||||
|
||||
d->m_categoriesMenu->clear();
|
||||
|
||||
const QList<Id> filteredCategories = d->m_filter->filteredCategories();
|
||||
const QSet<Id> filteredCategories = d->m_filter->filteredCategories();
|
||||
|
||||
QMap<QString, Id> nameToIds;
|
||||
const QList<Id> ids = d->m_model->categoryIds();
|
||||
|
Reference in New Issue
Block a user