HAL
action_set_object_color.cpp
Go to the documentation of this file.
5 #include "gui/gui_globals.h"
6 
7 namespace hal
8 {
10  : UserActionFactory("SetObjectColor") {;}
11 
13 
15  {
16  return new ActionSetObjectColor;
17  }
18 
20  {
22  }
23 
25  {
26  cryptoHash.addData((char*)(&mColor),sizeof(mColor));
27  }
28 
30  {
31  xmlOut.writeTextElement("color", mColor.name(QColor::HexArgb));
32  }
33 
35  {
36  while (xmlIn.readNextStartElement())
37  {
38  if (xmlIn.name() == "color")
39  mColor = QColor(xmlIn.readElementText());
40  }
41  }
42 
44  {
45  QColor oldColor;
46 
47  switch (mObject.type())
48  {
51 
52  // Set module color will fire moduleColorChanged event.
53  // However, gGraphContextManager is not in the receiver list and has to be updated manually
55  break;
58  recolorGrouping(mObject.id(), mColor);
59  break;
60  default:
61  return false;
62  }
63  if (oldColor.isValid())
64  {
65  ActionSetObjectColor* act = new ActionSetObjectColor(oldColor);
66  act->setObject(mObject);
67  mUndoAction = act;
68  }
69 
70  return UserAction::exec();
71  }
72 }
UserActionFactory for ActionSetObjectColor.
static ActionSetObjectColorFactory * sFactory
void writeToXml(QXmlStreamWriter &xmlOut) const override
void readFromXml(QXmlStreamReader &xmlIn) override
void addToHash(QCryptographicHash &cryptoHash) const override
ActionSetObjectColor(const QColor &col=QColor())
QString tagname() const override
GroupingManagerWidget * getGroupingManagerWidget()
void handleModuleColorChanged(Module *m) const
GroupingTableModel * getModel() const
QColor setModuleColor(u32 id, const QColor &col)
Module * get_module_by_id(u32 module_id) const
Definition: netlist.cpp:613
ModuleColorManager * getModuleColorManager() const
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
ContentManager * gContentManager
Definition: plugin_gui.cpp:78
GraphContextManager * gGraphContextManager
Definition: plugin_gui.cpp:85
Netlist * gNetlist
Definition: plugin_gui.cpp:80
NetlistRelay * gNetlistRelay
Definition: plugin_gui.cpp:81
bool isValid() const const
QString name() const const
void addData(const char *data, int length)
QStringRef name() const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
bool readNextStartElement()
void writeTextElement(const QString &qualifiedName, const QString &text)