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

0001 /*
0002     SPDX-FileCopyrightText: 2015-2017 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef FLAMEGRAPH_H
0008 #define FLAMEGRAPH_H
0009 
0010 #include <QVector>
0011 #include <QWidget>
0012 
0013 #include "treemodel.h"
0014 
0015 class QGraphicsScene;
0016 class QGraphicsView;
0017 class QComboBox;
0018 class QLabel;
0019 class QLineEdit;
0020 class QPushButton;
0021 
0022 class FrameGraphicsItem;
0023 
0024 class FlameGraph : public QWidget
0025 {
0026     Q_OBJECT
0027 public:
0028     FlameGraph(QWidget* parent = nullptr);
0029     ~FlameGraph();
0030 
0031     void setTopDownData(const TreeData& topDownData);
0032     void setBottomUpData(const TreeData& bottomUpData);
0033 
0034     void clearData();
0035 
0036 protected:
0037     bool eventFilter(QObject* object, QEvent* event) override;
0038 
0039 private slots:
0040     void setData(FrameGraphicsItem* rootItem);
0041     void setSearchValue(const QString& value);
0042     void navigateBack();
0043     void navigateForward();
0044 
0045 signals:
0046     void callerCalleeViewRequested(const Symbol& symbol);
0047 
0048 private:
0049     void setTooltipItem(const FrameGraphicsItem* item);
0050     void updateTooltip();
0051     void showData();
0052     void selectItem(int item);
0053     void selectItem(FrameGraphicsItem* item);
0054     void updateNavigationActions();
0055 
0056     TreeData m_topDownData;
0057     TreeData m_bottomUpData;
0058 
0059     QComboBox* m_costSource;
0060     QGraphicsScene* m_scene;
0061     QGraphicsView* m_view;
0062     QLabel* m_displayLabel;
0063     QLabel* m_searchResultsLabel;
0064     QLineEdit* m_searchInput = nullptr;
0065     QAction* m_forwardAction = nullptr;
0066     QAction* m_backAction = nullptr;
0067     QAction* m_resetAction = nullptr;
0068     QPushButton* m_backButton = nullptr;
0069     QPushButton* m_forwardButton = nullptr;
0070     const FrameGraphicsItem* m_tooltipItem = nullptr;
0071     FrameGraphicsItem* m_rootItem = nullptr;
0072     QVector<FrameGraphicsItem*> m_selectionHistory;
0073     int m_selectedItem = -1;
0074     bool m_showBottomUpData = false;
0075     bool m_collapseRecursion = true;
0076     bool m_buildingScene = false;
0077     // cost threshold in percent, items below that value will not be shown
0078     double m_costThreshold = 0.1;
0079 };
0080 
0081 #endif // FLAMEGRAPH_H