HAL
user_action_compound.cpp
Go to the documentation of this file.
3 
4 namespace hal {
6  : UserActionFactory("Compound") {;}
7 
9 
11  {
12  return new UserActionCompound;
13  }
14 
16  {
18  }
19 
21  : mUseCreatedObject(false)
22  {;}
23 
25  {
26  act->setCompoundOrder(mActionList.size());
27  mActionList.append(act);
28  }
29 
31  {
32  LayoutLocker llock;
33  bool first = true;
34  for (UserAction* act : mActionList)
35  {
36  if (mUseCreatedObject && !first){
37  act->setObject(object());
38  }
39  if (!act->exec())
40  return false;
41  if (mUseCreatedObject && first){
42  setObject(act->object());
43  }
44  first = false;
45  }
46  return true;
47  }
48 
50  {
51  xmlOut.writeStartElement("actions");
52  xmlOut.writeAttribute("useCreatedObject",mUseCreatedObject?"true":"false");
53  for (UserAction* act: mActionList)
54  act->writeToXml(xmlOut);
55  xmlOut.writeEndElement();
56  }
57 
59  {
60  bool parseActions = false;
61  while (!xmlIn.atEnd())
62  {
63  if (xmlIn.readNext())
64  {
65  if (xmlIn.isStartElement())
66  {
67  if (xmlIn.name() == "actions")
68  {
69  parseActions = true;
70  mUseCreatedObject = (xmlIn.attributes().value("useCreatedObject")=="true");
71  }
72  else if (parseActions)
73  {
75  if (act) mActionList.append(act);
76  }
77  }
78  else if (xmlIn.isEndElement())
79  {
80  if (xmlIn.name() == "actions")
81  {
82  parseActions = false;
83  return;
84  }
85  }
86  }
87  }
88  }
89 }
static UserActionCompoundFactory * sFactory
void addAction(UserAction *act)
void readFromXml(QXmlStreamReader &xmlIn) override
QString tagname() const override
void writeToXml(QXmlStreamWriter &xmlOut) const override
QList< UserAction * > mActionList
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
virtual void setObject(const UserActionObject &obj)
Definition: user_action.cpp:32
void setCompoundOrder(int cmpord)
Definition: user_action.h:123
static UserActionManager * instance()
UserAction * getParsedAction(QXmlStreamReader &xmlIn) const
QStringRef value(const QString &namespaceUri, const QString &name) const const
bool atEnd() const const
QXmlStreamAttributes attributes() const const
bool isEndElement() const const
bool isStartElement() const const
QStringRef name() const const
QXmlStreamReader::TokenType readNext()
void writeAttribute(const QString &qualifiedName, const QString &value)
void writeEndElement()
void writeStartElement(const QString &qualifiedName)