HAL
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 
195  void handleItemDoubleClicked(const QModelIndex& index);
196 
202  void handleSelectionChanged(void* sender);
203 
210  void handleModuleRemoved(Module* module, u32 module_id);
211 
212  private Q_SLOTS:
216  void handleToggleNetsClicked();
217 
221  void handleToggleGatesClicked();
222 
226  void handleToggleExpandTreeClicked();
227 
231  void handleRenameClicked();
232 
233  private Q_SLOTS:
234  void handleDeleteShortcutOnFocusChanged(QWidget *oldWidget, QWidget *newWidget);
235 
236  void deleteSelectedItem();
237 
238  private:
239  ModuleTreeView* mTreeView;
240  Searchbar* mSearchbar;
241 
242  QAction* mToggleNetsAction;
243  QAction* mToggleGatesAction;
244  QAction* mRenameAction;
245  QAction* mDeleteAction;
246  QAction* mToggleExpandTreeAction;
247 
248  QString mDisabledIconStyle;
249  QString mActiveIconStyle;
250 
251  QString mShowNetsIconPath;
252  QString mHideNetsIconPath;
253  QString mShowGatesIconPath;
254  QString mHideGatesIconPath;
255  QString mDeleteIconPath;
256 
257  QString mSearchIconPath;
258  QString mSearchIconStyle;
259  QString mSearchActiveIconStyle;
260  QString mRenameIconPath;
261  QString mExpandedIconPath;
262  QString mCollapsedIconPath;
263 
264  QAction* mFilterAction;
265 
266  QList<QRegExp*> mRegexps;
267 
268  bool mIgnoreSelectionChange;
269 
270  ModuleModel* mModuleModel;
271  ModuleProxyModel* mModuleProxyModel;
272 
273  QShortcut* mShortCutDeleteItem;
274 
275  void enableDeleteAction(bool enable);
276 
277  ModuleItem* getModuleItemFromIndex(const QModelIndex& index);
278 
279  };
280 } // 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)
QString renameIconPath
Definition: module_widget.h:70
QString searchIconStyle
Definition: module_widget.h:68
void setSearchIconStyle(const QString &style)
QString hideNetsIconPath
Definition: module_widget.h:64
void setExpandedIconPath(const QString &path)
void setHideGatesIconPath(const QString &path)
QString activeIconStyle
Definition: module_widget.h:62
void setDisabledIconStyle(const QString &style)
QString showGatesIconPath
Definition: module_widget.h:65
void filter(const QString &text)
QString disabledIconStyle
Definition: module_widget.h:61
void handleSelectionChanged(void *sender)
QString collapsedIconPath
Definition: module_widget.h:73
void setShowNetsIconPath(const QString &path)
void handleTreeViewContextMenuRequested(const QPoint &point)
void setDeleteIconPath(const QString &path)
virtual QList< QShortcut * > createShortcuts() override
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)
QString deleteIconPath
Definition: module_widget.h:71
void setSearchActiveIconStyle(const QString &style)
void handleModuleRemoved(Module *module, u32 module_id)
void setHideNetsIconPath(const QString &path)
QString expandedIconPath
Definition: module_widget.h:72
QString showNetsIconPath
Definition: module_widget.h:63
QString searchActiveIconStyle
Definition: module_widget.h:69
void setActiveIconStyle(const QString &style)
ModuleModel * getModuleModel() const
QString searchIconPath
Definition: module_widget.h:67
QString hideGatesIconPath
Definition: module_widget.h:66
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
const Module * module(const Gate *g, const NodeBoxes &boxes)
quint32 u32
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
QObject * sender() const const
QStyle * style() const const