diff --git a/analyzers/cppcheck/problemmodel.h b/analyzers/cppcheck/problemmodel.h --- a/analyzers/cppcheck/problemmodel.h +++ b/analyzers/cppcheck/problemmodel.h @@ -60,7 +60,10 @@ Plugin* m_plugin; KDevelop::IProject* m_project; + KDevelop::DocumentRange m_projectLocation; + QString m_path; + KDevelop::DocumentRange m_pathLocation; 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 @@ -66,12 +66,8 @@ // 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(m_projectLocation); } for (auto diagnostic : problem->diagnostics()) { @@ -99,6 +95,7 @@ if (m_problems.isEmpty()) { maxLength = 0; + clearProblems(); // Remove starting notification } for (auto problem : problems) { @@ -121,7 +118,11 @@ void ProblemModel::setProblems() { - setProblems(m_problems); + if (m_problems.isEmpty()) { + setPlaceholderText(i18n("Analysis completed, no problems detected."), m_pathLocation); + } else { + setProblems(m_problems); + } } void ProblemModel::reset() @@ -132,14 +133,22 @@ void ProblemModel::reset(KDevelop::IProject* project, const QString& path) { m_project = project; + m_projectLocation = KDevelop::DocumentRange::invalid(); + if (m_project) { + m_projectLocation.document = KDevelop::IndexedString(m_project->path().toLocalFile()); + } + m_path = path; + m_pathLocation = KDevelop::DocumentRange::invalid(); + m_pathLocation.document = KDevelop::IndexedString(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)); + setPlaceholderText(i18n("Analysis started..."), m_pathLocation); } setFullUpdateTooltip(tooltip); }