diff --git a/analyzers/cppcheck/problemmodel.h b/analyzers/cppcheck/problemmodel.h --- a/analyzers/cppcheck/problemmodel.h +++ b/analyzers/cppcheck/problemmodel.h @@ -52,13 +52,16 @@ void forceFullUpdate() override; private: + KDevelop::DocumentRange projectLocation() const; void fixProblemFinalLocation(KDevelop::IProblem::Ptr problem); + using KDevelop::ProblemModel::setProblems; Plugin* m_plugin; KDevelop::IProject* m_project; QString m_path; + QString m_prettyPath; QVector m_problems; }; diff --git a/analyzers/cppcheck/problemmodel.cpp b/analyzers/cppcheck/problemmodel.cpp --- a/analyzers/cppcheck/problemmodel.cpp +++ b/analyzers/cppcheck/problemmodel.cpp @@ -60,18 +60,24 @@ return m_project; } +KDevelop::DocumentRange ProblemModel::projectLocation() const +{ + Q_ASSERT(m_project); + + KDevelop::DocumentRange location; + location.document = KDevelop::IndexedString(m_project->path().toLocalFile()); + + return location; +} + void ProblemModel::fixProblemFinalLocation(KDevelop::IProblem::Ptr problem) { // Fix problems with incorrect range, which produced by cppcheck's errors // without element. In this case location automatically gets "/". // To avoid this we set project's root path as problem location. - Q_ASSERT(m_project); - - auto range = problem->finalLocation(); - if (range.document.isEmpty()) { - range.document = KDevelop::IndexedString(m_project->path().toLocalFile()); - problem->setFinalLocation(range); + if (problem->finalLocation().document.isEmpty()) { + problem->setFinalLocation(projectLocation()); } for (auto diagnostic : problem->diagnostics()) { @@ -85,6 +91,7 @@ if (m_problems.isEmpty()) { maxLength = 0; + clearProblems(); // Remove starting notification } for (auto problem : problems) { @@ -103,7 +110,13 @@ void ProblemModel::setProblems() { - setProblems(m_problems); + if (m_problems.isEmpty()) { + setPlaceHolderText(i18n("Analysis of (%1) completed, no problems detected.", m_prettyPath), + QString(), + projectLocation()); + } else { + setProblems(m_problems); + } } void ProblemModel::reset() @@ -115,13 +128,17 @@ { m_project = project; m_path = path; + m_prettyPath = prettyPathName(m_path); clearProblems(); m_problems.clear(); QString tooltip = i18nc("@info:tooltip", "Re-Run Last Cppcheck Analysis"); if (m_project) { - tooltip += QString(" (%1)").arg(prettyPathName(m_path)); + tooltip += QString(" (%1)").arg(m_prettyPath); + setPlaceHolderText(i18n("Analysis of (%1) started, expect problems to come...", m_prettyPath), + QString(), + projectLocation()); } setFullUpdateTooltip(tooltip); }