diff --git a/plugins/problemreporter/problemsview.cpp b/plugins/problemreporter/problemsview.cpp --- a/plugins/problemreporter/problemsview.cpp +++ b/plugins/problemreporter/problemsview.cpp @@ -46,7 +46,6 @@ m_fullUpdateAction = new QAction(this); m_fullUpdateAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_fullUpdateAction->setText(i18n("Force Full Update")); - m_fullUpdateAction->setToolTip(i18nc("@info:tooltip", "Re-parse all watched documents")); m_fullUpdateAction->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); connect(m_fullUpdateAction, &QAction::triggered, this, [this]() { currentView()->model()->forceFullUpdate(); @@ -242,6 +241,7 @@ Q_ASSERT(problemModel); m_fullUpdateAction->setVisible(problemModel->features().testFlag(ProblemModel::CanDoFullUpdate)); + m_fullUpdateAction->setToolTip(problemModel->fullUpdateTooltip()); m_showImportsAction->setVisible(problemModel->features().testFlag(ProblemModel::CanShowImports)); m_scopeMenu->setVisible(problemModel->features().testFlag(ProblemModel::ScopeFilter)); m_severityActions->setVisible(problemModel->features().testFlag(ProblemModel::SeverityFilter)); @@ -428,8 +428,15 @@ static const QString parserId = QStringLiteral("Parser"); - ProblemTreeView* view = new ProblemTreeView(nullptr, newData.model); + auto model = newData.model; + auto view = new ProblemTreeView(nullptr, model); connect(view, &ProblemTreeView::changed, this, &ProblemsView::onViewChanged); + connect(model, &ProblemModel::fullUpdateTooltipChanged, + this, [this, model]() { + if (currentView()->model() == model) { + m_fullUpdateAction->setToolTip(model->fullUpdateTooltip()); + } + }); int insertIdx = 0; if (newData.id != parserId) { @@ -447,7 +454,7 @@ m_tabWidget->insertTab(insertIdx, view, newData.name); m_models.insert(insertIdx, newData); - updateTab(insertIdx, view->model()->rowCount()); + updateTab(insertIdx, model->rowCount()); } void ProblemsView::updateTab(int idx, int rows) diff --git a/shell/problemmodel.h b/shell/problemmodel.h --- a/shell/problemmodel.h +++ b/shell/problemmodel.h @@ -141,13 +141,24 @@ /// Set the supported features void setFeatures(Features features); + /// Tooltip for "Force Full Update" action in the Problems View when the model + /// is active (correspondent tab is selected) + QString fullUpdateTooltip() const; + + /// Set the "Force Full Update" action tooltip + void setFullUpdateTooltip(const QString& tooltip); + signals: /// Emitted when the stored problems are changed with addProblem(), setProblems() and /// clearProblems() methods. This signal emitted only when internal problems storage is /// really changed: for example, it is not emitted when we call clearProblems() method /// for empty model. void problemsChanged(); + /// Emitted when the "Force Full Update" action tooltip is changed with setFullUpdateTooltip(). + /// This signal emitted only when tooltip is really changed. + void fullUpdateTooltipChanged(); + public slots: /// Show imports void setShowImports(bool showImports); diff --git a/shell/problemmodel.cpp b/shell/problemmodel.cpp --- a/shell/problemmodel.cpp +++ b/shell/problemmodel.cpp @@ -62,11 +62,13 @@ explicit ProblemModelPrivate(KDevelop::ProblemStore *store) : m_problems(store) , m_features(KDevelop::ProblemModel::NoFeatures) + , m_fullUpdateTooltip(i18nc("@info:tooltip", "Re-parse all watched documents")) { } QScopedPointer m_problems; KDevelop::ProblemModel::Features m_features; + QString m_fullUpdateTooltip; }; namespace KDevelop @@ -233,6 +235,21 @@ d->m_features = features; } +QString ProblemModel::fullUpdateTooltip() const +{ + return d->m_fullUpdateTooltip; +} + +void ProblemModel::setFullUpdateTooltip(const QString& tooltip) +{ + if (d->m_fullUpdateTooltip == tooltip) { + return; + } + + d->m_fullUpdateTooltip = tooltip; + emit fullUpdateTooltipChanged(); +} + void ProblemModel::addProblem(const IProblem::Ptr &problem) { int c = d->m_problems->count();