File indexing completed on 2024-04-28 04:37:17
0001 /* 0002 SPDX-FileCopyrightText: 2015 Laszlo Kis-Adam <laszlo.kis-adam@kdemail.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef FILTEREDPROBLEMSTORE_H 0008 #define FILTEREDPROBLEMSTORE_H 0009 0010 #include "problemstore.h" 0011 #include "problemconstants.h" 0012 0013 0014 namespace KDevelop 0015 { 0016 0017 class FilteredProblemStorePrivate; 0018 0019 /** 0020 * @brief ProblemStore subclass that can group by severity, and path, and filter by scope, and severity. 0021 * 0022 * Internally grouping is implemented using a tree structure. 0023 * When grouping is on, the top level nodes are the groups, and their children are the nodes containing the problems that belong into that node. 0024 * If the problems have diagnostics, then the diagnostics are added as children nodes as well. This was implemented so they can be browsed in a model/view architecture. 0025 * When grouping is off, the top level nodes are the problem nodes. 0026 * 0027 * Grouping can be set and queried using the following methods 0028 * \li setGrouping(); 0029 * \li grouping(); 0030 * 0031 * Valid grouping settings: 0032 * \li NoGrouping 0033 * \li PathGrouping 0034 * \li SeverityGrouping 0035 * 0036 * Severity filter can be set and queried using the following methods 0037 * \li setSeverity() 0038 * \li severity() 0039 * 0040 * Valid severity setting: 0041 * \li IProblem::Error 0042 * \li IProblem::Warning 0043 * \li IProblem::Hint 0044 * 0045 * When changing the grouping or filtering method the following signals are emitted in order: 0046 * \li beginRebuild() 0047 * \li endRebuild() 0048 * \li changed() 0049 * 0050 * Usage example: 0051 * @code 0052 * IProblem::Ptr problem(new DetectedProblem); 0053 * problem->setSeverity(IProblem::Error); 0054 * ... 0055 * FilteredProblemStore *store = new FilteredProblemStore(); 0056 * store->setGrouping(SeverityGrouping); 0057 * store->addProblem(problem); 0058 * ProblemStoreNode *label = store->findNode(0); // Label node with the label "Error" 0059 * ProblemNode *problemNode = dynamic_cast<ProblemNode*>(label->child(0)); // the node with the problem 0060 * problemNode->problem(); // The problem we added 0061 * @endcode 0062 * 0063 */ 0064 class KDEVPLATFORMSHELL_EXPORT FilteredProblemStore : public ProblemStore 0065 { 0066 Q_OBJECT 0067 public: 0068 explicit FilteredProblemStore(QObject *parent = nullptr); 0069 ~FilteredProblemStore() override; 0070 0071 /// Adds a problem, which is then filtered and also added to the filtered problem list if it matches the filters 0072 void addProblem(const IProblem::Ptr &problem) override; 0073 0074 /// Retrieves the specified node 0075 const ProblemStoreNode* findNode(int row, ProblemStoreNode *parent = nullptr) const override; 0076 0077 /// Retrieves the number of filtered problems 0078 int count(ProblemStoreNode *parent = nullptr) const override; 0079 0080 /// Clears the problems 0081 void clear() override; 0082 0083 /// Rebuilds the filtered problem list 0084 void rebuild() override; 0085 0086 /// Set the grouping method. See the GroupingMethod enum. 0087 void setGrouping(int grouping) override; 0088 0089 /// Tells which grouping strategy is currently in use 0090 int grouping() const; 0091 0092 private: 0093 friend class FilteredProblemStorePrivate; 0094 const QScopedPointer<class FilteredProblemStorePrivate> d_ptr; 0095 Q_DECLARE_PRIVATE(FilteredProblemStore) 0096 }; 0097 0098 } 0099 0100 #endif