HAL
grouping_manager_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 
30 #include "hal_core/defines.h"
32 
33 #include <QColor>
35 #include <QListWidget>
36 #include <QMap>
37 #include <QMenu>
38 #include <QPoint>
39 #include <QPushButton>
40 #include <QTableView>
41 
42 namespace hal
43 {
44  class GraphTabWidget;
45  class Grouping;
46  class GroupingProxyModel;
47  class Searchbar;
48  class GraphicsItem;
49 
59  {
60  Q_OBJECT
77 
80 
81  public:
88 
94  virtual void setupToolbar(Toolbar* toolbar) override;
95 
101  virtual QList<QShortcut*> createShortcuts() override;
102 
108  QString toolboxIconPath() const;
109  QString toolboxIconStyle() const;
112  QString deleteIconPath() const;
113  QString deleteIconStyle() const;
118  QString disabledIconStyle() const;
119  QString searchIconPath() const;
120  QString searchIconStyle() const;
122 
123  QString tableIconPath() const;
124  QString tableIconStyle() const;
126 
130  void setDisabledIconStyle(const QString& style);
131  void setNewGroupingIconPath(const QString& path);
133  void setToolboxIconPath(const QString& path);
134  void setToolboxIconStyle(const QString& style);
135  void setRenameGroupingIconPath(const QString& path);
137  void setDeleteIconPath(const QString& path);
138  void setDeleteIconStyle(const QString& style);
139  void setColorSelectIconPath(const QString& path);
141  void setToSelectionIconPath(const QString& path);
143  void setSearchIconPath(const QString& path);
144  void setSearchIconStyle(const QString& style);
146 
147  void setTableIconPath(const QString& path);
148  void setTableIconStyle(const QString& style);
150 
157  {
158  return mGroupingTableModel;
159  }
160 
167  {
168  return mProxyModel;
169  }
170 
174  void setToolbarButtonsEnabled(bool enable);
175 
179  void enableSearchbar(bool enable);
180 
188  void newGroupingSuccOrPred(int maxDepth, bool succ, const GraphicsItem* item);
189 
197  void newGroupingByDistance(int maxDepth, bool succ, const GraphicsItem* item);
198 
206  void assignElementsToGroupingDialog(const QSet<u32>& modules = QSet<u32>(), const QSet<u32>& gates = QSet<u32>(), const QSet<u32>& nets = QSet<u32>());
207 
215  void removeElementsFromGrouping(const QSet<u32>& modules = QSet<u32>(), const QSet<u32>& gates = QSet<u32>(), const QSet<u32>& nets = QSet<u32>());
216 
217  public Q_SLOTS:
221  void handleLastEntryDeleted();
222 
228  void handleNewEntryAdded(const QModelIndex& modelIndex);
229 
236  void handleCurrentChanged(const QModelIndex& current = QModelIndex(), const QModelIndex& previous = QModelIndex());
237 
243 
248  void handleToolboxSuccessor();
249 
255 
261 
262  private Q_SLOTS:
266  void toggleSearchbar();
267 
273  void filter(const QString& text);
274 
278  void updateSearchIcon();
279 
283  void handleCreateGroupingClicked();
284 
288  void handleRenameGroupingClicked();
289 
293  void handleShowContentClicked();
294 
298  void handleColorSelectClicked();
299 
304  void handleToSelectionClicked();
305 
309  void handleDeleteGroupingClicked();
310 
316  void handleContextMenuRequest(const QPoint& point);
317 
321  void handleToolboxClicked();
322 
329  void handleDoubleClicked(const QModelIndex& index);
330 
338  void handleDeleteShortcutOnFocusChanged(QWidget *oldWidget, QWidget *newWidget);
339 
340  private:
341  class ToolboxModuleHash
342  {
343  public:
344  QHash<Gate*, Module*> mHash;
345  ToolboxModuleHash(const Node& nd);
346  };
347 
348  class ToolboxNode
349  {
350  public:
351  QString mName;
352  Node mNode;
353  ToolboxNode(Endpoint* ep = nullptr, const ToolboxModuleHash* tmh = nullptr);
354  ToolboxNode(const GraphicsItem* item);
355  std::vector<Net*> inputNets() const;
356  std::vector<Net*> outputNets() const;
357  };
358 
359  QIcon toolboxIcon() const;
360  //GraphTabWidget* mTabView;
361  QTableView* mGroupingTableView;
362  GroupingTableModel* mGroupingTableModel;
363  GroupingProxyModel* mProxyModel;
364  Searchbar* mSearchbar;
365 
366  QAction* mNewGroupingAction;
367  QString mNewGroupingIconPath;
368  QString mNewGroupingIconStyle;
369 
370  QString mToolboxIconPath;
371  QString mToolboxIconStyle;
372 
373  QAction* mRenameAction;
374  QString mRenameGroupingIconPath;
375  QString mRenameGroupingIconStyle;
376 
377  QAction* mColorSelectAction;
378  QString mColorSelectIconPath;
379  QString mColorSelectIconStyle;
380 
381  QAction* mDeleteAction;
382  QString mDeleteIconPath;
383  QString mDeleteIconStyle;
384 
385  QAction* mToSelectionAction;
386  QString mToSelectionIconPath;
387  QString mToSelectionIconStyle;
388 
389  QString mSearchIconPath;
390  QString mSearchIconStyle;
391  QString mSearchActiveIconStyle;
392 
393  QAction* mTableAction;
394  QString mTableIconPath;
395  QString mTableIconStyle;
396 
397  QString mDisabledIconStyle;
398  GroupingColorSerializer mColorSerializer;
399 
400  QShortcut* mShortCutDeleteItem;
401 
402  GroupingTableEntry getCurrentGrouping();
403  };
404 } // namespace hal
Abstract class for Widgets within HAL's ContentArea.
A ContentWidget that holds all GraphWidget objects (GraphView) as tabs of a QTabWidget.
Superclass for all graphic items used ins the GraphicsScene. It contains information about the underl...
Definition: graphics_item.h:44
User interface for Groupings.
GroupingManagerWidget(QWidget *parent=nullptr)
virtual void setupToolbar(Toolbar *toolbar) override
void setColorSelectIconStyle(const QString &style)
void setTableIconPath(const QString &path)
void setToolboxIconPath(const QString &path)
void setToSelectionIconStyle(const QString &style)
GroupingTableModel * getModel() const
virtual QList< QShortcut * > createShortcuts() override
void newGroupingSuccOrPred(int maxDepth, bool succ, const GraphicsItem *item)
void setRenameGroupingIconStyle(const QString &style)
void setColorSelectIconPath(const QString &path)
void setNewGroupingIconStyle(const QString &style)
void setDeleteIconStyle(const QString &style)
void setSearchIconPath(const QString &path)
void handleCurrentChanged(const QModelIndex &current=QModelIndex(), const QModelIndex &previous=QModelIndex())
GroupingProxyModel * getProxyModel() const
void handleNewEntryAdded(const QModelIndex &modelIndex)
void newGroupingByDistance(int maxDepth, bool succ, const GraphicsItem *item)
void setNewGroupingIconPath(const QString &path)
void assignElementsToGroupingDialog(const QSet< u32 > &modules=QSet< u32 >(), const QSet< u32 > &gates=QSet< u32 >(), const QSet< u32 > &nets=QSet< u32 >())
void setToolboxIconStyle(const QString &style)
void setSearchIconStyle(const QString &style)
void setDeleteIconPath(const QString &path)
void removeElementsFromGrouping(const QSet< u32 > &modules=QSet< u32 >(), const QSet< u32 > &gates=QSet< u32 >(), const QSet< u32 > &nets=QSet< u32 >())
void setSearchActiveIconStyle(const QString &style)
void setTableIconStyle(const QString &style)
void setDisabledIconStyle(const QString &style)
void setToSelectionIconPath(const QString &path)
void setRenameGroupingIconPath(const QString &path)
Helper model to make filtering available.
Table that holds information about all groupings.
The Node class object represents a module or a gate.
Definition: gui_def.h:61
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
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
QStyle * style() const const