HAL
gatelibrary_tab_pin.cpp
Go to the documentation of this file.
1 
3 
4 #include "gui/gui_globals.h"
5 
6 #include <QTreeView>
9 
10 namespace hal
11 {
12 
14  : QTreeView(parent)
15  {
16  QStyle* s = style();
17 
18  s->unpolish(this);
19  s->polish(this);
21  }
22 
23  /*
24  QModelIndex PinTreeView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
25  {
26  QModelIndex inx = currentIndex();
27  QModelIndex par = inx.parent();
28  int pcount = 0;
29  while (par.isValid())
30  {
31  ++pcount;
32  par = par.parent();
33  }
34  std::cerr << "moveCursor " << cursorAction << " current: " << model()->data(inx).toString().toStdString() << std::endl;
35 
36  return QTreeView::moveCursor(cursorAction, modifiers);
37  }
38  */
39 
41  {
42  QModelIndex nextIndex;
43 
44  if (index.column() || index.parent().isValid())
45  nextIndex = model()->index(index.row()+1,0,index.parent());
46  else
47  nextIndex = model()->index(index.row(),1,index.parent());
48 
49  setCurrentIndex(nextIndex);
50  edit(nextIndex);
51  }
52 
53 
55  : GateLibraryTabInterface(parent)
56  {
57  mGridLayout = new QGridLayout(this);
58 
59  mTreeView = new PinTreeView(this);
60 
61  if (editable)
62  {
63  mPinModel = new PinModel(this, editable);
64  auto pinDelegate = new PinDelegate(this);
65  mTreeView->setItemDelegate(pinDelegate);
67  }
68  else
69  {
70  mPinModel = new PinModel(this);
71  }
72 
73  mTreeView->setModel(mPinModel);
74 
75  mGridLayout->addWidget(mTreeView);
76 
77  setLayout(mGridLayout);
78  }
79 
81  {
82 
83  mPinModel->setGate(gate);
84 
85  //TODO resize to see children columns
86  mTreeView->resizeColumnToContents(0);
87  }
88 
90  {
91  return mTreeView;
92  }
93 
95  {
96  return mPinModel;
97  }
98 
99 }
GateLibraryTabPin(bool editable=false, QWidget *parent=nullptr)
void setGate(GateType *gate)
Definition: pin_model.cpp:41
void editNewDone(QModelIndex index)
void handleEditNewDone(const QModelIndex &index)
PinTreeView(QWidget *parent=nullptr)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
void edit(const QModelIndex &index)
QAbstractItemModel * model() const const
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void setCurrentIndex(const QModelIndex &index)
void setItemDelegate(QAbstractItemDelegate *delegate)
void addWidget(QWidget *widget, int row, int column, Qt::Alignment alignment)
int column() const const
bool isValid() const const
QModelIndex parent() const const
int row() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual void polish(QWidget *widget)
virtual void unpolish(QWidget *widget)
QueuedConnection
void resizeColumnToContents(int column)
virtual void setModel(QAbstractItemModel *model) override
void setLayout(QLayout *layout)
QStyle * style() const const
void update()