diff --git a/plugins/problemreporter/problemtreeview.h b/plugins/problemreporter/problemtreeview.h --- a/plugins/problemreporter/problemtreeview.h +++ b/plugins/problemreporter/problemtreeview.h @@ -64,6 +64,8 @@ private slots: void itemActivated(const QModelIndex& index); + void setScope(int scope); + private: void resizeColumns(); ProblemReporterPlugin* m_plugin; diff --git a/plugins/problemreporter/problemtreeview.cpp b/plugins/problemreporter/problemtreeview.cpp --- a/plugins/problemreporter/problemtreeview.cpp +++ b/plugins/problemreporter/problemtreeview.cpp @@ -122,8 +122,8 @@ if (problemModel->features().testFlag(ProblemModel::ScopeFilter)) { KActionMenu* scopeMenu = new KActionMenu(this); scopeMenu->setDelayed(false); - scopeMenu->setText(i18n("Scope")); scopeMenu->setToolTip(i18nc("@info:tooltip", "Which files to display the problems for")); + scopeMenu->setObjectName(QStringLiteral("scopeMenu")); QActionGroup* scopeActions = new QActionGroup(this); @@ -162,6 +162,7 @@ scopeMenu->addAction(action); } addAction(scopeMenu); + setScope(CurrentDocument); // Show All should be default if it's supported. It helps with error messages that are otherwise invisible if (problemModel->features().testFlag(ProblemModel::CanByPassScopeFilter)) { @@ -192,35 +193,30 @@ static_cast(&QSignalMapper::map)); } - connect(scopeMapper, static_cast(&QSignalMapper::mapped), model(), - &ProblemModel::setScope); + connect(scopeMapper, static_cast(&QSignalMapper::mapped), this, + &ProblemTreeView::setScope); } if (problemModel->features().testFlag(ProblemModel::SeverityFilter)) { - KActionMenu* severityMenu = new KActionMenu(i18n("Severity"), this); - severityMenu->setDelayed(false); - severityMenu->setToolTip(i18nc("@info:tooltip", "Select the lowest level of problem severity to be displayed")); QActionGroup* severityActions = new QActionGroup(this); - - auto errorSeverityAction = new QAction(i18n("Error"), this); + auto errorSeverityAction = new QAction(this); errorSeverityAction->setToolTip(i18nc("@info:tooltip", "Display only errors")); errorSeverityAction->setIcon(QIcon::fromTheme("dialog-error")); - auto warningSeverityAction = new QAction(i18n("Warning"), this); + auto warningSeverityAction = new QAction(this); warningSeverityAction->setToolTip(i18nc("@info:tooltip", "Display errors and warnings")); warningSeverityAction->setIcon(QIcon::fromTheme("dialog-warning")); - auto hintSeverityAction = new QAction(i18n("Hint"), this); + auto hintSeverityAction = new QAction(this); hintSeverityAction->setToolTip(i18nc("@info:tooltip", "Display errors, warnings and hints")); hintSeverityAction->setIcon(QIcon::fromTheme("dialog-information")); QAction* severityActionArray[] = { errorSeverityAction, warningSeverityAction, hintSeverityAction }; for (int i = 0; i < 3; ++i) { severityActionArray[i]->setCheckable(true); severityActions->addAction(severityActionArray[i]); - severityMenu->addAction(severityActionArray[i]); + addAction(severityActionArray[i]); } - addAction(severityMenu); hintSeverityAction->setChecked(true); model()->setSeverity(IProblem::Hint); @@ -312,6 +308,15 @@ ICore::self()->documentController()->openDocument(url, start); } +void ProblemTreeView::setScope(int scope) +{ + foreach (auto action, actions()) + if (action->objectName() == QLatin1String("scopeMenu")) + action->setText(i18n("Scope: %1").arg(action->menu()->actions().at(scope)->text())); + + model()->setScope(scope); +} + void ProblemTreeView::resizeColumns() { for (int i = 0; i < model()->columnCount(); ++i)