HAL
pins_wizardpage.cpp
Go to the documentation of this file.
2 
5 
6 namespace hal
7 {
9  {
10  setTitle("Pins and Pingroups");
11  setSubTitle("Edit pins and pingroups");
12  QGridLayout* layout = new QGridLayout(this);
13 
14  mPinTab = new GateLibraryTabPin(true, this);
15  mDelBtn = new QPushButton("Delete", this);
16  mPinModel = mPinTab->getPinModel();
17 
18  mGateset = false;
19 
20  layout->addWidget(mDelBtn, 1, 0);
21  layout->addWidget(mPinTab, 0, 0, 1, 2);
22 
25  }
26 
28  {
29  mWizard = static_cast<GateLibraryWizard*>(wizard());
30  mWizard->mPinModel = mPinModel;
31  mWizard->mEditMode = true;
32 
33  if(!mGateset)
34  {
35  mPinTab->update(mWizard->mGateType);
36  mGateset = true;
37  }
38  }
39 
41  {
42  auto treeView = mPinTab->getTreeView();
43 
44  mPinModel->handleDeleteItem(treeView->currentIndex());
46  }
47 
49  return mPinModel->getPinGroups();
50  }
51 
52  void PinsWizardPage::handlePinModelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
53  {
55  }
56 
58  {
59  if(mPinModel->getRootItem()->getChildren().isEmpty()) return false;
60  bool hasPingroup = false;
61  for(auto ch : mPinModel->getRootItem()->getChildren()) //check pin direction of groups
62  {
63  PinItem* pg = static_cast<PinItem*>(ch);
64  if(pg->getItemType() != PinItem::TreeItemType::GroupCreator) hasPingroup = true;
65  if(pg->getItemType() == PinItem::TreeItemType::InvalidPinGroup) return false;
66  if(!pg->getChildren().isEmpty())
67  {
68  for (auto it : pg->getChildren()) {
69  PinItem* p = static_cast<PinItem*>(it);
70  if(pg->getItemType() == PinItem::TreeItemType::InvalidPin) return false;
71  }
72  }
73  }
74  mWizard->mEditMode = false;
75  return hasPingroup;
76  }
77 }
virtual QList< BaseTreeItem * > getChildren() const
BaseTreeItem * getRootItem() const
void update(GateType *gate) override
An item in the PinModel.
Definition: pin_item.h:48
TreeItemType getItemType() const
Definition: pin_item.cpp:132
QList< PinItem * > getPinGroups() const
Definition: pin_model.cpp:632
void handleDeleteItem(QModelIndex index)
Definition: pin_model.cpp:644
PinsWizardPage(QWidget *parent=nullptr)
bool isComplete() const override
QList< PinItem * > getPingroups()
void handlePinModelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void initializePage() override
void clicked(bool checked)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
void addWidget(QWidget *w)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QLayout * layout() const const
void completeChanged()
void setSubTitle(const QString &subTitle)
void setTitle(const QString &title)
QWizard * wizard() const const