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 QList<LDObject*> objs); |
71 void addObjects (const QList<LDObject*> objs); |
|
72 void clearSelection(); |
72 void forgetObject (LDObject* obj); // Deletes the given object from the object chain. |
73 void forgetObject (LDObject* obj); // Deletes the given object from the object chain. |
73 str getShortName(); |
74 str getShortName(); |
|
75 const QList<LDObject*>& selection() const; |
74 bool hasUnsavedChanges() const; // Does this file have unsaved changes? |
76 bool hasUnsavedChanges() const; // Does this file have unsaved changes? |
75 QList<LDObject*> inlineContents (LDSubfile::InlineFlags flags); |
77 QList<LDObject*> inlineContents (LDSubfile::InlineFlags flags); |
76 void insertObj (int pos, LDObject* obj); |
78 void insertObj (int pos, LDObject* obj); |
77 int numObjs() const; |
79 int numObjs() const; |
78 LDObject* object (int pos) const; |
80 LDObject* object (int pos) const; |
114 static LDFile* current(); |
116 static LDFile* current(); |
115 static void setCurrent (LDFile* f); |
117 static void setCurrent (LDFile* f); |
116 static void closeInitialFile(); |
118 static void closeInitialFile(); |
117 static int countExplicitFiles(); |
119 static int countExplicitFiles(); |
118 |
120 |
|
121 protected: |
|
122 void addToSelection (LDObject* obj); |
|
123 void removeFromSelection (LDObject* obj); |
|
124 friend class LDObject; |
|
125 |
119 private: |
126 private: |
120 static LDFile* m_curfile; |
127 QList<LDObject*> m_sel; |
|
128 |
|
129 static LDFile* m_curfile; |
121 }; |
130 }; |
122 |
131 |
123 // Close all current loaded files and start off blank. |
132 // Close all current loaded files and start off blank. |
124 void newFile(); |
133 void newFile(); |
125 |
134 |
152 bool safeToCloseAll(); |
161 bool safeToCloseAll(); |
153 |
162 |
154 QList<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok = null); |
163 QList<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok = null); |
155 |
164 |
156 extern QList<LDFile*> g_loadedFiles; |
165 extern QList<LDFile*> g_loadedFiles; |
|
166 |
|
167 inline const QList<LDObject*>& selection() |
|
168 { return LDFile::current()->selection(); |
|
169 } |
157 |
170 |
158 void addRecentFile (str path); |
171 void addRecentFile (str path); |
159 void loadLogoedStuds(); |
172 void loadLogoedStuds(); |
160 str basename (str path); |
173 str basename (str path); |
161 str dirname (str path); |
174 str dirname (str path); |
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
167 // ============================================================================= |
180 // ============================================================================= |
168 // FileLoader |
181 // FileLoader |
169 // |
182 // |
170 // Loads the given file and parses it to LDObjects using parseLine. It's a |
183 // 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. |
184 // separate class so as to be able to do the work progressively through the |
|
185 // event loop, allowing the program to maintain responsivity during loading. |
172 // ============================================================================= |
186 // ============================================================================= |
173 class FileLoader : public QObject |
187 class FileLoader : public QObject |
174 { Q_OBJECT |
188 { Q_OBJECT |
175 READ_PROPERTY (QList<LDObject*>, objs, setObjects) |
189 READ_PROPERTY (QList<LDObject*>, objs, setObjects) |
176 READ_PROPERTY (bool, done, setDone) |
190 READ_PROPERTY (bool, done, setDone) |