14 #include <QInputDialog>
18 const QString GateInfoTable::nameRowKey =
"Name";
19 const QString GateInfoTable::idRowKey =
"ID";
20 const QString GateInfoTable::typeRowKey =
"Type";
21 const QString GateInfoTable::gateTypePropertiesRowKey =
"Properties";
22 const QString GateInfoTable::locationRowKey =
"Location";
23 const QString GateInfoTable::moduleRowKey =
"Module";
27 mNameEntryContextMenu =
new QMenu();
28 mNameEntryContextMenu->
addAction(
"Name to clipboard", std::bind(&GateInfoTable::copyName,
this));
30 mNameEntryContextMenu->
addAction(
"Change name", std::bind(&GateInfoTable::changeName,
this));
32 mNameEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get name", std::bind(&GateInfoTable::pyCopyName,
this));
34 mIdEntryContextMenu =
new QMenu();
35 mIdEntryContextMenu->
addAction(
"ID to clipboard", std::bind(&GateInfoTable::copyId,
this));
37 mIdEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get ID", std::bind(&GateInfoTable::pyCopyId,
this));
39 mTypeEntryContextMenu =
new QMenu();
40 mTypeEntryContextMenu->
addAction(
"Type name to clipboard", std::bind(&GateInfoTable::copyType,
this));
42 mTypeEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get type", std::bind(&GateInfoTable::pyCopyType,
this));
44 mPropertiesEntryContextMenu =
new QMenu();
45 mPropertiesEntryContextMenu->
addAction(
"Properties to clipboard", std::bind(&GateInfoTable::copyproperties,
this));
46 mPropertiesEntryContextMenu->
addSection(
"Python");
47 mPropertiesEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get properties", std::bind(&GateInfoTable::pyCopyproperties,
this));
49 mLocationEntryContextMenu =
new QMenu();
50 mLocationEntryContextMenu->
addAction(
"Location to clipboard", std::bind(&GateInfoTable::copyLocation,
this));
51 mLocationEntryContextMenu->
addSection(
"Phyton");
52 mLocationEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get location", std::bind(&GateInfoTable::pyCopyLocation,
this));
54 mModuleEntryContextMenu =
new QMenu();
55 mModuleEntryContextMenu->
addAction(
"Module name to clipboard", std::bind(&GateInfoTable::copyModuleName,
this));
56 mModuleEntryContextMenu->
addAction(
"Module ID to clipboard", std::bind(&GateInfoTable::copyModuleID,
this));
57 mModuleEntryContextMenu->
addAction(
"Set as current selection", std::bind(&GateInfoTable::setModuleAsSelection,
this));
58 mModuleEntryContextMenu->
addAction(
"Add to current selection", std::bind(&GateInfoTable::addModuleToSelection,
this));
59 mModuleEntryContextMenu->
addAction(
"Change module", std::bind(&GateInfoTable::moveToModuleAction,
this));
61 mModuleEntryContextMenu->
addAction(
QIcon(
":/icons/python"),
"Get module", std::bind(&GateInfoTable::pyCopyModule,
this));
63 mModuleDoubleClickedAction = std::bind(&GateInfoTable::setModuleAsSelection,
this);
78 setRow(nameRowKey , name(), mNameEntryContextMenu);
79 setRow(idRowKey,
id(), mIdEntryContextMenu);
80 setRow(typeRowKey, type(), mTypeEntryContextMenu);
81 setRow(gateTypePropertiesRowKey, properties(), mPropertiesEntryContextMenu);
82 setRow(locationRowKey, location(), mLocationEntryContextMenu);
83 setRow(moduleRowKey, parentModule(), mModuleEntryContextMenu, mModuleDoubleClickedAction);
89 QString GateInfoTable::name()
const
94 QString GateInfoTable::id()
const
99 QString GateInfoTable::type()
const
111 QString GateInfoTable::properties()
const
130 QString GateInfoTable::location()
const
144 QString GateInfoTable::parentModule()
const
154 void GateInfoTable::changeName()
157 QString prompt =
"Change gate name";
164 ActionRenameObject* act =
new ActionRenameObject(newName);
165 act->setObject(UserActionObject(mGate->
get_id(), UserActionObjectType::ObjectType::Gate));
170 void GateInfoTable::copyName()
const
175 void GateInfoTable::pyCopyName()
const
180 void GateInfoTable::copyId()
const
185 void GateInfoTable::pyCopyId()
const
190 void GateInfoTable::copyType()
const
195 void GateInfoTable::pyCopyType()
const
200 void GateInfoTable::copyproperties()
const
205 void GateInfoTable::pyCopyproperties()
const
210 void GateInfoTable::copyLocation()
const
215 void GateInfoTable::pyCopyLocation()
const
220 void GateInfoTable::copyModuleName()
const
226 void GateInfoTable::pyCopyModule()
const
231 void GateInfoTable::copyModuleID()
const
236 void GateInfoTable::addModuleToSelection()
242 void GateInfoTable::setModuleAsSelection()
249 void GateInfoTable::moveToModuleAction()
253 ModuleDialog md(excludeMods,
"Move to module",
false,
nullptr,
this);
255 if (md.isNewModule())
260 if (!ok ||
name.isEmpty())
return;
264 UserActionCompound* compound =
new UserActionCompound;
265 compound->setUseCreatedObject();
266 compound->addAction(actNewModule);
276 void GateInfoTable::handleGateRemoved(Gate* gate)
282 const QString notification(
"Displayed gate has been removed.");
284 setRow(nameRowKey, notification,
nullptr);
285 setRow(idRowKey, notification,
nullptr);
286 setRow(typeRowKey, notification,
nullptr);
287 setRow(gateTypePropertiesRowKey, notification,
nullptr);
288 setRow(locationRowKey, notification,
nullptr);
289 setRow(moduleRowKey, notification,
nullptr,
nullptr);
295 void GateInfoTable::handleGateNameChanged(Gate* gate)
301 void GateInfoTable::handleGateLocationChanged(Gate* gate)
307 void GateInfoTable::handleModuleNameChanged(Module*
module)
316 void GateInfoTable::handleModuleGateAssigned(Module*
module,
const u32 gateId)
323 if(mGate->
get_id() == gateId)
327 void GateInfoTable::refresh()
i32 get_location_x() const
i32 get_location_y() const
GateType * get_type() const
const std::string & get_name() const
bool has_location() const
Module * get_module() const
GateInfoTable(QWidget *parent=nullptr)
std::string get_name() const
bool is_gate_in_netlist(const Gate *gate) const
void moduleGateAssigned(Module *m, const u32 assigned_gate) const
void moduleNameChanged(Module *m) const
void gateRemoved(Gate *g) const
void gateNameChanged(Gate *g) const
void gateLocationChanged(Gate *g) const
static QString pyCodeGateLocation(u32 gateId)
static QString pyCodeGateType(u32 gateId)
static QString pyCodeProperties(u32 gateId)
static QString pyCodeGateModule(u32 gateId)
static QString pyCodeGateName(u32 gateId)
static QString pyCodeGateId(u32 gateId)
void relaySelectionChanged(void *sender)
const Module * module(const Gate *g, const NodeBoxes &boxes)
SelectionRelay * gSelectionRelay
NetlistRelay * gNetlistRelay
std::string enum_to_string(T e)
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)
QSet::iterator insert(const T &value)
QString & append(QChar ch)
QString fromStdString(const std::string &str)
QString number(int n, int base)