Commit 64b4ce9d authored by Milian Wolff's avatar Milian Wolff
Browse files

Use ProblemScope in favor of plan int in more places

Improved typesafety and easier to understand code.
parent b0e65127
......@@ -377,7 +377,7 @@ bool ProblemModel::showImports() const
return d->m_problems->showImports();
}
void ProblemModel::setScope(int scope)
void ProblemModel::setScope(ProblemScope scope)
{
Q_D(ProblemModel);
......
......@@ -13,8 +13,10 @@
#include <shell/problem.h>
#include <language/editor/documentrange.h>
#include "problemconstants.h"
namespace KDevelop {
class IDocument;
class IDocument;
class IndexedString;
class ProblemStore;
class ProblemModelPrivate;
......@@ -163,7 +165,7 @@ public Q_SLOTS:
void setShowImports(bool showImports);
/// Sets the scope filter
void setScope(int scope);
void setScope(ProblemScope scope);
/// Sets the severity filter
void setSeverity(int severity);///old-style severity filtering
......
......@@ -195,22 +195,21 @@ WatchedDocumentSet* ProblemStore::documents() const
return d->m_documents;
}
void ProblemStore::setScope(int scope)
void ProblemStore::setScope(ProblemScope scope)
{
Q_D(ProblemStore);
auto cast_scope = static_cast<ProblemScope>(scope);
bool showImports = false;
if (d->m_documents) {
if(cast_scope == d->m_documents->scope())
if (scope == d->m_documents->scope())
return;
showImports = d->m_documents->showImports();
delete d->m_documents;
}
switch (cast_scope) {
switch (scope) {
case CurrentDocument:
d->m_documents = new CurrentDocumentSet(d->m_currentDocument, this);
break;
......@@ -237,7 +236,7 @@ void ProblemStore::setScope(int scope)
emit changed();
}
int ProblemStore::scope() const
ProblemScope ProblemStore::scope() const
{
Q_D(const ProblemStore);
......
......@@ -11,6 +11,8 @@
#include <shell/shellexport.h>
#include <interfaces/iproblem.h>
#include "problemconstants.h"
namespace KDevelop
{
......@@ -95,10 +97,10 @@ public:
WatchedDocumentSet* documents() const;
/// Sets the scope filter
void setScope(int scope);
void setScope(ProblemScope scope);
/// Returns the current scope
int scope() const;
ProblemScope scope() const;
/// Sets the grouping method
virtual void setGrouping(int grouping);
......
......@@ -461,7 +461,7 @@ void ProblemsView::handleSeverityActionToggled()
(m_hintSeverityAction->isChecked() ? IProblem::Hint : IProblem::Severities()) );
}
void ProblemsView::setScope(int scope)
void ProblemsView::setScope(ProblemScope scope)
{
m_scopeMenu->setText(i18nc("@title:menu", "Scope: %1", m_scopeMenu->menu()->actions().at(scope)->text()));
......
......@@ -9,6 +9,8 @@
#include <interfaces/itoolviewactionlistener.h>
#include <problemconstants.h>
#include <QWidget>
class ProblemTreeView;
......@@ -73,7 +75,7 @@ private:
void updateActions();
void handleSeverityActionToggled();
void setScope(int scope);
void setScope(ProblemScope scope);
/// Create a view for the model and add to the tabbed widget
void addModel(const ModelData& data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment