51 // The default name is a placeholder, initially suggested name for a file. The |
51 // The default name is a placeholder, initially suggested name for a file. The |
52 // primitive generator uses this to give initial names to primitives. |
52 // primitive generator uses this to give initial names to primitives. |
53 // ============================================================================= |
53 // ============================================================================= |
54 class LDFile : public QObject |
54 class LDFile : public QObject |
55 { Q_OBJECT |
55 { Q_OBJECT |
56 READ_PROPERTY (List<LDObject*>, objects, setObjects) |
56 READ_PROPERTY (QList<LDObject*>, objects, setObjects) |
57 READ_PROPERTY (History, history, setHistory) |
57 READ_PROPERTY (History, history, setHistory) |
58 READ_PROPERTY (List<LDObject*>, vertices, setVertices) |
58 READ_PROPERTY (QList<LDObject*>, vertices, setVertices) |
59 PROPERTY (str, name, setName) |
59 PROPERTY (str, name, setName) |
60 PROPERTY (str, defaultName, setDefaultName) |
60 PROPERTY (str, defaultName, setDefaultName) |
61 PROPERTY (bool, implicit, setImplicit) |
61 PROPERTY (bool, implicit, setImplicit) |
62 PROPERTY (List<LDObject*>, cache, setCache) |
62 PROPERTY (QList<LDObject*>, cache, setCache) |
63 PROPERTY (long, savePos, setSavePos) |
63 PROPERTY (long, savePos, setSavePos) |
64 DECLARE_PROPERTY (QListWidgetItem*, listItem, setListItem) |
64 DECLARE_PROPERTY (QListWidgetItem*, listItem, setListItem) |
65 |
65 |
66 public: |
66 public: |
67 LDFile(); |
67 LDFile(); |
68 ~LDFile(); |
68 ~LDFile(); |
69 |
69 |
70 int addObject (LDObject* obj); // Adds an object to this file at the end of the file. |
70 int addObject (LDObject* obj); // Adds an object to this file at the end of the file. |
71 void addObjects (const List<LDObject*> objs); |
71 void addObjects (const QList<LDObject*> objs); |
72 void forgetObject (LDObject* obj); // Deletes the given object from the object chain. |
72 void forgetObject (LDObject* obj); // Deletes the given object from the object chain. |
73 str getShortName(); |
73 str getShortName(); |
74 bool hasUnsavedChanges() const; // Does this file have unsaved changes? |
74 bool hasUnsavedChanges() const; // Does this file have unsaved changes? |
75 List<LDObject*> inlineContents (LDSubfile::InlineFlags flags); |
75 QList<LDObject*> inlineContents (LDSubfile::InlineFlags flags); |
76 void insertObj (int pos, LDObject* obj); |
76 void insertObj (int pos, LDObject* obj); |
77 int numObjs() const; |
77 int numObjs() const; |
78 LDObject* object (int pos) const; |
78 LDObject* object (int pos) const; |
79 LDObject* obj (int pos) const; |
79 LDObject* obj (int pos) const; |
80 bool save (str path = ""); // Saves this file to disk. |
80 bool save (str path = ""); // Saves this file to disk. |
149 void reloadAllSubfiles(); |
149 void reloadAllSubfiles(); |
150 |
150 |
151 // Is it safe to close all files? |
151 // Is it safe to close all files? |
152 bool safeToCloseAll(); |
152 bool safeToCloseAll(); |
153 |
153 |
154 List<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok = null); |
154 QList<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok = null); |
155 |
155 |
156 extern List<LDFile*> g_loadedFiles; |
156 extern QList<LDFile*> g_loadedFiles; |
157 |
157 |
158 void addRecentFile (str path); |
158 void addRecentFile (str path); |
159 void loadLogoedStuds(); |
159 void loadLogoedStuds(); |
160 str basename (str path); |
160 str basename (str path); |
161 str dirname (str path); |
161 str dirname (str path); |
162 |
162 |
163 extern List<LDFile*> g_loadedFiles; // Vector of all currently opened files. |
163 extern QList<LDFile*> g_loadedFiles; // Vector of all currently opened files. |
164 |
164 |
165 // ============================================================================= |
165 // ============================================================================= |
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
167 // ============================================================================= |
167 // ============================================================================= |
168 // FileLoader |
168 // FileLoader |
170 // Loads the given file and parses it to LDObjects using parseLine. It's a |
170 // Loads the given file and parses it to LDObjects using parseLine. It's a |
171 // separate class so as to be able to do the work in a separate thread. |
171 // separate class so as to be able to do the work in a separate thread. |
172 // ============================================================================= |
172 // ============================================================================= |
173 class FileLoader : public QObject |
173 class FileLoader : public QObject |
174 { Q_OBJECT |
174 { Q_OBJECT |
175 READ_PROPERTY (List<LDObject*>, objs, setObjects) |
175 READ_PROPERTY (QList<LDObject*>, objs, setObjects) |
176 READ_PROPERTY (bool, done, setDone) |
176 READ_PROPERTY (bool, done, setDone) |
177 READ_PROPERTY (int, progress, setProgress) |
177 READ_PROPERTY (int, progress, setProgress) |
178 READ_PROPERTY (bool, aborted, setAborted) |
178 READ_PROPERTY (bool, aborted, setAborted) |
179 PROPERTY (List<str>, lines, setLines) |
179 PROPERTY (QList<str>, lines, setLines) |
180 PROPERTY (int*, warningsPointer, setWarningsPointer) |
180 PROPERTY (int*, warningsPointer, setWarningsPointer) |
181 PROPERTY (bool, concurrent, setConcurrent) |
181 PROPERTY (bool, concurrent, setConcurrent) |
182 |
182 |
183 public slots: |
183 public slots: |
184 void start(); |
184 void start(); |