HAL
port_tree_model.cpp
Go to the documentation of this file.
2 
4 #include "gui/gui_globals.h"
11 #include "hal_core/netlist/gate.h"
14 #include "hal_core/netlist/net.h"
16 
17 #include <QDebug>
18 #include <QMimeData>
19 
20 namespace hal
21 {
22  PortTreeItem::PortTreeItem(Type itype, u32 id_, QString pinName, PinDirection dir, PinType ptype, QString netName)
23  : mItemType(itype), mId(id_), mPinName(pinName), mPinDirection(dir), mPinType(ptype), mNetName(netName)
24  {;}
25 
27  {
28  switch (index)
29  {
30  case 0:
31  return mPinName;
32  case 1:
33  return QString::fromStdString(enum_to_string(mPinDirection));
34  case 2:
35  return QString::fromStdString(enum_to_string(mPinType));
36  case 3:
37  return mNetName;
38  }
39  return QVariant();
40  }
41 
43  {
44  mPinName = data[0].toString();
45  mPinDirection = enum_from_string<PinDirection>(data[1].toString().toStdString());
46  mPinType = enum_from_string<PinType>(data[2].toString().toStdString());
47  mNetName = data[3].toString();
48  }
49 
50  void PortTreeItem::setDataAtIndex(int index, QVariant &data)
51  {
52  switch (index)
53  {
54  case 0: {
55  mPinName = data.toString();
56  break;}
57  case 1: {
58  mPinDirection = enum_from_string<PinDirection>(data.toString().toStdString());
59  break;}
60  case 2: {
61  mPinType = enum_from_string<PinType>(data.toString().toStdString());
62  break;}
63  case 3: {
64  mNetName = data.toString();
65  break;}
66  }
67  }
68 
70  {
71  Q_UNUSED(data)
72  }
73 
75  {
76  return 4;
77  }
78 
80  {
81  setHeaderLabels(QStringList() << "Name"
82  << "Direction"
83  << "Type"
84  << "Connected Net");
86 
87  //connections
89  }
90 
92  {
93  delete mRootItem;
94  }
95 
97  {
98 // Qt::ItemFlags defaultFlags = BaseTreeModel::flags(index);
99 // TreeItem* item = index.isValid() ? getItemFromIndex(index) : nullptr;
100 // if (item)
101 // {
102 // //get parent, must be a pingroup item and not the root (not allowed to drag from external group, but maybe later)
103 // TreeItem* parentItem = item->getParent();
104 // itemType type = getTypeOfItem(item);
105 // if (type == itemType::portMultiBit)
106 // return defaultFlags | Qt::ItemIsDropEnabled;
107 // else if (type == itemType::pin) // && parentItem != mRootItem)//only case that should be possible
108 // return defaultFlags | Qt::ItemIsDragEnabled; // | Qt::ItemIsDropEnabled;
109 // if (parentItem == mRootItem && type == itemType::pin)
110 // return defaultFlags;
111 // }
112  // valid-check must be ommitted when a drop between pingroups is desired, all checks are performed in canDropMimeData
114 // if(item)
115 // {
116 // // everything can be dragged, but wether it can be dropped on or not depends on the situation
117 // // -> a pin cannot be dropped onto its parent-group (but it can be dropped within its group),
118 // // and a pingroup cannot be dropped onto (or between) a pin. -> what is currently dragged can only
119 // // be checked in the "canDropMimeData" function, ItemIsDropEnabled cannot be set since its conditional on the dragged item
120 // return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
121 
122 // }
123 // return defaultFlags;
124  }
125 
127  {
128  QStringList types;
129  types << "pintreemodel/item";
130  return types;
131  }
132 
133  QMimeData* ModulePinsTreeModel::mimeData(const QModelIndexList& indexes) const
134  {
135  if (indexes.size() != 4) //columncount, only 1 item is allowed
136  return new QMimeData();
137 
138  QMimeData* data = new QMimeData();
139  PortTreeItem* item = static_cast<PortTreeItem*>(getItemFromIndex(indexes.at(0)));
140  QByteArray encodedData;
141  QDataStream stream(&encodedData, QIODevice::WriteOnly);
142  QString type = item->itemType() == PortTreeItem::Pin ? "pin" : "group";
143  stream << type << item->id();
144  data->setText(item->itemType() == PortTreeItem::Pin
145  ? PyCodeProvider::pyCodeModulePinById(mModule->get_id(),item->id())
146  : PyCodeProvider::pyCodeModulePinGroup(mModule->get_id(),item->id()));
147  data->setData("pintreemodel/item", encodedData);
148  return data;
149  }
150 
151  bool ModulePinsTreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent)
152  {
153  Q_UNUSED(action)
154  Q_UNUSED(column)
155 
156  QString type;
157  int id;
158  QByteArray encItem = data->data("pintreemodel/item");
159  QDataStream dataStream(&encItem, QIODevice::ReadOnly);
160 // debug pingroup qDebug() << "dropMimeData" << encItem << row << column;
161  dataStream >> type >> id;
162 
163  auto droppedItem = (type == "group") ? static_cast<PortTreeItem*>(mIdToGroupItem.value(id)) : static_cast<PortTreeItem*>(mIdToPinItem.value(id));
164  //auto droppedParentItem = droppedItem->getParent();
165  auto parentItem = getItemFromIndex(parent);
166 
167  // perhaps helper functions?
168  // 1. group on group (between group)
169  // 2. pin on group
170  // 3. pin between groups
171  // 4. pin between pins
172 
173  // put ignore flags here? perhaps needed specifically in other places in functions..
174 
175  if(type == "group")
176  {
177  if(!parentItem)
178  {
179 // debug pingroup qDebug() << "group was dropped between groups... with row: " << row; //check in canDropMine if its not an adjacent row?
180  dndGroupBetweenGroup(droppedItem, row);
181  }
182  else
183  {
184 // debug pingroup qDebug() << "group was dropped on a group?";
185  dndGroupOnGroup(droppedItem, parentItem);
186  }
187  }
188  else
189  {
190  if(!parentItem)
191  {
192 // debug pingroup qDebug() << "pin was dropped between groups on row " << row;
193  dndPinBetweenGroup(droppedItem, row);
194  }
195  else if(row != -1)
196  {
197 // debug pingroup qDebug() << "pin was dropped between pins";
198  dndPinBetweenPin(droppedItem, parentItem, row);
199  }
200  else
201  {
202 // debug pingroup qDebug() << "pin was dropped on a group...";
203  dndPinOnGroup(droppedItem, parentItem);
204  }
205  }
206 
207  return true;
208  }
209 
210 
211  bool ModulePinsTreeModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
212  {
213  Q_UNUSED(column)
214  Q_UNUSED(action)
215  if(!data->formats().contains("pintreemodel/item")) return false;
216 
217  QString type; int id;
218  auto encItem = data->data("pintreemodel/item");
219  QDataStream dataStream(&encItem, QIODevice::ReadOnly);
220  dataStream >> type >> id;
221  auto parentItem = static_cast<PortTreeItem*>(getItemFromIndex(parent));
222  // qDebug() << "type: " << type << ", id" << id << ", row: " << row;
223 
224  // construct a "drop-matrix" here, but only 4(5) things are NOT allowed (so check for these):
225  // 1: drop a pin on its OWN parent
226  // 3: drop a pingroup on/between pins
227  // 4: drop an item on itself
228  // 5: drop adjecent index to itself, must be at least 1 item apart
229  if(type == "group")
230  {
231  auto item = static_cast<PortTreeItem*>(mIdToGroupItem[id]);
232  if(parentItem)
233  {
234  if(item->itemType() == PortTreeItem::Pin || (item->itemType() == PortTreeItem::Group && row != -1) || item == parentItem)
235  return false;
236  }
237  else // here, only check for adjacent rows
238  {
239  auto itRow = item->getOwnRow();
240  if(itRow == row || ((itRow+1) == row))
241  return false;
242  }
243  }
244  if(type == "pin")
245  {
246  // perhaps check here that a pin can only be dropped between groups if its own group has size > 1?
247  // otherwise it does not make much sense...perhaps change this check
248  auto item = mIdToPinItem[id];
249  if((!parentItem && item->getParent()->getChildCount() == 1) || (item->getParent() == parentItem && row == -1) || item == parentItem
250  || (parentItem && (parentItem->itemType() == PortTreeItem::Pin)))
251  return false;
252  // case if one wants to drop between pins in same group, check if its not adjacent row (other cases are handled on case above
253  if(item->getParent() == parentItem)
254  {
255  auto itRow = item->getOwnRow();
256  if(itRow == row || ((itRow+1) == row))
257  return false;
258  }
259  }
260  return true;
261  }
262 
264  {
266  mModule = nullptr;
267  mNameToTreeItem.clear();
268  mIdToGroupItem.clear();
269  mIdToPinItem.clear();
270  }
271 
273  {
274  clear();
275  mModule = m;
276  beginResetModel();
277 
278  for(PinGroup<ModulePin>* pinGroup : m->get_pin_groups())
279  {
280  if(pinGroup->empty())
281  continue;
282 
283  auto pinGroupName = QString::fromStdString(pinGroup->get_name());
284  PortTreeItem* pinGroupItem = new PortTreeItem(PortTreeItem::Group, pinGroup->get_id(), pinGroupName, pinGroup->get_direction(), pinGroup->get_type());
285  mIdToGroupItem.insert(pinGroup->get_id(), pinGroupItem);
286  for(ModulePin* pin : pinGroup->get_pins())
287  {
289  pin->get_id(),
290  QString::fromStdString(pin->get_name()),
291  pin->get_direction(),
292  pin->get_type(),
293  QString::fromStdString(pin->get_net()->get_name()));
294  pinGroupItem->appendChild(pinItem);
295  mNameToTreeItem.insert(QString::fromStdString(pin->get_name()), pinItem);
296  mIdToPinItem.insert(pin->get_id(), pinItem);
297  }
298  mNameToTreeItem.insert(pinGroupName, pinGroupItem);
299  mRootItem->appendChild(pinGroupItem);
300  }
301 
302 // for (PinGroup<ModulePin>* pinGroup : m->get_pin_groups())
303 // {
304 // //ignore empty pingroups
305 // if (pinGroup->empty())
306 // continue;
307 
308 
309 // ModulePin* firstPin = pinGroup->get_pins().front();
310 // QString pinGroupName;
311 // QString pinGroupDirection = QString::fromStdString(enum_to_string(firstPin->get_direction()));
312 // QString pinGroupType = QString::fromStdString(enum_to_string(firstPin->get_type()));
313 // if (pinGroup->size() == 1)
314 // {
315 // pinGroupName = QString::fromStdString(firstPin->get_name());
316 // }
317 // else
318 // {
319 // pinGroupName = QString::fromStdString(pinGroup->get_name());
320 // }
321 
322 // TreeItem* pinGroupItem = new TreeItem(QList<QVariant>() << pinGroupName << pinGroupDirection << pinGroupType << "");
323 
324 // if (pinGroup->size() == 1)
325 // {
326 // pinGroupItem->setDataAtIndex(sNetColumn, QString::fromStdString(firstPin->get_net()->get_name()));
327 // pinGroupItem->setAdditionalData(keyType, QVariant::fromValue(itemType::pin));
328 // //since a single-pin pingroup represents the pin itself, take the pinid
329 // pinGroupItem->setAdditionalData(keyId, firstPin->get_id());
330 // mIdToPinItem.insert(firstPin->get_id(), pinGroupItem);
331 // }
332 // else
333 // {
334 // pinGroupItem->setAdditionalData(keyType, QVariant::fromValue(itemType::portMultiBit));
335 // pinGroupItem->setAdditionalData(keyId, pinGroup->get_id());
336 // mIdToGroupItem.insert(pinGroup->get_id(), pinGroupItem);
337 // for (ModulePin* pin : pinGroup->get_pins())
338 // {
339 // TreeItem* pinItem =
340 // new TreeItem(QList<QVariant>() << QString::fromStdString(pin->get_name()) << pinGroupDirection << pinGroupType << QString::fromStdString(pin->get_net()->get_name()));
341 // pinItem->setAdditionalData(keyType, QVariant::fromValue(itemType::pin));
342 // pinItem->setAdditionalData(keyId, pin->get_id());
343 // pinGroupItem->appendChild(pinItem);
344 // mNameToTreeItem.insert(QString::fromStdString(pin->get_name()), pinItem);
345 // mIdToPinItem.insert(pin->get_id(), pinItem);
346 // }
347 // }
348 // mRootItem->appendChild(pinGroupItem);
349 // mNameToTreeItem.insert(pinGroupName, pinGroupItem);
350 // }
351  endResetModel();
352 
353  Q_EMIT numberOfPortsChanged(m->get_pins().size());
354  }
355 
357  {
358  if (!mModule) //no current module = no represented net
359  return nullptr;
360 
361  if (item->itemType() == PortTreeItem::Group && item->getChildCount() > 1)
362  return nullptr;
363 
364  Module* m = gNetlist->get_module_by_id(mModule->get_id());
365  if (!m)
366  return nullptr;
367 
368  //std::string name = item->getData(sNameColumn).toString().toStdString();
369  if (auto* pin = m->get_pin_by_id(item->id()); pin != nullptr)
370  {
371  return pin->get_net();
372  }
373 
374  return nullptr;
375  }
376 
378  {
379  if (!mModule) return -1;
380  return mModule->get_id();
381  }
382 
384  {
385  static const QSet<PinEvent> groupEvents = { PinEvent::GroupCreate,
391  Q_UNUSED(pev);
392  Q_UNUSED(pgid);
393  if (m != mModule) return;
394 
395  // debug pingroups log_info("gui", "Handle pin_changed event {} ID={}", enum_to_string<PinEvent>(pev), pgid);
396  PortTreeItem* ptiPin = nullptr;
397  PortTreeItem* ptiGroup = nullptr;
398  const PinGroup<ModulePin>* pgroup = nullptr;
399  const ModulePin* pin = nullptr;
400  int pinRow = -1;
401 
402 
403  if (groupEvents.contains(pev))
404  {
405  // group event
406  ptiGroup = mIdToGroupItem.value(pgid);
407  if (pev != PinEvent::GroupCreate && !ptiGroup)
408  {
409  log_warning("gui", "Cannot handle event for pin group ID={}, tree item does not exist.", pgid);
410  return;
411  }
412  if (pev != PinEvent::GroupDelete)
413  {
414  pgroup = m->get_pin_group_by_id(pgid);
415  if (!pgroup)
416  {
417  log_warning("gui", "Cannot handle event for pin group ID={}, no such group.", pgid);
418  return;
419  }
420  }
421  }
422  else
423  {
424  // pin event
425  ptiPin = mIdToPinItem.value(pgid);
426  if (pev != PinEvent::PinCreate && !ptiPin)
427  {
428  log_warning("gui", "Cannot handle event for pin ID={}, tree item does not exist.", pgid);
429  return;
430  }
431  if (pev != PinEvent::PinDelete)
432  {
433  pin = m->get_pin_by_id(pgid);
434  if (!pin)
435  {
436  log_warning("gui", "Cannot handle event for pin ID={}, no such pid.", pgid);
437  return;
438  }
439  auto pgPair = pin->get_group();
440  pgroup = pgPair.first;
441  pinRow = pinIndex2Row(pin,pgPair.second);
442  if (pgroup)
443  ptiGroup = mIdToGroupItem.value(pgroup->get_id());
444  }
445  }
446 
447  QModelIndex dataChangedIndex;
448 
449  switch (pev)
450  {
452  {
453  ptiGroup = new PortTreeItem(PortTreeItem::Group,
454  pgroup->get_id(),
455  QString::fromStdString(pgroup->get_name()),
456  pgroup->get_direction(),
457  pgroup->get_type());
458  mIdToGroupItem.insert(ptiGroup->id(), ptiGroup);
459  int inx = pinGroupIndex(m,pgroup);
460  insertItem(ptiGroup, mRootItem, inx);
461  break;
462  }
464  {
465  int inx = pinGroupIndex(m,pgroup);
466  removeItem(ptiGroup);
467  insertItem(ptiGroup, mRootItem, inx);
468  break;
469  }
471  ptiGroup->setName(QString::fromStdString(pgroup->get_name()));
472  dataChangedIndex = getIndexFromItem(ptiGroup);
473  break;
475  ptiGroup->setPinType(pgroup->get_type());
476  dataChangedIndex = getIndexFromItem(ptiGroup);
477  break;
479  ptiGroup->setPinDirection(pgroup->get_direction());
480  dataChangedIndex = getIndexFromItem(ptiGroup);
481  break;
483  removeItem(ptiGroup);
484  delete ptiGroup;
485  break;
486  case PinEvent::PinCreate:
487  {
488  if (!pgroup || !ptiGroup)
489  {
490  log_warning("gui", "Cannot handle pin create event for pin ID={}, pin is not assigned to any group.", pgid);
491  return;
492  }
493  QString netName;
494  if (pin->get_net())
495  netName = QString::fromStdString(pin->get_net()->get_name());
496  ptiPin = new PortTreeItem(PortTreeItem::Pin,
497  pin->get_id(),
499  pin->get_direction(),
500  pin->get_type(),
501  netName);
502  mIdToPinItem.insert(ptiPin->id(), ptiPin);
503  insertItem(ptiPin, ptiGroup, pinRow);
504  break;
505  }
507  {
508  if (!pgroup || !ptiGroup)
509  {
510  log_warning("gui", "Cannot handle pin reorder event for pin ID={}, pin is not assigned to any group.", pgid);
511  return;
512  }
513  removeItem(ptiPin);
514  insertItem(ptiPin, ptiGroup, pinRow);
515  break;
516  }
518  {
519  if (!pgroup || !ptiGroup)
520  {
521  log_warning("gui", "Cannot handle pin assign event for pin ID={}, pin is not assigned to any group.", pgid);
522  return;
523  }
524  removeItem(ptiPin);
525  insertItem(ptiPin, ptiGroup, pinRow);
526  break;
527  }
528  case PinEvent::PinRename:
529  ptiPin->setName(QString::fromStdString(pin->get_name()));
530  dataChangedIndex = getIndexFromItem(ptiPin);
531  break;
533  ptiPin->setPinType(pin->get_type());
534  dataChangedIndex = getIndexFromItem(ptiPin);
535  break;
537  ptiPin->setPinDirection(pin->get_direction());
538  dataChangedIndex = getIndexFromItem(ptiPin);
539  break;
540  case PinEvent::PinDelete:
541  removeItem(ptiPin);
542  delete ptiPin;
543  break;
544  default:
545  break;
546  }
547 
548  if (dataChangedIndex.isValid())
549  {
550  QModelIndex inxLastCol = createIndex(dataChangedIndex.row(),columnCount()-1,dataChangedIndex.internalPointer());
551  Q_EMIT dataChanged(dataChangedIndex,inxLastCol);
552  }
553  }
554 
555  void ModulePinsTreeModel::dndGroupOnGroup(BaseTreeItem *droppedGroup, BaseTreeItem *onDroppedGroup)
556  {
557  // SPECIFY: 1) create completely new group, all pins in that, delete old 2 groups
558  // 2) just add all pins from dropped group to "ondroppedgroup", then rename?
559 // InputDialog ipd("Name of new group", "Name of new group:", onDroppedGroup->getData(sNameColumn).toString());
560 // if(ipd.exec() == QDialog::Rejected) return false;
562  auto srcgroup = mModule->get_pin_group_by_id(static_cast<PortTreeItem*>(droppedGroup)->id());
563  for(const auto &pin : srcgroup->get_pins())
564  pins.append(pin->get_id());
565  if (pins.isEmpty()) return; // no pins to move
566 
567  auto tgtgroup = mModule->get_pin_group_by_id(static_cast<PortTreeItem*>(onDroppedGroup)->id());
568 
569  ActionPingroup* act = ActionPingroup::addPinsToExistingGroup(mModule,tgtgroup->get_id(),pins);
571  if (act) act->exec();
572 
573  // too keep the order, ActionAddItemsToObject cannot be executed with all pins, but a ComAction must be created
574  // with many ActionAddItemsToObject that contain a single pin each -> set destroys order of pins in source pingroup
575  }
576 
577  void ModulePinsTreeModel::dndGroupBetweenGroup(PortTreeItem *droppedGroup, int row)
578  {
579  int ownRow = droppedGroup->getOwnRow();
580  bool bottomEdge = row == mRootItem->getChildCount();
581  auto desiredIdx = bottomEdge ? row-1 : row;
582  if(ownRow < row && !bottomEdge) desiredIdx--;
583  ActionPingroup* act = new ActionPingroup(PinActionType::GroupMoveToRow,droppedGroup->id(),"",desiredIdx);
584  act->setObject(UserActionObject(mModule->get_id(),UserActionObjectType::Module));
585  act->exec();
586  }
587 
588  void ModulePinsTreeModel::dndPinOnGroup(PortTreeItem *droppedPin, BaseTreeItem *onDroppedGroup)
589  {
590  ActionPingroup* act = new ActionPingroup(PinActionType::PinAsignToGroup,droppedPin->id(),"",static_cast<PortTreeItem*>(onDroppedGroup)->id());
591  act->setObject(UserActionObject(mModule->get_id(),UserActionObjectType::Module));
592  act->exec();
593  }
594 
595  void ModulePinsTreeModel::dndPinBetweenPin(PortTreeItem *droppedPin, BaseTreeItem *onDroppedParent, int row)
596  {
597  int desiredIdx = row;
598  ActionPingroup* act = nullptr;
599  if(droppedPin->getParent() == onDroppedParent) // same group
600  {
601  int ownRow = droppedPin->getOwnRow();
602  bool bottomEdge = row == onDroppedParent->getChildCount();
603  desiredIdx = bottomEdge ? row-1 : row;
604  if(ownRow < row && !bottomEdge) desiredIdx--; // insert item here
605  act = new ActionPingroup(PinActionType::PinMoveToRow,droppedPin->id(),"",desiredIdx); // TODO : start_index, descending
606  }
607  else
608  {
609  act = ActionPingroup::addPinToExistingGroup(mModule,static_cast<PortTreeItem*>(onDroppedParent)->id(),droppedPin->id(),desiredIdx);
610  if (!act) return;
611  }
612  act->setObject(UserActionObject(mModule->get_id(),UserActionObjectType::Module));
613  act->exec();
614  }
615 
616  void ModulePinsTreeModel::dndPinBetweenGroup(PortTreeItem *droppedPin, int row)
617  {
618  // row is needed for when groups can change its order within the module
619  Q_UNUSED(row)
620 
621  auto pinToMove = mModule->get_pin_by_id(droppedPin->id());
622  if (!pinToMove) return;
623 
624  QString groupName = generateGroupName(mModule,pinToMove);
625 
626  ActionPingroup* act = ActionPingroup::addPinToNewGroup(mModule, groupName, droppedPin->id(),row);
627  act->exec();
628  }
629 
630  void ModulePinsTreeModel::insertItem(PortTreeItem* item, BaseTreeItem* parent, int index)
631  {
632  // fun fact: if an item is inserted above an item that is expanded, the tree collapses all indeces
634  parent->insertChild(index, item);
635  endInsertRows();
636  //mNameToTreeItem.insert(item->getData(sNameColumn).toString(), item);
637  item->itemType() == PortTreeItem::Pin ? mIdToPinItem.insert(item->id(), item) : mIdToGroupItem.insert(item->id(), item);
638  //mIdToPinItem.insert(getIdOfItem(item), item);
639  }
640  void ModulePinsTreeModel::removeItem(PortTreeItem* item)
641  {
642  beginRemoveRows(parent(getIndexFromItem(item)), item->getOwnRow(), item->getOwnRow());
643  item->getParent()->removeChild(item);
644  endRemoveRows();
645  //mNameToTreeItem.remove(item->getData(sNameColumn).toString());
646  //for now, only ids of pin-items (since these functions are only relevant for dnd)
647  item->itemType() == PortTreeItem::Pin ? mIdToPinItem.remove(item->id()) : mIdToGroupItem.remove(item->id());
648  //mIdToPinItem.remove(getIdOfItem(item));
649  //delete item;
650  }
651 
652 
653 
654 } // namespace hal
Pingroup user actions.
static ActionPingroup * addPinToNewGroup(const Module *m, const QString &name, u32 pinId, int grpRow=-1)
static ActionPingroup * addPinToExistingGroup(const Module *m, u32 grpId, u32 pinId, int pinRow=-1)
static ActionPingroup * addPinsToExistingGroup(const Module *m, u32 grpId, QList< u32 > pinIds, int pinRow=-1)
bool exec() override
const std::string & get_name() const
Definition: base_pin.h:108
u32 get_id() const
Definition: base_pin.h:88
PinType get_type() const
Definition: base_pin.h:148
const std::pair< PinGroup< T > *, i32 > & get_group() const
Definition: base_pin.h:158
PinDirection get_direction() const
Definition: base_pin.h:128
(Future) Base class for all tree models related to the details widget.
virtual int getChildCount() const
virtual void appendChild(BaseTreeItem *child)
virtual int getOwnRow()
The BaseTreeModel implements generic standard functions of a tree model.
QModelIndex getIndexFromItem(BaseTreeItem *item) const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
RootTreeItem * mRootItem
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
virtual void clear()
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setHeaderLabels(const QStringList &label)
BaseTreeItem * getItemFromIndex(QModelIndex index) const
std::vector< ModulePin * > get_pins(const std::function< bool(ModulePin *)> &filter=nullptr) const
Definition: module.cpp:871
ModulePin * get_pin_by_id(const u32 id) const
Definition: module.cpp:983
std::vector< PinGroup< ModulePin > * > get_pin_groups(const std::function< bool(PinGroup< ModulePin > *)> &filter=nullptr) const
Definition: module.cpp:962
PinGroup< ModulePin > * get_pin_group_by_id(const u32 id) const
Definition: module.cpp:1034
u32 get_id() const
Definition: module.cpp:82
Net * get_net() const
Definition: module_pin.cpp:19
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
ModulePinsTreeModel(QObject *parent=nullptr)
QStringList mimeTypes() const override
Net * getNetFromItem(PortTreeItem *item)
QMimeData * mimeData(const QModelIndexList &indexes) const override
void handleModulePortsChanged(Module *m, PinEvent pev, u32 pgid)
Qt::ItemFlags flags(const QModelIndex &index) const override
void numberOfPortsChanged(const int newNumber)
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition: net.h:58
const std::string & get_name() const
Definition: net.cpp:98
Module * get_module_by_id(u32 module_id) const
Definition: netlist.cpp:613
void modulePortsChanged(Module *m, PinEvent pev, u32 pgid) const
u32 get_id() const
Definition: pin_group.h:130
const std::string & get_name() const
Definition: pin_group.h:150
PinDirection get_direction() const
Definition: pin_group.h:190
PinType get_type() const
Definition: pin_group.h:170
void setPinDirection(PinDirection dir)
void setPinType(PinType ptype)
void appendData(QVariant data) override
void setDataAtIndex(int index, QVariant &data) override
void setData(QList< QVariant > data) override
int getColumnCount() const override
void setName(const QString &nam)
Type itemType() const
QVariant getData(int column) const override
static QString pyCodeModulePinGroup(u32 moduleId, u32 groupId)
static QString pyCodeModulePinById(u32 moduleId, u32 pinId)
virtual void setObject(const UserActionObject &obj)
Definition: user_action.cpp:32
The UserActionObject class represents a single object used in UserAction.
#define log_warning(channel,...)
Definition: log.h:76
action
Definition: control.py:16
PinDirection
Definition: pin_direction.h:36
int pinGroupIndex(const Module *mod, const PinGroup< ModulePin > *pgrp)
PinEvent
Definition: pin_event.h:42
@ PinTypeChange
pin renamed
@ GroupReorder
changed PinDirection attribute of group (like input)
@ PinDirChange
changed PinType attribute of pin (like data)
@ PinCreate
moved group to a new position within containing module
@ GroupTypeChange
pin group renamed
@ PinRename
pin assigned to new group
@ PinAssignToGroup
new pin created
@ PinDelete
moved pin to a new position within containing group
@ GroupRename
new pin group created
@ GroupDelete
pin deleted
@ GroupDirChange
changed PinType attribute of group (like data)
@ PinReorder
changed PinDirection attribute of pin (like input)
int pinIndex2Row(const ModulePin *pin, int index)
Netlist * gNetlist
Definition: plugin_gui.cpp:80
NetlistRelay * gNetlistRelay
Definition: plugin_gui.cpp:81
PinType
Definition: pin_type.h:36
QString generateGroupName(const Module *mod, const ModulePin *pin)
std::string enum_to_string(T e)
Definition: enums.h:52
quint32 u32
PinType type
std::vector< PinInformation > pins
i32 id
void beginInsertRows(const QModelIndex &parent, int first, int last)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
QModelIndex createIndex(int row, int column, void *ptr) const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
void * internalPointer() const const
bool isValid() const const
int row() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
bool contains(const T &value) const const
QString fromStdString(const std::string &str)
DropAction
typedef ItemFlags