File indexing completed on 2024-05-19 05:42:13
0001 // ct_lvtmdl_errorsmodel.h -*-C++-*- 0002 0003 /* 0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk> 0005 // SPDX-License-Identifier: Apache-2.0 0006 // 0007 // Licensed under the Apache License, Version 2.0 (the "License"); 0008 // you may not use this file except in compliance with the License. 0009 // You may obtain a copy of the License at 0010 // 0011 // http://www.apache.org/licenses/LICENSE-2.0 0012 // 0013 // Unless required by applicable law or agreed to in writing, software 0014 // distributed under the License is distributed on an "AS IS" BASIS, 0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 // See the License for the specific language governing permissions and 0017 // limitations under the License. 0018 */ 0019 0020 #ifndef DEFINED_CT_LVTMDL_ERRORSMODEL 0021 #define DEFINED_CT_LVTMDL_ERRORSMODEL 0022 0023 #include <lvtmdl_export.h> 0024 0025 #include <QAbstractTableModel> 0026 #include <QModelIndex> 0027 #include <QSortFilterProxyModel> 0028 0029 #include <memory> 0030 0031 namespace Codethink::lvtmdl { 0032 class LVTMDL_EXPORT ErrorsModel : public QAbstractTableModel { 0033 /* Model that holds the data from Parsing Errors from the code 0034 * extractor, and compiler errors. This is used to show the user 0035 * possible mistakes that happened during the process of code 0036 * examination, while building the relationship database. 0037 */ 0038 0039 Q_OBJECT 0040 public: 0041 ErrorsModel(); 0042 ~ErrorsModel() override; 0043 0044 void reset(); 0045 0046 [[nodiscard]] int rowCount(const QModelIndex& idx) const override; 0047 [[nodiscard]] int columnCount(const QModelIndex& idx) const override; 0048 [[nodiscard]] QVariant data(const QModelIndex& idx, int role) const override; 0049 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0050 0051 private: 0052 struct Private; 0053 std::unique_ptr<Private> d; 0054 }; 0055 0056 class LVTMDL_EXPORT ErrorModelFilter : public QSortFilterProxyModel { 0057 public: 0058 ErrorModelFilter(); 0059 ~ErrorModelFilter() override; 0060 0061 [[nodiscard]] bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; 0062 [[nodiscard]] bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override; 0063 0064 void setFilterCompilerMessages(bool filter); 0065 void setFilterParseMessages(bool filter); 0066 0067 void setIgnoreCategoriesModel(QAbstractItemModel *model); 0068 // Sets the model with the list of strings that will be used to filter 0069 // categories out 0070 0071 void setFilterString(const QString& str); 0072 // Use this string to match the messages that will be filtered on the view 0073 0074 void setInvertMessageFilter(bool value); 0075 // If true, return messages that don't match the string 0076 // if false, return messages that match the string. 0077 0078 private: 0079 struct Private; 0080 std::unique_ptr<Private> d; 0081 }; 0082 0083 } // namespace Codethink::lvtmdl 0084 #endif