Thu, 12 Dec 2013 19:44:09 +0200
- LDFile renamed to LDDocument, file.h -> document.h
- Added the INSTALL document
553
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #ifndef LDFORGE_DOCUMENT_H |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #define LDFORGE_DOCUMENT_H |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "main.h" |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "ldtypes.h" |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "history.h" |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QObject> |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | class History; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class OpenProgressDialog; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | namespace LDPaths |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | { void initPaths(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | bool tryConfigure (str path); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | str ldconfig(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | str prims(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | str parts(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | str getError(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | // ============================================================================= |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | // LDDocument |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | // |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | // The LDDocument class stores a document opened in LDForge either as a editable |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | // file for the user or for subfile caching. Its methods handle file input and |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | // output. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | // |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | // A file is implicit when they are opened automatically for caching purposes |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | // and are hidden from the user. User-opened files are explicit (not implicit). |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | // |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // The default name is a placeholder, initially suggested name for a file. The |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | // primitive generator uses this to give initial names to primitives. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | // ============================================================================= |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | class LDDocument : public QObject |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { properties: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | Q_OBJECT |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | PROPERTY (private, QList<LDObject*>, Objects, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | PROPERTY (private, History*, History, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | PROPERTY (private, QList<LDObject*>, Vertices, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | PROPERTY (public, str, Name, STR_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | PROPERTY (public, str, DefaultName, STR_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | PROPERTY (public, bool, Implicit, BOOL_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | PROPERTY (public, QList<LDObject*>, Cache, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | PROPERTY (public, long, SavePosition, NUM_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | PROPERTY (public, QListWidgetItem*, ListItem, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | public: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | LDDocument(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | ~LDDocument(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | int addObject (LDObject* obj); // Adds an object to this file at the end of the file. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | void addObjects (const QList<LDObject*> objs); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | void clearSelection(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | void forgetObject (LDObject* obj); // Deletes the given object from the object chain. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | str getShortName(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | const QList<LDObject*>& getSelection() const; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | bool hasUnsavedChanges() const; // Does this document.have unsaved changes? |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | QList<LDObject*> inlineContents (LDSubfile::InlineFlags flags); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | void insertObj (int pos, LDObject* obj); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | int getObjectCount() const; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | LDObject* getObject (int pos) const; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | bool save (str path = ""); // Saves this file to disk. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | bool isSafeToClose(); // Perform safety checks. Do this before closing any files! |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | void setObject (int idx, LDObject* obj); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | inline LDDocument& operator<< (LDObject* obj) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | { addObject (obj); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | return *this; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | inline void addHistoryStep() |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | { m_History->addStep(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | inline void undo() |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | { m_History->undo(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | inline void redo() |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | { m_History->redo(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | inline void clearHistory() |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | { m_History->clear(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | inline void addToHistory (AbstractHistoryEntry* entry) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | { *m_History << entry; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | static void closeUnused(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | static LDDocument* current(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | static void setCurrent (LDDocument* f); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | static void closeInitialFile(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | static int countExplicitFiles(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | protected: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | void addToSelection (LDObject* obj); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | void removeFromSelection (LDObject* obj); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | friend class LDObject; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | private: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | QList<LDObject*> m_sel; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | static LDDocument* m_curdoc; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | }; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | inline LDDocument* getCurrentDocument() |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | { return LDDocument::current(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | // Close all current loaded files and start off blank. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | void newFile(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | // Opens the given file as the main file. Everything is closed first. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | void openMainFile (str path); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | // Finds an OpenFile by name or null if not open |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | LDDocument* findDocument (str name); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | // Opens the given file and parses the LDraw code within. Returns a pointer |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | // to the opened file or null on error. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | LDDocument* openDocument (str path, bool search); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | // Opens the given file and returns a pointer to it, potentially looking in /parts and /p |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | File* openLDrawFile (str relpath, bool subdirs); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | // Close all open files, whether user-opened or subfile caches. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | void closeAll(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | // Parses a string line containing an LDraw object and returns the object parsed. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | LDObject* parseLine (str line); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | // Retrieves the pointer to the given document by file name. Document is loaded |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | // from file if necessary. Can return null if neither succeeds. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | LDDocument* getDocument (str filename); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | // Re-caches all subfiles. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | void reloadAllSubfiles(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | // Is it safe to close all files? |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | bool safeToCloseAll(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | QList<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok = null); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | extern QList<LDDocument*> g_loadedFiles; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | inline const QList<LDObject*>& selection() |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | { return getCurrentDocument()->getSelection(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | } |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | void addRecentFile (str path); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | void loadLogoedStuds(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | str basename (str path); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | str dirname (str path); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | extern QList<LDDocument*> g_loadedFiles; // Vector of all currently opened files. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | // ============================================================================= |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | // ============================================================================= |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | // FileLoader |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | // |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | // Loads the given file and parses it to LDObjects using parseLine. It's a |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | // separate class so as to be able to do the work progressively through the |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | // event loop, allowing the program to maintain responsivity during loading. |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | // ============================================================================= |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | class LDFileLoader : public QObject |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | { Q_OBJECT |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | PROPERTY (private, QList<LDObject*>, Objects, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | PROPERTY (private, bool, Done, BOOL_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | PROPERTY (private, int, Progress, NUM_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | PROPERTY (private, bool, Aborted, BOOL_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | PROPERTY (public, QStringList, Lines, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | PROPERTY (public, int*, Warnings, NO_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | PROPERTY (public, bool, OnForeground, BOOL_OPS, STOCK_WRITE) |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | public slots: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | void start(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | void abort(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | private: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | OpenProgressDialog* dlg; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | private slots: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | void work (int i); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | signals: |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | void progressUpdate (int progress); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | void workDone(); |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | }; |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | |
2418d5955421
- LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | #endif // LDFORGE_DOCUMENT_H |