HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
logic_evaluator_select_gates.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 <QDialog>
29  #include <QTreeView>
30  #include <vector>
32 
33  class QDialogButtonBox;
34  class QCheckBox;
35 
36  namespace hal {
37  class Gate;
38 
39  class ModuleProxyModel;
40 
41  class Searchbar;
42 
46  class SelectGateItem : public ModuleItem
47  {
48  Qt::CheckState mState;
49  bool mSelectable;
50  public:
52  : ModuleItem(id, type, model), mState(Qt::Unchecked), mSelectable(isSel) {;}
53  Qt::CheckState state() const { return mState; }
54  bool isSelectable() const { return mSelectable; }
55  void setSelectable(bool isSel) { mSelectable = isSel; }
56  void setState(Qt::CheckState stat) { mState = stat; }
57  };
58 
59  class LogicEvaluatorSelectGates;
60 
65  {
66  Q_OBJECT
67  std::vector<Gate*> mSelectedGates;
68  LogicEvaluatorSelectGates* mParentDialog;
69 
70  int insertModuleRecursion(const Module* mod, SelectGateItem* parentItem = nullptr);
71  QPair<bool,bool> setCheckedRecursion(bool applySet, BaseTreeItem* parentItem, const QSet<u32>& selectedGateIds = QSet<u32>() );
72  void setModuleStateRecursion(SelectGateItem* item, Qt::CheckState stat);
73  void setSelectedGatesRecursion(SelectGateItem* item = nullptr);
74  Q_SIGNALS:
75  void selectionStateChanged(bool empty);
76  public:
77  SelectGateModel(QObject* parent = nullptr);
78  void setChecked(const std::vector<Gate *> &gates);
79  Qt::ItemFlags flags(const QModelIndex &index) const override;
80  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
81  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
82  const std::vector<Gate*>& selectedGates() const {return mSelectedGates; }
83  };
84 
89  {
90  Q_OBJECT
91 
94 
95  QTreeView* mTreeView;
96  SelectGateModel* mSelectGateModel;
97  ModuleProxyModel* mProxyModel;
98  Searchbar* mSearchbar;
99  QCheckBox* mCompile;
100  QDialogButtonBox* mButtonBox;
101  QColor mSelBackground;
102  QColor mSelForeground;
103  public Q_SLOTS:
104  void accept() override;
105  private Q_SLOTS:
106  void handleSelectionStateChanged(bool empty);
107  public:
108  LogicEvaluatorSelectGates(const std::vector<Gate *> &gates, QWidget* parent = nullptr);
109 
110  QColor selBackground() const { return mSelBackground; }
111  void setSelBackground(QColor bg) { mSelBackground = bg; }
112  QColor selForeground() const { return mSelForeground; }
113  void setSelForeground(QColor fg) { mSelForeground = fg; }
114  };
115  }
(Future) Base class for all tree models related to the details widget.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
LogicEvaluatorSelectGates(const std::vector< Gate * > &gates, QWidget *parent=nullptr)
An item in the ModuleModel.
Definition: module_item.h:48
u32 id() const
A model for displaying multiple netlist elements.
Definition: module_model.h:54
Enables filtering in the ModuleModel.
A QFrame with a QLineEdit that can be used to input a substring to search for.
Definition: searchbar.h:48
Qt::CheckState state() const
SelectGateItem(u32 id, ModuleItem::TreeItemType type, ModuleModel *model, bool isSel=true)
void setState(Qt::CheckState stat)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
const std::vector< Gate * > & selectedGates() const
void selectionStateChanged(bool empty)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setChecked(const std::vector< Gate * > &gates)
SelectGateModel(QObject *parent=nullptr)
Qt::ItemFlags flags(const QModelIndex &index) const override
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
PinType type
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
CheckState
DisplayRole
typedef ItemFlags