8 #include <QInputDialog>
13 const QString NetInfoTable::nameRowKey =
"Name";
14 const QString NetInfoTable::idRowKey =
"ID";
15 const QString NetInfoTable::typeRowKey =
"Type";
16 const QString NetInfoTable::noOfSrcRowKey =
"Number of Sources";
17 const QString NetInfoTable::noOfDstRowKey =
"Number of Destinations";
21 mNameEntryContextMenu =
new QMenu();
22 mNameEntryContextMenu->
addAction(
"Name to clipboard", std::bind(&NetInfoTable::copyName,
this));
24 mNameEntryContextMenu->
addAction(
"Change name", std::bind(&NetInfoTable::changeName,
this));
26 mNameEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get name", std::bind(&NetInfoTable::pyCopyName,
this));
28 mIdEntryContextMenu =
new QMenu();
29 mIdEntryContextMenu->
addAction(
"ID to clipboard", std::bind(&NetInfoTable::copyId,
this));
31 mIdEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get ID", std::bind(&NetInfoTable::pyCopyId,
this));
33 mTypeEntryContextMenu =
new QMenu();
34 mTypeEntryContextMenu->
addAction(
"Type to clipboard", std::bind(&NetInfoTable::copyType,
this));
36 mTypeEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get type", std::bind(&NetInfoTable::pyCopyType,
this));
38 mNumSrcsEntryContextMenu =
new QMenu();
39 mNumSrcsEntryContextMenu->
addAction(
"Number of sources to clipboard", std::bind(&NetInfoTable::copyNumberOfSrcs,
this));
40 mNumSrcsEntryContextMenu->
addSection(
"Python");
41 mNumSrcsEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get sources", std::bind(&NetInfoTable::pyCopySrcs,
this));
43 mNumDstsEntryContextMenu =
new QMenu();
44 mNumDstsEntryContextMenu->
addAction(
"Number of destinations to clipboard", std::bind(&NetInfoTable::copyNumberOfDsts,
this));
45 mNumDstsEntryContextMenu->
addSection(
"Python");
46 mNumDstsEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get destinations", std::bind(&NetInfoTable::pyCopyDsts,
this));
66 setRow(nameRowKey, name(), mNameEntryContextMenu);
67 setRow(idRowKey,
id(), mIdEntryContextMenu);
68 setRow(typeRowKey, type(), mTypeEntryContextMenu);
69 setRow(noOfSrcRowKey, numberOfSrcs(), mNumSrcsEntryContextMenu);
70 setRow(noOfDstRowKey, numberOfDsts(), mNumDstsEntryContextMenu);
76 QString NetInfoTable::name()
const
81 QString NetInfoTable::id()
const
86 QString NetInfoTable::type()
const
91 type =
"Global input";
93 type =
"Global output";
102 QString NetInfoTable::numberOfSrcs()
const
107 QString NetInfoTable::numberOfDsts()
const
112 void NetInfoTable::changeName()
115 QString prompt =
"Change net name";
122 ActionRenameObject* act =
new ActionRenameObject(newName);
123 act->setObject(UserActionObject(mNet->
get_id(), UserActionObjectType::ObjectType::Net));
128 void NetInfoTable::copyName()
const
133 void NetInfoTable::pyCopyName()
const
138 void NetInfoTable::copyId()
const
143 void NetInfoTable::pyCopyId()
const
148 void NetInfoTable::copyType()
const
153 void NetInfoTable::pyCopyType()
const
158 void NetInfoTable::copyNumberOfSrcs()
const
163 void NetInfoTable::pyCopySrcs()
const
168 void NetInfoTable::copyNumberOfDsts()
const
173 void NetInfoTable::pyCopyDsts()
const
178 void NetInfoTable::handleNetRemoved(Net*
net)
184 const QString notification(
"Displayed net has been removed.");
186 setRow(nameRowKey, notification,
nullptr);
187 setRow(idRowKey, notification,
nullptr);
188 setRow(typeRowKey, notification,
nullptr);
189 setRow(noOfSrcRowKey, notification,
nullptr);
190 setRow(noOfDstRowKey, notification,
nullptr);
196 void NetInfoTable::handleNetNameChanged(Net*
net)
202 void NetInfoTable::handleNetTypeChanged(Netlist*
netlist,
const u32 netId)
209 if (mNet->
get_id() == netId)
213 void NetInfoTable::handleSrcDstChanged(Net*
net,
u32 srcDstGateId)
215 Q_UNUSED(srcDstGateId)
221 void NetInfoTable::refresh()
u32 get_num_of_sources(const std::function< bool(Endpoint *ep)> &filter=nullptr) const
const std::string & get_name() const
bool is_global_output_net() const
u32 get_num_of_destinations(const std::function< bool(Endpoint *ep)> &filter=nullptr) const
bool is_global_input_net() const
NetInfoTable(QWidget *parent=nullptr)
bool is_net_in_netlist(const Net *net) const
void netDestinationRemoved(Net *n, const u32 dst_gate_id) const
void netlistUnmarkedGlobalOutput(Netlist *n, const u32 associated_data) const
void netlistUnmarkedGlobalInput(Netlist *n, const u32 associated_data) const
void netSourceAdded(Net *n, const u32 src_gate_id) const
void netSourceRemoved(Net *n, const u32 src_gate_id) const
void netlistMarkedGlobalInput(Netlist *n, const u32 associated_data) const
void netRemoved(Net *n) const
void netlistMarkedGlobalOutput(Netlist *n, const u32 associated_data) const
void netDestinationAdded(Net *n, const u32 dst_gate_id) const
void netNameChanged(Net *n) const
static QString pyCodeNetSources(u32 netId)
static QString pyCodeNetType(u32 netId)
static QString pyCodeNetId(u32 netId)
static QString pyCodeNetDestinations(u32 netId)
static QString pyCodeNetName(u32 netId)
NetlistRelay * gNetlistRelay
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString fromStdString(const std::string &str)
QString number(int n, int base)