Mon, 15 Jul 2013 22:32:23 +0300
moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
| 376 | 4 | * |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
| 376 | 9 | * |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
| 376 | 14 | * |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #ifndef FILE_H |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #define FILE_H |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "common.h" |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "ldtypes.h" |
|
265
955c0aabfebf
Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
24 | #include "history.h" |
|
248
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
25 | #include <QObject> |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
|
265
955c0aabfebf
Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
254
diff
changeset
|
27 | class History; |
|
249
6b2cc2d82ba6
Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents:
248
diff
changeset
|
28 | class OpenProgressDialog; |
|
290
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
29 | |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | namespace LDPaths { |
| 376 | 31 | void initPaths(); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | bool tryConfigure (str path); |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
| 376 | 34 | str ldconfig(); |
| 35 | str prims(); | |
| 36 | str parts(); | |
| 37 | str getError(); | |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | } |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | // ============================================================================= |
|
232
4e44c92e21dd
Renamed the OpenFile class to LDOpenFile as MinGW doesn't appear to like the former name
Santeri Piippo <crimsondusk64@gmail.com>
parents:
226
diff
changeset
|
41 | // LDOpenFile |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | // |
|
232
4e44c92e21dd
Renamed the OpenFile class to LDOpenFile as MinGW doesn't appear to like the former name
Santeri Piippo <crimsondusk64@gmail.com>
parents:
226
diff
changeset
|
43 | // The LDOpenFile class stores a file opened in LDForge either as a editable file |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | // for the user or for subfile caching. Its methods handle file input and output. |
| 376 | 45 | // |
|
250
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
46 | // A file is implicit when they are opened automatically for caching purposes |
|
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
47 | // and are hidden from the user. User-opened files are explicit (not implicit). |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | // ============================================================================= |
|
379
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
49 | class LDOpenFile : public QObject { |
|
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
50 | Q_OBJECT |
|
383
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
51 | READ_PROPERTY (vector<LDObject*>, objs, setObjects) |
|
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
52 | READ_PROPERTY (History, history, setHistory) |
|
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
53 | READ_PROPERTY (vector<LDObject*>, vertices, setVertices) |
|
250
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
54 | PROPERTY (str, name, setName) |
|
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
55 | PROPERTY (bool, implicit, setImplicit) |
|
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
56 | PROPERTY (vector<LDObject*>, cache, setCache) |
|
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
57 | PROPERTY (long, savePos, setSavePos) |
|
383
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
58 | DECLARE_PROPERTY (QListWidgetItem*, listItem, setListItem) |
|
250
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
59 | |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | public: |
|
269
2d71227f35cb
Refactor LDSubfile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
61 | typedef vector<LDObject*>::it it; |
|
2d71227f35cb
Refactor LDSubfile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
62 | typedef vector<LDObject*>::c_it c_it; |
|
2d71227f35cb
Refactor LDSubfile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
63 | |
| 376 | 64 | LDOpenFile(); |
| 65 | ~LDOpenFile(); | |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
|
383
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
67 | ulong addObject (LDObject* obj); // Adds an object to this file at the end of the file. |
|
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
68 | void forgetObject (LDObject* obj); // Deletes the given object from the object chain. |
|
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
69 | bool hasUnsavedChanges() const; // Does this file have unsaved changes? |
|
379
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
70 | void insertObj (const ulong pos, LDObject* obj); |
|
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
71 | ulong numObjs() const; |
| 309 | 72 | LDObject* object (ulong pos) const; |
|
379
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
73 | LDObject* obj (ulong pos) const; |
|
383
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
74 | bool save (str path = ""); // Saves this file to disk. |
|
10e60ae9ed58
File list is populated now..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
381
diff
changeset
|
75 | bool safeToClose(); // Perform safety checks. Do this before closing any files! |
|
250
6e80f038e8df
Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents:
249
diff
changeset
|
76 | void setObject (ulong idx, LDObject* obj); |
| 376 | 77 | |
|
274
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
78 | LDOpenFile& operator<< (LDObject* obj) { |
|
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
79 | addObject (obj); |
|
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
80 | return *this; |
|
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
81 | } |
|
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
82 | |
| 376 | 83 | LDOpenFile& operator<< (vector<LDObject*> objs); |
| 84 | ||
| 85 | it begin() { | |
| 86 | return PROP_NAME (objs).begin(); | |
| 87 | } | |
| 88 | ||
| 89 | c_it begin() const { | |
| 90 | return PROP_NAME (objs).begin(); | |
| 91 | } | |
|
310
c62edce5668c
Begin converting the radial type into a primitive generator
Santeri Piippo <crimsondusk64@gmail.com>
parents:
309
diff
changeset
|
92 | |
| 376 | 93 | it end() { |
| 94 | return PROP_NAME (objs).end(); | |
| 95 | } | |
| 96 | ||
| 97 | c_it end() const { | |
| 98 | return PROP_NAME (objs).end(); | |
| 99 | } | |
| 100 | ||
| 101 | static void closeUnused(); | |
|
269
2d71227f35cb
Refactor LDSubfile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
102 | |
| 376 | 103 | void openHistory() { |
| 104 | m_history.open(); | |
| 105 | } | |
| 106 | ||
| 107 | void closeHistory() { | |
| 108 | m_history.close(); | |
| 109 | } | |
| 110 | ||
| 111 | void undo() { | |
| 112 | m_history.undo(); | |
| 113 | } | |
|
274
d232fe4d88a6
Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
271
diff
changeset
|
114 | |
| 376 | 115 | void redo() { |
| 116 | m_history.redo(); | |
| 117 | } | |
| 118 | ||
| 119 | void clearHistory() { | |
| 120 | m_history.clear(); | |
| 121 | } | |
| 122 | ||
| 123 | void addToHistory (AbstractHistoryEntry* entry) { | |
| 124 | m_history << entry; | |
| 125 | } | |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | }; |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | // Close all current loaded files and start off blank. |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
129 | void newFile(); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | // Opens the given file as the main file. Everything is closed first. |
| 376 | 132 | void openMainFile (str path); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | // Finds an OpenFile by name or null if not open |
| 376 | 135 | LDOpenFile* findLoadedFile (str name); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | // Opens the given file and parses the LDraw code within. Returns a pointer |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | // to the opened file or null on error. |
| 376 | 139 | LDOpenFile* openDATFile (str path, bool search); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | // Opens the given file and returns a pointer to it, potentially looking in /parts and /p |
| 376 | 142 | File* openLDrawFile (str relpath, bool subdirs); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | // Close all open files, whether user-opened or subfile caches. |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
145 | void closeAll(); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | // Parses a string line containing an LDraw object and returns the object parsed. |
| 376 | 148 | LDObject* parseLine (str line); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | // Retrieves the pointer to - or loads - the given subfile. |
| 376 | 151 | LDOpenFile* getFile (str filename); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
|
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | // Re-caches all subfiles. |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
154 | void reloadAllSubfiles(); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | |
|
226
3dd9e63698cd
Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
220
diff
changeset
|
156 | // Is it safe to close all files? |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
157 | bool safeToCloseAll(); |
|
226
3dd9e63698cd
Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
220
diff
changeset
|
158 | |
| 376 | 159 | vector<LDObject*> loadFileContents (File* f, ulong* numWarnings, bool* ok = null); |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | |
|
232
4e44c92e21dd
Renamed the OpenFile class to LDOpenFile as MinGW doesn't appear to like the former name
Santeri Piippo <crimsondusk64@gmail.com>
parents:
226
diff
changeset
|
161 | extern vector<LDOpenFile*> g_loadedFiles; |
|
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
| 376 | 163 | void addRecentFile (str path); |
| 164 | str basename (str path); | |
| 165 | str dirname (str path); | |
|
379
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
166 | LDOpenFile* currentFile(); |
|
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
167 | void setCurrentFile (LDOpenFile* f); |
|
234
79b120b0aa51
added basename since windows doesn't have it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
232
diff
changeset
|
168 | |
|
381
241f65769a57
restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
169 | extern vector<LDOpenFile*> g_loadedFiles; // Vector of all currently opened files. |
|
241f65769a57
restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
170 | |
|
290
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
171 | // ============================================================================= |
|
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
172 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
173 | // ============================================================================= |
|
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
174 | // FileLoader |
| 376 | 175 | // |
|
290
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
176 | // Loads the given file and parses it to LDObjects using parseLine. It's a |
|
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
177 | // separate class so as to be able to do the work in a separate thread. |
|
be0c367e7420
Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents:
289
diff
changeset
|
178 | // ============================================================================= |
|
248
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
179 | class FileLoader : public QObject { |
|
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
180 | Q_OBJECT |
| 376 | 181 | READ_PROPERTY (vector<LDObject*>, objs, setObjects) |
| 182 | READ_PROPERTY (bool, done, setDone) | |
| 183 | READ_PROPERTY (ulong, progress, setProgress) | |
| 184 | READ_PROPERTY (bool, aborted, setAborted) | |
| 185 | PROPERTY (vector<str>, lines, setLines) | |
| 186 | PROPERTY (ulong*, warningsPointer, setWarningsPointer) | |
| 187 | PROPERTY (bool, concurrent, setConcurrent) | |
|
248
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
188 | |
|
371
e8ef9fb4721b
make aborting work in the new setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
370
diff
changeset
|
189 | public slots: |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
190 | void start(); |
|
371
e8ef9fb4721b
make aborting work in the new setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
370
diff
changeset
|
191 | void abort(); |
|
248
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
192 | |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
193 | private: |
|
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
194 | OpenProgressDialog* dlg; |
|
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
195 | |
|
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
196 | private slots: |
| 376 | 197 | void work (ulong i); |
|
248
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
198 | |
|
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
199 | signals: |
| 376 | 200 | void progressUpdate (int progress); |
|
370
843b3dbbd849
make file loading be done properly as just a QObject rather than multi-threaded..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
310
diff
changeset
|
201 | void workDone(); |
|
248
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
202 | }; |
|
4431371f3ffe
Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
236
diff
changeset
|
203 | |
|
379
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
204 | void changeCurrentFile (LDOpenFile* f); |
|
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
205 | |
|
f5f3faac60cd
Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
376
diff
changeset
|
206 | #endif // FILE_H |