Changeset View
Changeset View
Standalone View
Standalone View
analyzers/cppcheck/problemmodel.cpp
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | void ProblemModel::fixProblemFinalLocation(KDevelop::IProblem::Ptr problem) | 63 | void ProblemModel::fixProblemFinalLocation(KDevelop::IProblem::Ptr problem) | ||
64 | { | 64 | { | ||
65 | // Fix problems with incorrect range, which produced by cppcheck's errors | 65 | // Fix problems with incorrect range, which produced by cppcheck's errors | ||
66 | // without <location> element. In this case location automatically gets "/". | 66 | // without <location> element. In this case location automatically gets "/". | ||
67 | // To avoid this we set project's root path as problem location. | 67 | // To avoid this we set project's root path as problem location. | ||
68 | 68 | | |||
69 | Q_ASSERT(m_project); | 69 | if (problem->finalLocation().document.isEmpty()) { | ||
70 | 70 | problem->setFinalLocation(m_projectLocation); | |||
71 | auto range = problem->finalLocation(); | | |||
72 | if (range.document.isEmpty()) { | | |||
73 | range.document = KDevelop::IndexedString(m_project->path().toLocalFile()); | | |||
74 | problem->setFinalLocation(range); | | |||
75 | } | 71 | } | ||
76 | 72 | | |||
77 | for (auto diagnostic : problem->diagnostics()) { | 73 | for (auto diagnostic : problem->diagnostics()) { | ||
78 | fixProblemFinalLocation(diagnostic); | 74 | fixProblemFinalLocation(diagnostic); | ||
79 | } | 75 | } | ||
80 | } | 76 | } | ||
81 | 77 | | |||
82 | bool ProblemModel::problemExists(KDevelop::IProblem::Ptr newProblem) | 78 | bool ProblemModel::problemExists(KDevelop::IProblem::Ptr newProblem) | ||
Show All 33 Lines | 111 | if (maxLength < problem->description().length()) { | |||
116 | maxLength = problem->description().length(); | 112 | maxLength = problem->description().length(); | ||
117 | setProblems(m_problems); | 113 | setProblems(m_problems); | ||
118 | } | 114 | } | ||
119 | } | 115 | } | ||
120 | } | 116 | } | ||
121 | 117 | | |||
122 | void ProblemModel::setProblems() | 118 | void ProblemModel::setProblems() | ||
123 | { | 119 | { | ||
120 | if (m_problems.isEmpty()) { | ||||
kfunk: Pretty hacky IMO | |||||
121 | setPlaceholderText(i18n("Analysis completed, no problems detected."), m_pathLocation); | ||||
122 | } else { | ||||
124 | setProblems(m_problems); | 123 | setProblems(m_problems); | ||
125 | } | 124 | } | ||
125 | } | ||||
126 | 126 | | |||
127 | void ProblemModel::reset() | 127 | void ProblemModel::reset() | ||
128 | { | 128 | { | ||
129 | reset(nullptr, QString()); | 129 | reset(nullptr, QString()); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void ProblemModel::reset(KDevelop::IProject* project, const QString& path) | 132 | void ProblemModel::reset(KDevelop::IProject* project, const QString& path) | ||
133 | { | 133 | { | ||
134 | m_project = project; | 134 | m_project = project; | ||
135 | m_projectLocation = KDevelop::DocumentRange::invalid(); | ||||
136 | if (m_project) { | ||||
137 | m_projectLocation.document = KDevelop::IndexedString(m_project->path().toLocalFile()); | ||||
138 | } | ||||
139 | | ||||
135 | m_path = path; | 140 | m_path = path; | ||
141 | m_pathLocation = KDevelop::DocumentRange::invalid(); | ||||
142 | m_pathLocation.document = KDevelop::IndexedString(m_path); | ||||
136 | 143 | | |||
137 | clearProblems(); | 144 | clearProblems(); | ||
138 | m_problems.clear(); | 145 | m_problems.clear(); | ||
139 | 146 | | |||
140 | QString tooltip = i18nc("@info:tooltip", "Re-Run Last Cppcheck Analysis"); | 147 | QString tooltip = i18nc("@info:tooltip", "Re-Run Last Cppcheck Analysis"); | ||
141 | if (m_project) { | 148 | if (m_project) { | ||
142 | tooltip += QString(" (%1)").arg(prettyPathName(m_path)); | 149 | tooltip += QString(" (%1)").arg(prettyPathName(m_path)); | ||
150 | setPlaceholderText(i18n("Analysis started..."), m_pathLocation); | ||||
as said in the other review: the placeholder should be set once, and then get displayed whenever the model is empty. also reword the message to make it less funny, and remove the parens: Analysis of %1 started... mwolff: as said in the other review: the placeholder should be set once, and then get displayed… | |||||
143 | } | 151 | } | ||
both times passing QString(), as I said in the other report - this argument should be removed mwolff: both times passing `QString()`, as I said in the other report - this argument should be removed | |||||
144 | setFullUpdateTooltip(tooltip); | 152 | setFullUpdateTooltip(tooltip); | ||
mwolff: I also don't get why we want to pass the location | |||||
145 | } | 153 | } | ||
146 | 154 | | |||
147 | void ProblemModel::show() | 155 | void ProblemModel::show() | ||
148 | { | 156 | { | ||
149 | problemModelSet()->showModel(problemModelId); | 157 | problemModelSet()->showModel(problemModelId); | ||
150 | } | 158 | } | ||
151 | 159 | | |||
152 | void ProblemModel::forceFullUpdate() | 160 | void ProblemModel::forceFullUpdate() | ||
153 | { | 161 | { | ||
154 | if (m_project && !m_plugin->isRunning()) { | 162 | if (m_project && !m_plugin->isRunning()) { | ||
155 | m_plugin->runCppcheck(m_project, m_path); | 163 | m_plugin->runCppcheck(m_project, m_path); | ||
156 | } | 164 | } | ||
157 | } | 165 | } | ||
158 | 166 | | |||
159 | } | 167 | } |
Pretty hacky IMO