HAL
action_open_netlist_file.cpp
Go to the documentation of this file.
3 
4 namespace hal
5 {
6  const char* sOpenMethodsPersist[] = {"Undefined", "CreateNew", "ImportFile", "OpenProject", nullptr};
7 
9  : UserActionFactory("OpenNetlistFile") {;}
10 
12 
14  {
15  return new ActionOpenNetlistFile;
16  }
17 
19  {
21  }
22 
24  : mFilename(filename_), mMethod(method)
25  {
26  mProjectModified = false;
27  }
28 
30  {
31  switch (mMethod)
32  {
33  case Undefined:
34  return false;
35  case CreateNew:
37  break;
38  case ImportFile:
40  break;
41  case OpenProject:
43  break;
44  }
45  return UserAction::exec();
46  }
47 
49  {
50  cryptoHash.addData(mFilename.toUtf8());
51  cryptoHash.addData((char*) &mMethod, sizeof(mMethod));
52  }
53 
55  {
56  xmlOut.writeTextElement("filename", mFilename);
57  xmlOut.writeTextElement("method", sOpenMethodsPersist[mMethod]);
58  }
59 
61  {
62  mMethod = Undefined;
63  while (xmlIn.readNextStartElement())
64  {
65  if (xmlIn.name() == "filename")
66  mFilename = xmlIn.readElementText();
67  if (xmlIn.name() == "method")
68  {
69  QString meth = xmlIn.readElementText();
70  for (int i=0; sOpenMethodsPersist[i]; i++)
71  if (sOpenMethodsPersist[i] == meth)
72  {
73  mMethod = static_cast<OpenMethod>(i);
74  break;
75  }
76  }
77  }
78  }
79 }
UserActionFactory for ActionOpenNetlistFile.
static ActionOpenNetlistFileFactory * sFactory
void readFromXml(QXmlStreamReader &xmlIn) override
QString tagname() const override
ActionOpenNetlistFile(OpenMethod method=Undefined, const QString &filename_=QString())
void writeToXml(QXmlStreamWriter &xmlOut) const override
void addToHash(QCryptographicHash &cryptoHash) const override
void importFile(QString filename)
void openProject(QString projPath)
static FileManager * get_instance()
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 bool exec()
Definition: user_action.cpp:23
const char * sOpenMethodsPersist[]
void addData(const char *data, int length)
QByteArray toUtf8() const const
QStringRef name() const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
bool readNextStartElement()
void writeTextElement(const QString &qualifiedName, const QString &text)