Commit c22cd775 authored by Milian Wolff's avatar Milian Wolff
Browse files

Introduce new DocumentsInCurrentPath problem scope

This tracks the current document and then sets its path automatically
on a DocumentsInPathSet which is quite useful for me to have in large
projects when doing refactorings.
parent 1ba4c4dd
......@@ -18,6 +18,7 @@ enum ProblemScope {
CurrentProject,
AllProjects,
DocumentsInPath,
DocumentsInCurrentPath, // basically combination of DocumentsInPath and CurrentDocument
BypassScopeFilter // Special setting. Bypasses the filter in FilteredProblemStore
};
......
......@@ -228,6 +228,9 @@ void ProblemStore::setScope(ProblemScope scope)
case DocumentsInPath:
d->m_documents = new DocumentsInPathSet(d->m_pathForDocumentsInPathScope, this);
break;
case DocumentsInCurrentPath:
d->m_documents = new DocumentsInCurrentPathSet(d->m_currentDocument, this);
break;
case BypassScopeFilter:
d->m_documents = new BypassSet(this);
break;
......
......@@ -17,6 +17,8 @@
#include <project/interfaces/iprojectfilemanager.h>
#include <project/projectmodel.h>
#include <QFileInfo>
namespace KDevelop
{
......@@ -428,6 +430,21 @@ bool DocumentsInPathSet::include(const IndexedString& path) const
return path.str().contains(m_path, Qt::CaseInsensitive);
}
DocumentsInCurrentPathSet::DocumentsInCurrentPathSet(const IndexedString& document, QObject* parent)
: DocumentsInPathSet(QFileInfo(document.str()).path(), parent)
{
}
ProblemScope DocumentsInCurrentPathSet::scope() const
{
return DocumentsInCurrentPath;
}
void DocumentsInCurrentPathSet::setCurrentDocument(const IndexedString& document)
{
setPath(QFileInfo(document.str()).path());
}
BypassSet::BypassSet(QObject* parent)
: WatchedDocumentSet(parent)
{
......
......@@ -147,6 +147,15 @@ private:
QString m_path;
};
class DocumentsInCurrentPathSet : public DocumentsInPathSet
{
Q_OBJECT
public:
explicit DocumentsInCurrentPathSet(const IndexedString& document, QObject* parent);
ProblemScope scope() const override;
void setCurrentDocument(const IndexedString& url) override;
};
class BypassSet : public WatchedDocumentSet
{
Q_OBJECT
......
......@@ -73,13 +73,18 @@ void ProblemsView::setupActions()
documentsInPathAction->setText(i18nc("@option:check", "Documents In Path"));
documentsInPathAction->setToolTip(i18nc("@info:tooltip", "Display problems from all files in a specific path"));
auto* documentsInCurrentPathAction = new QAction(this);
documentsInCurrentPathAction->setText(i18nc("@option:check", "Documents In Current Path"));
documentsInCurrentPathAction->setToolTip(
i18nc("@info:tooltip", "Display problems from all files in the path of the current document"));
m_showAllAction = new QAction(this);
m_showAllAction->setText(i18nc("@option:check", "Show All"));
m_showAllAction->setToolTip(i18nc("@info:tooltip", "Display all problems"));
QAction* const actions[] = {
m_currentDocumentAction, openDocumentsAction, currentProjectAction,
allProjectAction, documentsInPathAction, m_showAllAction,
m_currentDocumentAction, openDocumentsAction, currentProjectAction, allProjectAction,
documentsInPathAction, documentsInCurrentPathAction, m_showAllAction,
};
for (QAction* action : actions) {
......@@ -118,6 +123,8 @@ void ProblemsView::setupActions()
connect(currentProjectAction, &QAction::triggered, this, [this](){ setScope(CurrentProject); });
connect(allProjectAction, &QAction::triggered, this, [this](){ setScope(AllProjects); });
connect(documentsInPathAction, &QAction::triggered, this, [this]() { setScope(DocumentsInPath); });
connect(documentsInCurrentPathAction, &QAction::triggered, this,
[this]() { setScope(DocumentsInCurrentPath); });
connect(m_showAllAction, &QAction::triggered, this, [this](){ setScope(BypassScopeFilter); });
}
......
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