HAL
action_set_object_type.cpp
Go to the documentation of this file.
2 
3 #include "gui/gui_globals.h"
7 
8 namespace hal
9 {
11  {
12  ;
13  }
14 
16 
18  {
19  return new ActionSetObjectType;
20  }
21 
23  {
25  }
26 
28  {
29  cryptoHash.addData(mObjectType.toUtf8());
30  }
31 
33  {
34  xmlOut.writeTextElement("type", mObjectType);
35  }
36 
38  {
39  while (xmlIn.readNextStartElement())
40  {
41  if (xmlIn.name() == "type")
42  mObjectType = xmlIn.readElementText();
43  }
44  }
45 
47  {
48  QString oldType;
49  Module* mod;
50  switch (mObject.type())
51  {
54  if (mod != nullptr)
55  {
56  oldType = QString::fromStdString(mod->get_type());
57  mod->set_type(mObjectType.toStdString());
58  }
59  else
60  return false;
61  break;
62  default:
63  return false;
64  }
65  mUndoAction = new ActionSetObjectType(oldType);
67  return UserAction::exec();
68  }
69 } // namespace hal
UserActionFactory for ActionSetObjectType.
static ActionSetObjectTypeFactory * sFactory
Assigns a new type to a module.
void readFromXml(QXmlStreamReader &xmlIn) override
QString tagname() const override
ActionSetObjectType(const QString &type=QString())
void addToHash(QCryptographicHash &cryptoHash) const override
void writeToXml(QXmlStreamWriter &xmlOut) const override
void set_type(const std::string &type)
Definition: module.cpp:111
std::string get_type() const
Definition: module.cpp:106
Module * get_module_by_id(u32 module_id) const
Definition: netlist.cpp:613
The UserActionFactory is the abstract base class for registration.
Definition: user_action.h:225
QString tagname() const
Definition: user_action.h:242
The UserAction class is the abstract base class for user interactions.
Definition: user_action.h:57
UserAction * mUndoAction
Definition: user_action.h:186
virtual bool exec()
Definition: user_action.cpp:23
virtual void setObject(const UserActionObject &obj)
Definition: user_action.cpp:32
UserActionObject mObject
Definition: user_action.h:183
UserActionObjectType::ObjectType type() const
Netlist * gNetlist
Definition: plugin_gui.cpp:80
void addData(const char *data, int length)
QString fromStdString(const std::string &str)
std::string toStdString() const const
QByteArray toUtf8() const const
QStringRef name() const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
bool readNextStartElement()
void writeTextElement(const QString &qualifiedName, const QString &text)