File indexing completed on 2024-05-19 05:44:26

0001 /*
0002     SPDX-FileCopyrightText: 2021 Milian Wolff <milian.wolff@kdab.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef SUPPRESSIONSMODEL_H
0008 #define SUPPRESSIONSMODEL_H
0009 
0010 #include <QAbstractTableModel>
0011 #include <QVector>
0012 
0013 struct Suppression;
0014 struct SummaryData;
0015 
0016 class SuppressionsModel : public QAbstractTableModel
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit SuppressionsModel(QObject* parent = nullptr);
0021     ~SuppressionsModel();
0022 
0023     void setSuppressions(const SummaryData& summaryData);
0024 
0025     enum class Columns
0026     {
0027         Matches,
0028         Leaked,
0029         Pattern,
0030         COLUMN_COUNT,
0031     };
0032     int columnCount(const QModelIndex& parent = {}) const override;
0033     int rowCount(const QModelIndex& parent = {}) const override;
0034 
0035     enum Roles
0036     {
0037         SortRole = Qt::UserRole,
0038         TotalCostRole,
0039     };
0040 
0041     QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal,
0042                         int role = Qt::DisplayRole) const override;
0043     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
0044 
0045 private:
0046     QVector<Suppression> m_suppressions;
0047     qint64 m_totalAllocations = 0;
0048     qint64 m_totalLeaked = 0;
0049 };
0050 
0051 #endif // SUPPRESSIONSMODEL_H