File indexing completed on 2024-04-14 04:31:19

0001 /* This file is part of KDevelop
0002  * Copyright 2011 Mathieu Lornac <mathieu.lornac@gmail.com>
0003  * Copyright 2011 Damien Coppel <damien.coppel@gmail.com>
0004  * Copyright 2011 Lionel Duc <lionel.data@gmail.com>
0005  * Copyright 2011 Lucas Sarie <lucas.sarie@gmail.com>
0006  * Copyright 2017 Anton Anikin <anton@anikin.xyz>
0007 
0008    This program is free software; you can redistribute it and/or
0009    modify it under the terms of the GNU General Public
0010    License as published by the Free Software Foundation; either
0011    version 2 of the License, or (at your option) any later version.
0012 
0013    This program is distributed in the hope that it will be useful,
0014    but WITHOUT ANY WARRANTY; without even the implied warranty of
0015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016     General Public License for more details.
0017 
0018    You should have received a copy of the GNU General Public License
0019    along with this program; see the file COPYING.  If not, write to
0020    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021    Boston, MA 02110-1301, USA.
0022 */
0023 
0024 #pragma once
0025 
0026 #include <QAbstractTableModel>
0027 
0028 namespace Valgrind
0029 {
0030 
0031 struct CachegrindFunction
0032 {
0033     QString functionName;
0034     QStringList fileNames;
0035 
0036     QList<int> eventValues;
0037 };
0038 
0039 class CachegrindFunctionsModel : public QAbstractTableModel
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044     explicit CachegrindFunctionsModel(QObject* parent = nullptr);
0045     ~CachegrindFunctionsModel() override;
0046 
0047     void setEventsList(const QStringList& events);
0048     void addItem(CachegrindFunction* item, bool isTotal = false);
0049 
0050     void setPercentageValues(bool value);
0051 
0052     QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
0053 
0054     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
0055     int columnCount(const QModelIndex& parent = QModelIndex()) const override;
0056 
0057     QVariant data(const QModelIndex& index, int role) const override;
0058     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
0059 
0060 private:
0061     QList<CachegrindFunction*> m_items;
0062     CachegrindFunction* m_totalItem;
0063 
0064     bool m_percentageValues;
0065 
0066     QStringList m_eventList;
0067 };
0068 
0069 }