VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scriptEditor.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 #include <vrvUtil/signalslib.h>
17 #include <vlutil/vlFilename.h>
19 
20 #include <QObject>
21 #include <QDateTime>
22 #include <QtCore/QProcess>
23 
24 namespace makVrv
25 {
26  class DtDe;
27 }
28 
29 class DtSimMessage;
30 class QProcess;
32 
33 namespace makVrf
34 {
39  {
40  Q_OBJECT
41 
42  public:
44  DtScriptEditor(makVrv::DtDe&, const std::string& tmpDir = "scripts");
45 
47  virtual ~DtScriptEditor();
48 
50  static DtScriptEditor& instance(makVrv::DtDe& de);
51  static void registerInstance(makVrv::DtDe&, DtScriptEditor*);
52 
54  virtual void edit(const std::string&, int scriptType, const std::string& commentBlock = "");
55 
58  virtual void editNew(const std::string& id, int sType, const std::string& script, const std::string& scriptEngine,
59  const std::string& commentBlock = "");
60 
62  virtual void view(const std::string&);
63 
65  virtual void closeEditorFor(const std::string&);
66 
68  virtual bool alreadyEditing(const std::string& id) const;
69 
72  virtual void editExternalScript(const std::string& filename);
73 
75  virtual bool hasScriptFor(const std::string&) const;
76 
78  boost::signal<void (const std::string&, const std::string&)> signal_scriptModified;
79 
80  boost::signal<void (const std::string&)> signal_editingComplete;
81 
82  protected:
83  virtual void slot_scriptSaveError(std::string scriptId);
84 
86  virtual void receivedScript(DtSimMessage*);
87 
89  virtual void slot_aboutToClearScriptedTasks();
90  virtual void slot_scriptedTaskAboutToBeRemoved(std::string scriptId);
91 
93  virtual void editScript(const std::string& id, int sType, const std::string& script,
94  const std::string& scriptEngine = "lua", bool readOnly = false,
95  bool localOnly = false, bool scriptIsFilename = false,
96  const std::string& commentBlock = "");
97 
99  virtual void tick();
100 
103  virtual void checkNeedsUpdate(const std::string& filename);
104 
106  virtual void scriptBeingRemoved();
107 
109  virtual void slot_scriptedTaskAdded(std::string);
110 
112  virtual void editingComplete(QProcess*);
113 
117  virtual bool checkForScriptErrors(const DtScriptedTaskMetaData&) const;
118 
120  virtual std::string cleanUpError(const std::string&) const;
121 
122  protected slots:
123  virtual void editingComplete(int, QProcess::ExitStatus);
124  virtual void startupError(QProcess::ProcessError);
125 
126  protected:
128 
130  {
132  bool viewOnly;
133  bool localOnly;
135  std::string commentBlock;
137  std::string userData;
138  };
139 
140  std::map<DtU32, PendingRequest> myPendingRequests;
141 
142  struct FileInfo
143  {
144  QProcess* editingProcess;
145  QDateTime lastModified;
147  bool readOnly;
148  bool localOnly;
151  std::string scriptEditor;
152  int retries;
154  };
155 
156  typedef std::map<std::string, FileInfo> FileInfoMap;
158 
160 
161  DtFilename myTempDirectory;
162 
163  std::set<std::string> myHasScriptFor;
164  };
165 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)