HAL
groupings_of_item_model.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 "gui/gui_def.h"
32 #include "hal_core/defines.h"
34 
35 #include <QAbstractTableModel>
36 #include <QColor>
37 #include <QList>
38 #include <QString>
39 
40 namespace hal
41 {
42 
56  {
57  Q_OBJECT
58 
59  public:
66 
73  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
74 
81  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
82 
90  QVariant data(const QModelIndex& index, int role) const override;
91 
100  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
101 
110  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
111 
119  {
120  return mGroupings.at(row);
121  }
122 
128  void setGate(Gate* gate);
129 
135  void setModule(Module* module);
136 
142  void setNet(Net* net);
143 
148  void setGroupings(QList<Grouping*> groupingList);
149 
158  bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
159 
160  private Q_SLOTS:
161  // Slots to handle grouping or item changes that affect the grouping list or its data
162 
163  void handleGroupingRemoved(Grouping* grp);
164 
165  void handleGroupingNameChanged(Grouping* grp);
166 
167  void handleGroupingGateAssigned(Grouping* grp, u32 id);
168 
169  void handleGroupingGateRemoved(Grouping* grp, u32 id);
170 
171  void handleGroupingNetAssigned(Grouping* grp, u32 id);
172 
173  void handleGroupingNetRemoved(Grouping* grp, u32 id);
174 
175  void handleGroupingModuleAssigned(Grouping* grp, u32 id);
176 
177  void handleGroupingModuleRemoved(Grouping* grp, u32 id);
178 
179  void handleGroupingColorChanged(Grouping* grp);
180 
181  private:
187  int getIndexOfGrouping(Grouping* grp) const;
188 
190  QList<GroupingTableEntry> mGroupings;
191 
193  ItemType mItemType;
194 
196  u32 mItemId;
197  };
198 } // namespace hal
Definition: gate.h:58
An entry within a GroupingTableModel.
A TableModel to store all Groupings that contain a specified Gate, Net or Module.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
GroupingTableEntry getGroupingEntryAtRow(int row) const
QVariant data(const QModelIndex &index, int role) const override
void setGroupings(QList< Grouping * > groupingList)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
GroupingsOfItemModel(QObject *parent=nullptr)
Definition: net.h:58
ItemType
The ItemType enum provides the enum type to classify graphic items into Modules, Gates or Nets....
Definition: gui_def.h:45
const Module * module(const Gate *g, const NodeBoxes &boxes)
quint32 u32
Net * net
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
EditRole
Orientation