1919
2020namespace hal
2121{
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)
22+ PortTreeItem::PortTreeItem (Type itype, u32 id_, QString pinName, PinDirection dir, PinType ptype, int inx, QString netName)
23+ : mItemType (itype), mId (id_), mPinName (pinName), mPinDirection (dir), mPinType (ptype), mNetName (netName), mIndex (inx)
2424 {;}
2525
2626 QVariant PortTreeItem::getData (int index) const
@@ -35,34 +35,43 @@ namespace hal
3535 return QString::fromStdString (enum_to_string (mPinType ));
3636 case 3 :
3737 return mNetName ;
38+ case 4 :
39+ if (mItemType ==PortTreeItem::Group)
40+ return ( mIndex ? " descending" : " ascending" );
41+ return mIndex ;
3842 }
3943 return QVariant ();
4044 }
4145
4246 void PortTreeItem::setData (QList<QVariant> data)
4347 {
48+ Q_ASSERT (data.size () >= 5 );
4449 mPinName = data[0 ].toString ();
4550 mPinDirection = enum_from_string<PinDirection>(data[1 ].toString ().toStdString ());
4651 mPinType = enum_from_string<PinType>(data[2 ].toString ().toStdString ());
4752 mNetName = data[3 ].toString ();
53+ mIndex = data[4 ].toInt ();
4854 }
4955
5056 void PortTreeItem::setDataAtIndex (int index, QVariant &data)
5157 {
5258 switch (index)
5359 {
54- case 0 : {
60+ case 0 :
5561 mPinName = data.toString ();
56- break ;}
57- case 1 : {
62+ break ;
63+ case 1 :
5864 mPinDirection = enum_from_string<PinDirection>(data.toString ().toStdString ());
59- break ;}
60- case 2 : {
65+ break ;
66+ case 2 :
6167 mPinType = enum_from_string<PinType>(data.toString ().toStdString ());
62- break ;}
63- case 3 : {
68+ break ;
69+ case 3 :
6470 mNetName = data.toString ();
65- break ;}
71+ break ;
72+ case 4 :
73+ mIndex = data.toInt ();
74+ break ;
6675 }
6776 }
6877
@@ -73,15 +82,16 @@ namespace hal
7382
7483 int PortTreeItem::getColumnCount () const
7584 {
76- return 4 ;
85+ return 5 ;
7786 }
7887
7988 ModulePinsTreeModel::ModulePinsTreeModel (QObject* parent) : BaseTreeModel(parent)
8089 {
8190 setHeaderLabels (QStringList () << " Name"
8291 << " Direction"
8392 << " Type"
84- << " Connected Net" );
93+ << " Connected Net"
94+ << " Index" );
8595 setModule (gNetlist ->get_module_by_id (1 ));
8696
8797 // connections
@@ -132,7 +142,7 @@ namespace hal
132142
133143 QMimeData* ModulePinsTreeModel::mimeData (const QModelIndexList& indexes) const
134144 {
135- if (indexes.size () != 4 ) // columncount, only 1 item is allowed
145+ if (indexes.size () != 5 ) // columncount, only 1 item is allowed
136146 return new QMimeData ();
137147
138148 QMimeData* data = new QMimeData ();
@@ -281,7 +291,8 @@ namespace hal
281291 continue ;
282292
283293 auto pinGroupName = QString::fromStdString (pinGroup->get_name ());
284- PortTreeItem* pinGroupItem = new PortTreeItem (PortTreeItem::Group, pinGroup->get_id (), pinGroupName, pinGroup->get_direction (), pinGroup->get_type ());
294+ PortTreeItem* pinGroupItem = new PortTreeItem (PortTreeItem::Group, pinGroup->get_id (), pinGroupName, pinGroup->get_direction (),
295+ pinGroup->get_type (), pinGroup->is_ascending () ? 0 : 1 );
285296 mIdToGroupItem .insert (pinGroup->get_id (), pinGroupItem);
286297 for (ModulePin* pin : pinGroup->get_pins ())
287298 {
@@ -290,6 +301,7 @@ namespace hal
290301 QString::fromStdString (pin->get_name ()),
291302 pin->get_direction (),
292303 pin->get_type (),
304+ pin->get_group ().second ,
293305 QString::fromStdString (pin->get_net ()->get_name ()));
294306 pinGroupItem->appendChild (pinItem);
295307 mNameToTreeItem .insert (QString::fromStdString (pin->get_name ()), pinItem);
@@ -452,9 +464,10 @@ namespace hal
452464 {
453465 ptiGroup = new PortTreeItem (PortTreeItem::Group,
454466 pgroup->get_id (),
455- QString::fromStdString (pgroup->get_name ()),
456- pgroup->get_direction (),
457- pgroup->get_type ());
467+ QString::fromStdString (pgroup->get_name ()),
468+ pgroup->get_direction (),
469+ pgroup->get_type (),
470+ pgroup->is_ascending ()?0 :1 );
458471 mIdToGroupItem .insert (ptiGroup->id (), ptiGroup);
459472 int inx = pinGroupIndex (m,pgroup);
460473 insertItem (ptiGroup, mRootItem , inx);
@@ -498,6 +511,7 @@ namespace hal
498511 QString::fromStdString (pin->get_name ()),
499512 pin->get_direction (),
500513 pin->get_type (),
514+ pin->get_group ().second ,
501515 netName);
502516 mIdToPinItem .insert (ptiPin->id (), ptiPin);
503517 insertItem (ptiPin, ptiGroup, pinRow);
0 commit comments