diff --git a/src/plugins/clangtools/clangtidyclazytool.cpp b/src/plugins/clangtools/clangtidyclazytool.cpp index 0442c5f293d..a554b2c6b43 100644 --- a/src/plugins/clangtools/clangtidyclazytool.cpp +++ b/src/plugins/clangtools/clangtidyclazytool.cpp @@ -30,6 +30,7 @@ #include "clangtoolsdiagnosticmodel.h" #include "clangtoolslogfilereader.h" #include "clangtidyclazyruncontrol.h" +#include "clangstaticanalyzerdiagnosticview.h" #include #include @@ -64,12 +65,27 @@ ClangTidyClazyTool::ClangTidyClazyTool() setObjectName("ClangTidyClazyTool"); s_instance = this; - m_diagnosticView = new Debugger::DetailedErrorView; + m_diagnosticFilterModel = new ClangStaticAnalyzerDiagnosticFilterModel(this); + m_diagnosticFilterModel->setSourceModel(m_diagnosticModel); + + m_diagnosticView = new ClangStaticAnalyzerDiagnosticView; initDiagnosticView(); - m_diagnosticView->setModel(m_diagnosticModel); + m_diagnosticView->setModel(m_diagnosticFilterModel); m_diagnosticView->setObjectName(QLatin1String("ClangTidyClazyIssuesView")); m_diagnosticView->setWindowTitle(tr("Clang-Tidy and Clazy Issues")); + foreach (auto * const model, + QList() << m_diagnosticModel << m_diagnosticFilterModel) { + connect(model, &QAbstractItemModel::rowsInserted, + this, &ClangTidyClazyTool::handleStateUpdate); + connect(model, &QAbstractItemModel::rowsRemoved, + this, &ClangTidyClazyTool::handleStateUpdate); + connect(model, &QAbstractItemModel::modelReset, + this, &ClangTidyClazyTool::handleStateUpdate); + connect(model, &QAbstractItemModel::layoutChanged, // For QSortFilterProxyModel::invalidate() + this, &ClangTidyClazyTool::handleStateUpdate); + } + ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER); const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the " "Clang project to search for errors and warnings."); @@ -141,6 +157,7 @@ void ClangTidyClazyTool::startTool(bool askUserForFileSelection) m_diagnosticModel->clear(); setToolBusy(true); + m_diagnosticFilterModel->setProject(project); m_running = true; handleStateUpdate(); updateRunActions(); diff --git a/src/plugins/clangtools/clangtidyclazytool.h b/src/plugins/clangtools/clangtidyclazytool.h index 0ec9e2e6084..ad72eb496d0 100644 --- a/src/plugins/clangtools/clangtidyclazytool.h +++ b/src/plugins/clangtools/clangtidyclazytool.h @@ -30,9 +30,12 @@ namespace ClangTools { namespace Internal { +class ClangStaticAnalyzerDiagnosticFilterModel; + const char ClangTidyClazyPerspectiveId[] = "ClangTidyClazy.Perspective"; const char ClangTidyClazyDockId[] = "ClangTidyClazy.Dock"; +// TODO: Add "go next" and "go previous" button like for the static analyzer class ClangTidyClazyTool final : public ClangTool { Q_OBJECT @@ -52,6 +55,8 @@ private: void handleStateUpdate() final; void updateRunActions(); + + ClangStaticAnalyzerDiagnosticFilterModel *m_diagnosticFilterModel = nullptr; }; } // namespace Internal