Skip to content

Commit

Permalink
Handling of individual pin_changed events in GUI (albeit not fully te…
Browse files Browse the repository at this point in the history
…sted)
  • Loading branch information
joern274 committed Sep 20, 2023
1 parent a90e15a commit b7f9bac
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 83 deletions.
2 changes: 1 addition & 1 deletion include/hal_core/netlist/gate_library/enums/pin_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ namespace hal
GroupRename,
GroupTypeChange,
GroupDirChange,
GroupPinAssign,
GroupDelete,
PinCreate,
PinReorder,
PinAssignToGroup,
PinRename,
PinTypeChange,
PinDirChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
//#include "gui/new_selection_details_widget/models/base_tree_model.h"
#include "gui/basic_tree_model/base_tree_model.h"
#include "hal_core/netlist/gate_library/enums/pin_type.h"
#include "hal_core/netlist/gate_library/enums/pin_direction.h"
#include <QMap>

namespace hal
Expand All @@ -42,24 +43,31 @@ namespace hal
enum Type {None, Pin, Group};

private:
Type mType;
Type mItemType;
u32 mId;
QString mPinName;
QString mPinDirection;
QString mPinType;
PinDirection mPinDirection;
PinType mPinType;
QString mNetName;

void setPinType(const QString& type);
void setPinDirection(const QString& dir);
public:

PortTreeItem(Type tp, QString pinName, QString pinDirection, QString pinType, QString netName);
PortTreeItem() : mType(None), mId(0) {;}
PortTreeItem(Type itype, QString pinName, PinDirection dir, PinType ptype, QString netName = QString());
PortTreeItem() : mItemType(None), mId(0) {;}
QVariant getData(int column) const override;
void setData(QList<QVariant> data) override;
void setDataAtIndex(int index, QVariant& data) override;
void appendData(QVariant data) override;
int getColumnCount() const override;
void setType(Type tp) { mType = tp; }
Type type() const { return mType; }
void setItemType(Type tp) { mItemType = tp; }
Type itemType() const { return mItemType; }
void setId(u32 id_) { mId = id_; }
QString name() const { return mPinName; }
void setName(const QString& nam) { mPinName = nam; }
void setPinType(PinType ptype) { mPinType = ptype; }
void setPinDirection(PinDirection dir) { mPinDirection = dir; }

/**
* Returns the pin-id if the item represents a pin or the pingroup-id
Expand Down Expand Up @@ -155,9 +163,8 @@ namespace hal
Module* mModule;
//name is (hopefully) enough to identify
QMap<QString, BaseTreeItem*> mNameToTreeItem;
QMap<int, BaseTreeItem*> mIdToPinItem;
QMap<int, BaseTreeItem*> mIdToGroupItem;
bool mIgnoreEventsFlag;
QMap<int, PortTreeItem*> mIdToPinItem;
QMap<int, PortTreeItem*> mIdToGroupItem;

void insertItem(PortTreeItem* item, BaseTreeItem* parent, int index);
void removeItem(PortTreeItem* item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once

#include "hal_core/defines.h"
#include "hal_core/netlist/gate_library/enums/pin_type.h"

#include <QAbstractTableModel>
#include <QList>
Expand Down Expand Up @@ -154,7 +155,7 @@ class ModuleTableModel : public QAbstractTableModel
/** @name Event Handler Functions
*/
///@{
void handleModulePortsChanged(Module* m);
void handleModulePortsChanged(Module* m, PinEvent pev, u32 pgid);
void handleModuleRemoved(Module* m);
///@}

Expand Down
2 changes: 1 addition & 1 deletion plugins/gui/include/gui/user_action/action_pingroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace hal
static bool useExistingPin(Type tp);
};

int pinGroupIndex(const Module* mod, const PinGroup<Module>* pgrp);
int pinGroupIndex(const Module* mod, const PinGroup<ModulePin>* pgrp);

/**
* @ingroup user_action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace hal
});
}

if (clickedItem->type() == PortTreeItem::Group) //group specific context, own helper function? (returns at the end)
if (clickedItem->itemType() == PortTreeItem::Group) //group specific context, own helper function? (returns at the end)
{
menu.addAction("Change name", [name, modId, itemId]() {
InputDialog ipd("Change pin group name", "New group name", name);
Expand Down Expand Up @@ -244,7 +244,7 @@ namespace hal
appendMultiSelectionEntries(menu, modId);

menu.addSection("Python");
if(clickedItem->type()==PortTreeItem::Pin)
if(clickedItem->itemType()==PortTreeItem::Pin)
menu.addAction(QIcon(":/icons/python"), "Get pin", [modId, itemId]() { QApplication::clipboard()->setText(PyCodeProvider::pyCodeModulePinById(modId, itemId)); });
else
menu.addAction(QIcon(":/icons/python"), "Get group", [modId, itemId]() { QApplication::clipboard()->setText(PyCodeProvider::pyCodeModulePinGroup(modId, itemId)); });
Expand Down Expand Up @@ -297,15 +297,15 @@ namespace hal
for (auto index : selectionModel()->selectedRows())
{
PortTreeItem* item = static_cast<PortTreeItem*>(mPortModel->getItemFromIndex(index));
if (item->type() == PortTreeItem::Pin)
if (item->itemType() == PortTreeItem::Pin)
{
if (!alreadyProcessedPins.contains(item))
{
selectedPins.append(item);
alreadyProcessedPins.insert(item);
}
}
else if (item->type() == PortTreeItem::Group)
else if (item->itemType() == PortTreeItem::Group)
{
onlyPins = false;
for (auto pinItem : item->getChildren())
Expand Down
Loading

0 comments on commit b7f9bac

Please sign in to comment.