File indexing completed on 2024-05-05 04:39:28
0001 /* 0002 SPDX-FileCopyrightText: 2018 Anton Anikin <anton@anikin.xyz> 0003 SPDX-FileCopyrightText: 2020 Friedrich W. H. Kossebau <kossebau@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef COMPILEANALYZER_COMPILEANALYZER_H 0009 #define COMPILEANALYZER_COMPILEANALYZER_H 0010 0011 // lib 0012 #include <compileanalyzercommonexport.h> 0013 // KDevPlatform 0014 #include <shell/problemmodel.h> 0015 // Qt 0016 #include <QObject> 0017 #include <QIcon> 0018 0019 class KJob; 0020 class QAction; 0021 class QWidget; 0022 0023 namespace KDevelop 0024 { 0025 class IPlugin; 0026 class ICore; 0027 class IProject; 0028 class ContextMenuExtension; 0029 class Context; 0030 class Path; 0031 class CompileAnalyzeProblemModel; 0032 class CompileAnalyzeJob; 0033 0034 class KDEVCOMPILEANALYZERCOMMON_EXPORT CompileAnalyzer : public QObject 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 CompileAnalyzer(IPlugin* plugin, 0040 const QString& toolName, const QString& toolIconName, 0041 const QString& fileActionId, const QString& allActionId, 0042 const QString& modelId, 0043 ProblemModel::Features modelFeatures, 0044 QObject* parent); 0045 ~CompileAnalyzer() override; 0046 0047 public: 0048 void fillContextMenuExtension(ContextMenuExtension &extension, 0049 Context* context, QWidget* parent); 0050 0051 protected: // API to implement 0052 virtual CompileAnalyzeJob* createJob(KDevelop::IProject* project, const KDevelop::Path& buildDirectory, 0053 const QUrl& url, const QStringList& filePaths) = 0; 0054 virtual bool isOutputToolViewPreferred() const; 0055 0056 private: 0057 void raiseProblemsToolView(); 0058 void raiseOutputToolView(); 0059 void killJob(); 0060 0061 bool isRunning() const; 0062 ICore* core() const; 0063 0064 private Q_SLOTS: 0065 void runTool(const QUrl& url, bool allFiles = false); 0066 void runTool(bool allFiles = false); 0067 void runToolOnFile(); 0068 void runToolOnAll(); 0069 0070 void handleRerunRequest(const QUrl& url, bool allFiles); 0071 void result(KJob* job); 0072 void updateActions(); 0073 void handleProjectClosed(KDevelop::IProject* project); 0074 0075 private: 0076 ICore* const m_core; 0077 const QString m_toolName; 0078 const QIcon m_toolIcon; 0079 const QString m_modelId; 0080 0081 CompileAnalyzeProblemModel* m_model; 0082 0083 CompileAnalyzeJob* m_job = nullptr; 0084 0085 QAction* m_checkFileAction; 0086 QAction* m_checkProjectAction; 0087 }; 0088 0089 } 0090 0091 #endif