src/ldDocument.h

changeset 789
4b7306f52bb5
parent 784
f82ab4d3c7b4
child 794
c254ddc6618b
equal deleted inserted replaced
788:c9d1dad83ad0 789:4b7306f52bb5
29 class GLCompiler; 29 class GLCompiler;
30 30
31 namespace LDPaths 31 namespace LDPaths
32 { 32 {
33 void initPaths(); 33 void initPaths();
34 bool tryConfigure (String path); 34 bool tryConfigure (QString path);
35 35
36 String ldconfig(); 36 QString ldconfig();
37 String prims(); 37 QString prims();
38 String parts(); 38 QString parts();
39 String getError(); 39 QString getError();
40 } 40 }
41 41
42 // 42 //
43 // Flags for LDDocument 43 // Flags for LDDocument
44 // 44 //
63 class LDDocument : public QObject 63 class LDDocument : public QObject
64 { 64 {
65 public: 65 public:
66 using KnownVertexMap = QMap<Vertex, int>; 66 using KnownVertexMap = QMap<Vertex, int>;
67 67
68 PROPERTY (public, String, name, setName, STOCK_WRITE) 68 PROPERTY (public, QString, name, setName, STOCK_WRITE)
69 PROPERTY (private, LDObjectList, objects, setObjects, STOCK_WRITE) 69 PROPERTY (private, LDObjectList, objects, setObjects, STOCK_WRITE)
70 PROPERTY (private, LDObjectList, cache, setCache, STOCK_WRITE) 70 PROPERTY (private, LDObjectList, cache, setCache, STOCK_WRITE)
71 PROPERTY (private, History*, history, setHistory, STOCK_WRITE) 71 PROPERTY (private, History*, history, setHistory, STOCK_WRITE)
72 PROPERTY (private, KnownVertexMap, vertices, setVertices, STOCK_WRITE) 72 PROPERTY (private, KnownVertexMap, vertices, setVertices, STOCK_WRITE)
73 PROPERTY (public, String, fullPath, setFullPath, STOCK_WRITE) 73 PROPERTY (public, QString, fullPath, setFullPath, STOCK_WRITE)
74 PROPERTY (public, String, defaultName, setDefaultName, STOCK_WRITE) 74 PROPERTY (public, QString, defaultName, setDefaultName, STOCK_WRITE)
75 PROPERTY (public, bool, isImplicit, setImplicit, CUSTOM_WRITE) 75 PROPERTY (public, bool, isImplicit, setImplicit, CUSTOM_WRITE)
76 PROPERTY (public, long, savePosition, setSavePosition, STOCK_WRITE) 76 PROPERTY (public, long, savePosition, setSavePosition, STOCK_WRITE)
77 PROPERTY (public, int, tabIndex, setTabIndex, STOCK_WRITE) 77 PROPERTY (public, int, tabIndex, setTabIndex, STOCK_WRITE)
78 PROPERTY (public, QList<LDPolygon>, polygonData, setPolygonData, STOCK_WRITE) 78 PROPERTY (public, QList<LDPolygon>, polygonData, setPolygonData, STOCK_WRITE)
79 PROPERTY (private, LDDocumentFlags, flags, setFlags, STOCK_WRITE) 79 PROPERTY (private, LDDocumentFlags, flags, setFlags, STOCK_WRITE)
85 85
86 int addObject (LDObjectPtr obj); // Adds an object to this file at the end of the file. 86 int addObject (LDObjectPtr obj); // Adds an object to this file at the end of the file.
87 void addObjects (const LDObjectList objs); 87 void addObjects (const LDObjectList objs);
88 void clearSelection(); 88 void clearSelection();
89 void forgetObject (LDObjectPtr obj); // Deletes the given object from the object chain. 89 void forgetObject (LDObjectPtr obj); // Deletes the given object from the object chain.
90 String getDisplayName(); 90 QString getDisplayName();
91 const LDObjectList& getSelection() const; 91 const LDObjectList& getSelection() const;
92 bool hasUnsavedChanges() const; // Does this document have unsaved changes? 92 bool hasUnsavedChanges() const; // Does this document have unsaved changes?
93 void initializeCachedData(); 93 void initializeCachedData();
94 LDObjectList inlineContents (bool deep, bool renderinline); 94 LDObjectList inlineContents (bool deep, bool renderinline);
95 void insertObj (int pos, LDObjectPtr obj); 95 void insertObj (int pos, LDObjectPtr obj);
96 int getObjectCount() const; 96 int getObjectCount() const;
97 LDObjectPtr getObject (int pos) const; 97 LDObjectPtr getObject (int pos) const;
98 bool save (String path = ""); // Saves this file to disk. 98 bool save (QString path = ""); // Saves this file to disk.
99 void swapObjects (LDObjectPtr one, LDObjectPtr other); 99 void swapObjects (LDObjectPtr one, LDObjectPtr other);
100 bool isSafeToClose(); // Perform safety checks. Do this before closing any files! 100 bool isSafeToClose(); // Perform safety checks. Do this before closing any files!
101 void setObject (int idx, LDObjectPtr obj); 101 void setObject (int idx, LDObjectPtr obj);
102 QList<LDPolygon> inlinePolygons(); 102 QList<LDPolygon> inlinePolygons();
103 void vertexChanged (const Vertex& a, const Vertex& b); 103 void vertexChanged (const Vertex& a, const Vertex& b);
148 static void closeInitialFile(); 148 static void closeInitialFile();
149 static int countExplicitFiles(); 149 static int countExplicitFiles();
150 static LDDocumentPtr createNew(); 150 static LDDocumentPtr createNew();
151 151
152 // Turns a full path into a relative path 152 // Turns a full path into a relative path
153 static String shortenName (String a); 153 static QString shortenName (QString a);
154 static QList<LDDocumentPtr> const& explicitDocuments(); 154 static QList<LDDocumentPtr> const& explicitDocuments();
155 155
156 protected: 156 protected:
157 void addToSelection (LDObjectPtr obj); 157 void addToSelection (LDObjectPtr obj);
158 void removeFromSelection (LDObjectPtr obj); 158 void removeFromSelection (LDObjectPtr obj);
185 185
186 // Close all current loaded files and start off blank. 186 // Close all current loaded files and start off blank.
187 void newFile(); 187 void newFile();
188 188
189 // Opens the given file as the main file. Everything is closed first. 189 // Opens the given file as the main file. Everything is closed first.
190 void openMainFile (String path); 190 void openMainFile (QString path);
191 191
192 // Finds an OpenFile by name or null if not open 192 // Finds an OpenFile by name or null if not open
193 LDDocumentPtr findDocument (String name); 193 LDDocumentPtr findDocument (QString name);
194 194
195 // Opens the given file and parses the LDraw code within. Returns a pointer 195 // Opens the given file and parses the LDraw code within. Returns a pointer
196 // to the opened file or null on error. 196 // to the opened file or null on error.
197 LDDocumentPtr openDocument (String path, bool search, bool implicit, LDDocumentPtr fileToOverride = LDDocumentPtr()); 197 LDDocumentPtr openDocument (QString path, bool search, bool implicit, LDDocumentPtr fileToOverride = LDDocumentPtr());
198 198
199 // Opens the given file and returns a pointer to it, potentially looking in /parts and /p 199 // Opens the given file and returns a pointer to it, potentially looking in /parts and /p
200 QFile* openLDrawFile (String relpath, bool subdirs, String* pathpointer = null); 200 QFile* openLDrawFile (QString relpath, bool subdirs, QString* pathpointer = null);
201 201
202 // Close all open files, whether user-opened or subfile caches. 202 // Close all open files, whether user-opened or subfile caches.
203 void closeAll(); 203 void closeAll();
204 204
205 // Parses a string line containing an LDraw object and returns the object parsed. 205 // Parses a string line containing an LDraw object and returns the object parsed.
206 LDObjectPtr parseLine (String line); 206 LDObjectPtr parseLine (QString line);
207 207
208 // Retrieves the pointer to the given document by file name. Document is loaded 208 // Retrieves the pointer to the given document by file name. Document is loaded
209 // from file if necessary. Can return null if neither succeeds. 209 // from file if necessary. Can return null if neither succeeds.
210 LDDocumentPtr getDocument (String filename); 210 LDDocumentPtr getDocument (QString filename);
211 211
212 // Re-caches all subfiles. 212 // Re-caches all subfiles.
213 void reloadAllSubfiles(); 213 void reloadAllSubfiles();
214 214
215 // Is it safe to close all files? 215 // Is it safe to close all files?
220 inline const LDObjectList& selection() 220 inline const LDObjectList& selection()
221 { 221 {
222 return getCurrentDocument()->getSelection(); 222 return getCurrentDocument()->getSelection();
223 } 223 }
224 224
225 void addRecentFile (String path); 225 void addRecentFile (QString path);
226 void loadLogoedStuds(); 226 void loadLogoedStuds();
227 String basename (String path); 227 QString basename (QString path);
228 String dirname (String path); 228 QString dirname (QString path);
229 229
230 // ============================================================================= 230 // =============================================================================
231 // 231 //
232 // LDFileLoader 232 // LDFileLoader
233 // 233 //

mercurial