39 enum { MAX_RECENT_FILES = 10 }; |
39 enum { MAX_RECENT_FILES = 10 }; |
40 static bool g_aborted = false; |
40 static bool g_aborted = false; |
41 static LDDocument* g_logoedStud; |
41 static LDDocument* g_logoedStud; |
42 static LDDocument* g_logoedStud2; |
42 static LDDocument* g_logoedStud2; |
43 static bool g_loadingLogoedStuds = false; |
43 static bool g_loadingLogoedStuds = false; |
44 |
|
45 const QStringList g_specialSubdirectories ({ "s", "48", "8" }); |
44 const QStringList g_specialSubdirectories ({ "s", "48", "8" }); |
46 |
45 |
47 // ============================================================================= |
|
48 // |
|
49 LDDocument::LDDocument (QObject* parent) : |
46 LDDocument::LDDocument (QObject* parent) : |
50 QObject (parent), |
47 QObject (parent), |
51 HierarchyElement (parent), |
48 HierarchyElement (parent), |
52 m_history (new History), |
49 m_history (new History), |
53 m_isImplicit (true), |
50 m_isCache (true), |
54 m_flags (0), |
|
55 m_verticesOutdated (true), |
51 m_verticesOutdated (true), |
56 m_needVertexMerge (true), |
52 m_needVertexMerge (true), |
|
53 m_beingDestroyed (false), |
57 m_gldata (new LDGLData) |
54 m_gldata (new LDGLData) |
58 { |
55 { |
59 setSavePosition (-1); |
56 setSavePosition (-1); |
60 setTabIndex (-1); |
57 setTabIndex (-1); |
61 m_history->setDocument (this); |
58 m_history->setDocument (this); |
62 m_needsReCache = true; |
59 m_needsReCache = true; |
63 } |
60 } |
64 |
61 |
65 // ============================================================================= |
|
66 // |
|
67 LDDocument::~LDDocument() |
62 LDDocument::~LDDocument() |
68 { |
63 { |
69 m_flags |= DOCF_IsBeingDestroyed; |
64 m_beingDestroyed = true; |
70 delete m_history; |
65 delete m_history; |
71 delete m_gldata; |
66 delete m_gldata; |
72 } |
67 } |
73 |
68 |
74 // ============================================================================= |
69 QString LDDocument::name() const |
75 // |
70 { |
76 void LDDocument::setImplicit (bool const& a) |
71 return m_name; |
77 { |
72 } |
78 if (m_isImplicit != a) |
73 |
79 { |
74 void LDDocument::setName (QString value) |
80 m_isImplicit = a; |
75 { |
81 |
76 m_name = value; |
82 if (a == false) |
77 } |
83 { |
78 |
84 print ("Opened %1", name()); |
79 const LDObjectList& LDDocument::objects() const |
85 |
80 { |
86 // Implicit files are not compiled by the GL renderer. Now that this |
81 return m_objects; |
87 // part is no longer implicit, it needs to be compiled. |
82 } |
88 m_window->R()->compiler()->compileDocument (this); |
83 |
89 } |
84 History* LDDocument::history() const |
90 else |
85 { |
91 { |
86 return m_history; |
92 print ("Closed %1", name()); |
87 } |
93 } |
88 |
94 |
89 QString LDDocument::fullPath() |
|
90 { |
|
91 return m_fullPath; |
|
92 } |
|
93 |
|
94 void LDDocument::setFullPath (QString value) |
|
95 { |
|
96 m_fullPath = value; |
|
97 } |
|
98 |
|
99 int LDDocument::tabIndex() const |
|
100 { |
|
101 return m_tabIndex; |
|
102 } |
|
103 |
|
104 void LDDocument::setTabIndex (int value) |
|
105 { |
|
106 m_tabIndex = value; |
|
107 } |
|
108 |
|
109 const QList<LDPolygon>& LDDocument::polygonData() const |
|
110 { |
|
111 return m_polygonData; |
|
112 } |
|
113 |
|
114 long LDDocument::savePosition() const |
|
115 { |
|
116 return m_savePosition; |
|
117 } |
|
118 |
|
119 void LDDocument::setSavePosition (long value) |
|
120 { |
|
121 m_savePosition = value; |
|
122 } |
|
123 |
|
124 QString LDDocument::defaultName() const |
|
125 { |
|
126 return m_defaultName; |
|
127 } |
|
128 |
|
129 void LDDocument::setDefaultName (QString value) |
|
130 { |
|
131 m_defaultName = value; |
|
132 } |
|
133 |
|
134 void LDDocument::openForEditing() |
|
135 { |
|
136 if (m_isCache) |
|
137 { |
|
138 m_isCache = false; |
|
139 print ("Opened %1", name()); |
|
140 |
|
141 // Cache files are not compiled by the GL renderer. Now that this file is open for editing, it needs to be |
|
142 // compiled. |
|
143 m_window->R()->compiler()->compileDocument (this); |
95 m_window->updateDocumentList(); |
144 m_window->updateDocumentList(); |
|
145 } |
|
146 } |
|
147 |
|
148 bool LDDocument::isCache() const |
|
149 { |
|
150 return m_isCache; |
|
151 } |
|
152 |
|
153 void LDDocument::addHistoryStep() |
|
154 { |
|
155 history()->addStep(); |
|
156 } |
|
157 |
|
158 void LDDocument::undo() |
|
159 { |
|
160 history()->undo(); |
|
161 } |
|
162 |
|
163 void LDDocument::redo() |
|
164 { |
|
165 history()->redo(); |
|
166 } |
|
167 |
|
168 void LDDocument::clearHistory() |
|
169 { |
|
170 history()->clear(); |
|
171 } |
|
172 |
|
173 void LDDocument::addToHistory (AbstractHistoryEntry* entry) |
|
174 { |
|
175 *history() << entry; |
|
176 } |
|
177 |
|
178 void LDDocument::close() |
|
179 { |
|
180 if (not isCache()) |
|
181 { |
|
182 m_isCache = true; |
|
183 print ("Closed %1", name()); |
|
184 m_window->updateDocumentList(); |
96 |
185 |
97 // If the current document just became implicit (i.e. user closed it), we need to get a new one to show. |
186 // If the current document just became implicit (i.e. user closed it), we need to get a new one to show. |
98 if (currentDocument() == this and a) |
187 if (currentDocument() == this) |
99 m_window->currentDocumentClosed(); |
188 m_window->currentDocumentClosed(); |
100 } |
189 } |
|
190 } |
|
191 |
|
192 LDGLData* LDDocument::glData() |
|
193 { |
|
194 return m_gldata; |
101 } |
195 } |
102 |
196 |
103 // ============================================================================= |
197 // ============================================================================= |
104 // |
198 // |
105 LDDocument* FindDocument (QString name) |
199 LDDocument* FindDocument (QString name) |