HAL  v4.5.0-283-g3f42a39fa
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
module_widget.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 "hal_core/defines.h"
36 
37 
38 #include <QAction>
39 #include <QItemSelection>
40 #include <QList>
41 #include <QObject>
42 #include <QSortFilterProxyModel>
43 
44 class QTreeView;
45 
46 namespace hal
47 {
48  class ModuleModel;
49  class ModuleProxyModel;
50 
58  class ModuleWidget : public ContentWidget
59  {
60  Q_OBJECT
74 
75  public:
81  ModuleWidget(QWidget* parent = nullptr);
82 
88  virtual void setupToolbar(Toolbar* toolbar) override;
89 
95  virtual QList<QShortcut*> createShortcuts() override;
96 
102  ModuleModel* getModuleModel() const;
103 
110 
114  QString disabledIconStyle() const;
115  QString activeIconStyle() const;
116  QString showNetsIconPath() const;
117  QString hideNetsIconPath() const;
118  QString showGatesIconPath() const;
119  QString hideGatesIconPath() const;
120  QString searchIconPath() const;
121  QString searchIconStyle() const;
123  QString deleteIconPath() const;
124  QString renameIconPath() const;
125  QString expandedIconPath() const;
126  QString collapsedIconPath() const;
127 
129 
133  void setDisabledIconStyle(const QString& style);
134  void setActiveIconStyle(const QString& style);
135  void setShowNetsIconPath(const QString &path);
136  void setHideNetsIconPath(const QString &path);
137  void setShowGatesIconPath(const QString &path);
138  void setHideGatesIconPath(const QString &path);
139  void setSearchIconPath(const QString &path);
140  void setSearchIconStyle(const QString &style);
142  void setDeleteIconPath(const QString& path);
143  void setRenameIconPath(const QString& path);
144  void setExpandedIconPath(const QString& path);
145  void setCollapsedIconPath(const QString& path);
147 
148  public Q_SLOTS:
152  void toggleSearchbar();
153 
159  void filter(const QString& text);
160 
164  void updateSearchIcon();
165 
171  void handleTreeViewContextMenuRequested(const QPoint& point);
172 
180  void handleTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
181 
188  void handleCurrentChanged(const QModelIndex& current, const QModelIndex& previous = QModelIndex());
189 
196 
202  void handleSelectionChanged(void* sender);
203 
204  private Q_SLOTS:
208  void handleToggleNetsClicked();
209 
213  void handleToggleGatesClicked();
214 
218  void handleToggleExpandTreeClicked();
219 
223  void handleRenameClicked();
224 
225  private Q_SLOTS:
226  void handleDeleteShortcutOnFocusChanged(QWidget *oldWidget, QWidget *newWidget);
227 
228  void deleteSelectedItem();
229 
230  private:
231  ModuleTreeView* mTreeView;
232  Searchbar* mSearchbar;
233 
234  QAction* mToggleNetsAction;
235  QAction* mToggleGatesAction;
236  QAction* mRenameAction;
237  QAction* mDeleteAction;
238  QAction* mToggleExpandTreeAction;
239 
240  QString mDisabledIconStyle;
241  QString mActiveIconStyle;
242 
243  QString mShowNetsIconPath;
244  QString mHideNetsIconPath;
245  QString mShowGatesIconPath;
246  QString mHideGatesIconPath;
247  QString mDeleteIconPath;
248 
249  QString mSearchIconPath;
250  QString mSearchIconStyle;
251  QString mSearchActiveIconStyle;
252  QString mRenameIconPath;
253  QString mExpandedIconPath;
254  QString mCollapsedIconPath;
255 
256  QAction* mFilterAction;
257 
258  bool mIgnoreSelectionChange;
259 
260  ModuleModel* mModuleModel;
261  ModuleProxyModel* mModuleProxyModel;
262 
263  QShortcut* mShortCutDeleteItem;
264 
265  void enableDeleteAction(bool enable);
266 
267  ModuleItem* getModuleItemFromIndex(const QModelIndex& index);
268 
269  };
270 } // namespace hal
Abstract class for Widgets within HAL's ContentArea.
An item in the ModuleModel.
Definition: module_item.h:48
A model for displaying multiple netlist elements.
Definition: module_model.h:54
Enables filtering in the ModuleModel.
Wraps the QTreeView used for the ModuleWidget.
Shows the modules of the netlist hierarchical in a tree view.
Definition: module_widget.h:59
void handleTreeSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void setSearchIconPath(const QString &path)
void setSearchIconStyle(const QString &style)
QString activeIconStyle() const
void setExpandedIconPath(const QString &path)
void setHideGatesIconPath(const QString &path)
QString renameIconPath() const
void setDisabledIconStyle(const QString &style)
QString searchIconPath() const
void filter(const QString &text)
QString expandedIconPath() const
void handleSelectionChanged(void *sender)
QString disabledIconStyle() const
void setShowNetsIconPath(const QString &path)
QString hideNetsIconPath() const
void handleTreeViewContextMenuRequested(const QPoint &point)
void setDeleteIconPath(const QString &path)
QString showNetsIconPath() const
virtual QList< QShortcut * > createShortcuts() override
QString searchIconStyle() const
ModuleProxyModel * proxyModel()
void setShowGatesIconPath(const QString &path)
void setCollapsedIconPath(const QString &path)
void handleItemDoubleClicked(const QModelIndex &index)
void handleCurrentChanged(const QModelIndex &current, const QModelIndex &previous=QModelIndex())
ModuleWidget(QWidget *parent=nullptr)
void setRenameIconPath(const QString &path)
void setSearchActiveIconStyle(const QString &style)
QString showGatesIconPath() const
void setHideNetsIconPath(const QString &path)
QString deleteIconPath() const
QString collapsedIconPath() const
void setActiveIconStyle(const QString &style)
QString hideGatesIconPath() const
ModuleModel * getModuleModel() const
QString searchActiveIconStyle() const
virtual void setupToolbar(Toolbar *toolbar) override
A QFrame with a QLineEdit that can be used to input a substring to search for.
Definition: searchbar.h:48
Toolbar for all ContentFrames and ContentWidgets.
Definition: toolbar.h:39
Definition: defines.h:45
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
QObject * sender() const const
QStyle * style() const const