HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
wave_tree_view.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include <QTreeView>
29 #include <QHash>
30 #include <QResizeEvent>
31 #include <QStyledItemDelegate>
32 #include "hal_core/defines.h"
34 
35 namespace hal {
36  class WaveDataList;
37 
42  {
43  Q_OBJECT
44  public:
46 
47  void paint(QPainter *painter, const QStyleOptionViewItem &option,
48  const QModelIndex &index) const override;
49  };
50 
54  class WaveTreeView : public QTreeView
55  {
56  Q_OBJECT
57  QList<QModelIndex> mItemOrder;
58  QSet<u32> mExpandedGroups;
59  QModelIndexList mContextIndexList;
60  WaveDataList* mWaveDataList;
61  WaveItemHash* mWaveItemHash;
62 
63  QModelIndexList sortedSelection() const;
64  void editWaveData(WaveData* wd);
65 
66  protected:
67  void mouseDoubleClickEvent(QMouseEvent *event) override;
68  void startDrag(Qt::DropActions supportedActions) override;
69  void scrollContentsBy(int dx, int dy) override;
70  bool viewportEvent(QEvent *event) override;
71  void resizeEvent(QResizeEvent *event) override;
72  void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
73  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
74 
75  Q_SIGNALS:
77  void sizeChanged(int viewportHeight, int scrollbarMax, int scrollbarPos);
78 // void numberVisibleChanged(int nVisible, int scrollbarMax, int scrollbarPos); // unused
80 
81  private Q_SLOTS:
82  void handleExpand(const QModelIndex& index);
83  void handleCollapse(const QModelIndex& index);
84  void handleContextMenuRequested(const QPoint& pos);
85  void handleRemoveItem();
86  void handleRenameItem();
87  void handleEditOrBrowseItem();
88  void handleRemoveGroup();
89  void handleInsertGroup();
90  void handleInsertBoolean();
91  void handleInsertTrigger();
92  void handleSetValueFormat();
93  void handleRemoveMulti();
94 
95  public Q_SLOTS:
96  void handleInserted(const QModelIndex& index);
97  void reorder();
98  void setWaveSelection(const QSet<u32>& netIds);
99 
100  public:
101  WaveTreeView(WaveDataList* wdList, WaveItemHash* wHash, QWidget* parent = nullptr);
102 
103  private:
104  void orderRecursion(const QModelIndex& parent);
105  };
106 }
void viewportHeightChanged(int height)
void mouseDoubleClickEvent(QMouseEvent *event) override
void handleInserted(const QModelIndex &index)
void sizeChanged(int viewportHeight, int scrollbarMax, int scrollbarPos)
WaveTreeView(WaveDataList *wdList, WaveItemHash *wHash, QWidget *parent=nullptr)
bool viewportEvent(QEvent *event) override
void scrollContentsBy(int dx, int dy) override
void setWaveSelection(const QSet< u32 > &netIds)
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
void resizeEvent(QResizeEvent *event) override
void triggerUpdateWaveItems()
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
void startDrag(Qt::DropActions supportedActions) override
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: defines.h:45
virtual bool event(QEvent *event) override
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
QStyledItemDelegate(QObject *parent)
typedef DropActions