125 // Finds an OpenFile by name or null if not open |
125 // Finds an OpenFile by name or null if not open |
126 LDDocument* FindDocument (QString name); |
126 LDDocument* FindDocument (QString name); |
127 |
127 |
128 // Opens the given file and parses the LDraw code within. Returns a pointer |
128 // Opens the given file and parses the LDraw code within. Returns a pointer |
129 // to the opened file or null on error. |
129 // to the opened file or null on error. |
130 LDDocument* OpenDocument (QString path, bool search, bool implicit, LDDocument* fileToOverride = nullptr); |
130 LDDocument* OpenDocument (QString path, bool search, bool implicit, LDDocument* fileToOverride = nullptr, bool* aborted = nullptr); |
131 |
131 |
132 // Opens the given file and returns a pointer to it, potentially looking in /parts and /p |
132 // Opens the given file and returns a pointer to it, potentially looking in /parts and /p |
133 QFile* OpenLDrawFile (QString relpath, bool subdirs, QString* pathpointer = null); |
133 QFile* OpenLDrawFile (QString relpath, bool subdirs, QString* pathpointer = null); |
134 |
134 |
135 // Close all open files, whether user-opened or subfile caches. |
135 // Close all open files, whether user-opened or subfile caches. |
150 const LDObjectList& selectedObjects(); |
150 const LDObjectList& selectedObjects(); |
151 void AddRecentFile (QString path); |
151 void AddRecentFile (QString path); |
152 void LoadLogoStuds(); |
152 void LoadLogoStuds(); |
153 QString Basename (QString path); |
153 QString Basename (QString path); |
154 QString Dirname (QString path); |
154 QString Dirname (QString path); |
155 |
|
156 // ============================================================================= |
|
157 // |
|
158 // LDFileLoader |
|
159 // |
|
160 // Loads the given file and parses it to LDObjects using parseLine. It's a |
|
161 // separate class so as to be able to do the work progressively through the |
|
162 // event loop, allowing the program to maintain responsivity during loading. |
|
163 // |
|
164 class LDFileLoader : public QObject |
|
165 { |
|
166 Q_OBJECT |
|
167 PROPERTY (private, LDObjectList, objects, setObjects, STOCK_WRITE) |
|
168 PROPERTY (private, bool, isDone, setDone, STOCK_WRITE) |
|
169 PROPERTY (private, int, progress, setProgress, STOCK_WRITE) |
|
170 PROPERTY (private, bool, isAborted, setAborted, STOCK_WRITE) |
|
171 PROPERTY (public, QStringList, lines, setLines, STOCK_WRITE) |
|
172 PROPERTY (public, int*, warnings, setWarnings, STOCK_WRITE) |
|
173 PROPERTY (public, bool, isOnForeground, setOnForeground, STOCK_WRITE) |
|
174 |
|
175 public slots: |
|
176 void start(); |
|
177 void abort(); |
|
178 |
|
179 private: |
|
180 OpenProgressDialog* dlg; |
|
181 |
|
182 private slots: |
|
183 void work (int i); |
|
184 |
|
185 signals: |
|
186 void progressUpdate (int progress); |
|
187 void workDone(); |
|
188 }; |
|