Thu, 20 Jun 2019 08:54:35 +0300
uuid things
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1326 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QMessageBox> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QFileDialog> |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
21 | #include "lddocument.h" |
998 | 22 | #include "documentmanager.h" |
1295
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
23 | #include "parser.h" |
1318
568fcfc6da71
removed unnecessary files and includes
Teemu Piippo <teemu@hecknology.net>
parents:
1317
diff
changeset
|
24 | #include "editHistory.h" |
568fcfc6da71
removed unnecessary files and includes
Teemu Piippo <teemu@hecknology.net>
parents:
1317
diff
changeset
|
25 | #include "glShared.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
994
diff
changeset
|
27 | LDDocument::LDDocument (DocumentManager* parent) : |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1074
diff
changeset
|
28 | Model {parent}, |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
29 | HierarchyElement (parent), |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
30 | m_history (new EditHistory (this)), |
1015
92c6ec099075
Added triangle count to viewport, added compile-time line length check
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
31 | m_savePosition(-1), |
1424
737df8e904af
removed a duplicate member
Teemu Piippo <teemu@hecknology.net>
parents:
1400
diff
changeset
|
32 | m_tabIndex(-1) |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
33 | { |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
34 | connect( |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
35 | this, |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
36 | SIGNAL(objectAdded(QModelIndex)), |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
37 | this, |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
38 | SLOT(handleNewObject(QModelIndex)) |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
39 | ); |
1280
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
40 | connect( |
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
41 | this, |
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
42 | SIGNAL(aboutToRemoveObject(QModelIndex)), |
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
43 | this, |
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
44 | SLOT(handleImminentObjectRemoval(QModelIndex)), |
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
45 | Qt::DirectConnection |
5c30efc9032b
fixed: LDDocument created one removal connection to the model for each object added, so removing an object from a model of 9 objects added 9 deletion entries to history
Santeri Piippo
parents:
1279
diff
changeset
|
46 | ); |
1377
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
47 | connect( |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
48 | this, |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
49 | &Model::modelChanged, |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
50 | [&]() |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
51 | { |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
52 | this->m_needsRecache = true; |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
53 | } |
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
54 | ); |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
55 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | LDDocument::~LDDocument() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | { |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
59 | m_isBeingDestroyed = true; |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
60 | delete m_history; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
63 | QString LDDocument::name() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
64 | { |
1308
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1306
diff
changeset
|
65 | return this->header.name; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
66 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
67 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
68 | void LDDocument::setName (QString value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
69 | { |
1308
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1306
diff
changeset
|
70 | this->header.name = value; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
71 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
72 | |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
73 | EditHistory* LDDocument::history() const |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
74 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
75 | return m_history; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
76 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
77 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
78 | QString LDDocument::fullPath() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
79 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
80 | return m_fullPath; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
81 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
82 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
83 | void LDDocument::setFullPath (QString value) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | { |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
85 | m_fullPath = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
86 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
87 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
88 | int LDDocument::tabIndex() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
89 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
90 | return m_tabIndex; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
91 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
92 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
93 | void LDDocument::setTabIndex (int value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
94 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
95 | m_tabIndex = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
96 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
97 | |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1384
diff
changeset
|
98 | const QVector<LDPolygon>& LDDocument::polygonData() const |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
99 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
100 | return m_polygonData; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
101 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
102 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
103 | long LDDocument::savePosition() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
104 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
105 | return m_savePosition; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
106 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
107 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
108 | void LDDocument::setSavePosition (long value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
109 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
110 | m_savePosition = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
111 | } |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
112 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
113 | QString LDDocument::defaultName() const |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
114 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
115 | return m_defaultName; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
116 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
117 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
118 | void LDDocument::setDefaultName (QString value) |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
119 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
120 | m_defaultName = value; |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
121 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
122 | |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
123 | void LDDocument::setFrozen(bool value) |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
124 | { |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
125 | m_isFrozen = value; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
126 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
127 | |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
128 | bool LDDocument::isFrozen() const |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
129 | { |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
130 | return m_isFrozen; |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
131 | } |
788
c9d1dad83ad0
- added an action for opening the subfiles pointed to by selected references as editable documents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
132 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
133 | void LDDocument::addHistoryStep() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
134 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
135 | history()->addStep(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
136 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
137 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
138 | void LDDocument::undo() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
139 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
140 | history()->undo(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
141 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
142 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
143 | void LDDocument::redo() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
144 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
145 | history()->redo(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
146 | } |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
147 | |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
148 | void LDDocument::clearHistory() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
149 | { |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
150 | history()->clear(); |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
151 | } |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
152 | |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
153 | void LDDocument::close() |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
154 | { |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
155 | if (not isFrozen()) |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
156 | { |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
157 | setFrozen(true); |
1424
737df8e904af
removed a duplicate member
Teemu Piippo <teemu@hecknology.net>
parents:
1400
diff
changeset
|
158 | documentManager()->documentClosed(this); |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
159 | } |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
160 | } |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
161 | |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
162 | // ============================================================================= |
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
782
diff
changeset
|
163 | // |
979
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
164 | // Performs safety checks. Do this before closing any files! |
880d3fe9ac7c
Refactor LDDocument's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
165 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | bool LDDocument::isSafeToClose() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | setlocale (LC_ALL, "C"); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | // If we have unsaved changes, warn and give the option of saving. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | if (hasUnsavedChanges()) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | { |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
173 | QString message = format(tr("There are unsaved changes to %1. Should it be saved?"), getDisplayName()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
175 | int button = QMessageBox::question (m_window, tr("Unsaved Changes"), message, |
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
176 | (QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel), QMessageBox::Cancel); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | switch (button) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | { |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
180 | case QMessageBox::Yes: |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | // If we don't have a file path yet, we have to ask the user for one. |
1064
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
183 | if (name().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
185 | QString newpath = QFileDialog::getSaveFileName (m_window, QObject::tr ("Save As"), |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
186 | name(), QObject::tr ("LDraw files (*.dat *.ldr)")); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | |
1064
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
188 | if (newpath.isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | setName (newpath); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
194 | if (not save()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | { |
920
147497785496
- fixed stability problems
Teemu Piippo <crimsondusk64@gmail.com>
parents:
902
diff
changeset
|
196 | message = format (QObject::tr ("Failed to save %1 (%2)\nDo you still want to close?"), |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | name(), strerror (errno)); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
199 | if (QMessageBox::critical (m_window, tr("Save Failure"), message, |
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
200 | (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::No) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | } |
744
bbe0e1834065
- removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
205 | break; |
bbe0e1834065
- removed rest of the uses of <anonymous>
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
206 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | |
1156
c20ee66b6705
Removed the Critical and Question functions, replaced with direct QMessageBox uses. Removed unused code from mainwindow.h.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
208 | case QMessageBox::Cancel: |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | return false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | default: |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
219 | static QString headerToString(const Model& model, const LDHeader& header) |
1295
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
220 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
221 | QString result; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
222 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
223 | if (header.type != LDHeader::NoHeader) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
224 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
225 | QString partTypeString; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
226 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
227 | for ( |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
228 | auto iterator = Parser::typeStrings.begin(); |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
229 | iterator != Parser::typeStrings.end(); |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
230 | ++iterator |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
231 | ) { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
232 | if (iterator.value() == header.type) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
233 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
234 | partTypeString += "Unofficial_" + iterator.key(); |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
235 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
236 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
237 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
238 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
239 | if (header.qualfiers & LDHeader::Physical_Color) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
240 | partTypeString += " Physical_Colour"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
241 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
242 | if (header.qualfiers & LDHeader::Flexible_Section) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
243 | partTypeString += " Flexible_Section"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
244 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
245 | if (header.qualfiers & LDHeader::Alias) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
246 | partTypeString += " Alias"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
247 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
248 | result += "0 " + header.description + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
249 | result += "0 Name: " + header.name + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
250 | result += "0 Author: " + header.author + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
251 | result += "0 !LDRAW_ORG " + partTypeString + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
252 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
253 | switch (header.license) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
254 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
255 | case LDHeader::CaLicense: |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
256 | result += "0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
257 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
258 | case LDHeader::NonCaLicense: |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
259 | result += "0 !LICENSE Not redistributable : see NonCAreadme.txt\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
260 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
261 | case LDHeader::UnspecifiedLicense: |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
262 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
263 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
264 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
265 | if (not header.help.isEmpty()) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
266 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
267 | result += "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
268 | for (QString line : header.help.split("\n")) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
269 | result += "0 !HELP " + line + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
270 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
271 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
272 | result += "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
273 | |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
274 | switch (model.winding()) |
1295
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
275 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
276 | case CounterClockwise: |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
277 | result += "0 BFC CERTIFY CCW\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
278 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
279 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
280 | case Clockwise: |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
281 | result += "0 BFC CERTIFY CW\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
282 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
283 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
284 | case NoWinding: |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
285 | result += "0 BFC NOCERTIFY\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
286 | break; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
287 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
288 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
289 | if (not header.category.isEmpty() or not header.keywords.isEmpty()) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
290 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
291 | result += "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
292 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
293 | if (not header.category.isEmpty()) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
294 | result += "0 !CATEGORY " + header.category + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
295 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
296 | if (not header.keywords.isEmpty()) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
297 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
298 | for (QString line : header.keywords.split("\n")) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
299 | result += "0 !KEYWORDS " + line + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
300 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
301 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
302 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
303 | if (not header.cmdline.isEmpty()) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
304 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
305 | result += "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
306 | result += "0 !CMDLINE " + header.cmdline + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
307 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
308 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
309 | if (not header.history.isEmpty()) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
310 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
311 | result += "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
312 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
313 | for (const LDHeader::HistoryEntry& historyEntry : header.history) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
314 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
315 | QString author = historyEntry.author; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
316 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
317 | if (not author.startsWith("{")) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
318 | author = "[" + author + "]"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
319 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
320 | result += "0 !HISTORY "; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
321 | result += historyEntry.date.toString(Qt::ISODate) + " "; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
322 | result += author + " "; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
323 | result += historyEntry.description + "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
324 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
325 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
326 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
327 | result += "\r\n"; |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
328 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
329 | |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
330 | return result.toUtf8(); |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
331 | } |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
332 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | // |
1135
8e0691be0b6f
Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
335 | bool LDDocument::save (QString path, qint64* sizeptr) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | { |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
337 | if (isFrozen()) |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
338 | return false; |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
339 | |
1064
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
340 | if (path.isEmpty()) |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
341 | path = fullPath(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | |
1295
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
343 | QByteArray data; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | |
1295
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
345 | if (this->header.type != LDHeader::NoHeader) |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
346 | { |
ac8f0297885b
the header is now also saved
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
347 | header.name = LDDocument::shortenName(path); |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
348 | data += headerToString(*this, this->header).toUtf8(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | |
944 | 351 | // File is open, now save the model to it. Note that LDraw requires files to have DOS line endings. |
352 | for (LDObject* obj : objects()) | |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
353 | { |
1236
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1159
diff
changeset
|
354 | if (obj->isInverted()) |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1159
diff
changeset
|
355 | data += "0 BFC INVERTNEXT\r\n"; |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
356 | |
1236
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1159
diff
changeset
|
357 | data += (obj->asText() + "\r\n").toUtf8(); |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
358 | } |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
359 | |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
360 | QFile f (path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
362 | if (not f.open (QIODevice::WriteOnly)) |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
363 | return false; |
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
364 | |
1236
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1159
diff
changeset
|
365 | if (sizeptr) |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1159
diff
changeset
|
366 | *sizeptr = data.size(); |
861bf8ebb8ec
BFC INVERTNEXT objects are no longer individual objects
Santeri Piippo
parents:
1159
diff
changeset
|
367 | |
781
aa823ba3241d
- when saving, prepare the data first into a buffer and then write to disk, minimizing the time needed to perform the I/O operation.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
770
diff
changeset
|
368 | f.write (data); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | f.close(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | // We have successfully saved, update the save position now. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | setSavePosition (history()->position()); |
834
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
373 | setFullPath (path); |
3e697ba996e8
- now prints the filesize upon successful save
Santeri Piippo <crimsondusk64@gmail.com>
parents:
831
diff
changeset
|
374 | setName (shortenName (path)); |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
375 | m_window->updateDocumentListItem (this); |
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
376 | m_window->updateTitle(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | |
1440 | 380 | void LDDocument::handleNewObject(const Uuid& index) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
382 | LDObject* object = lookup(index); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
383 | history()->add<AddHistoryEntry>(index); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
384 | connect( |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
385 | object, |
1279 | 386 | SIGNAL(modified(LDObjectState, LDObjectState)), |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
387 | this, |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
388 | SLOT(objectChanged(LDObjectState, LDObjectState)) |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
389 | ); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
392 | void LDDocument::objectChanged(const LDObjectState& before, const LDObjectState& after) |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
393 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
394 | LDObject* object = qobject_cast<LDObject*>(sender()); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
395 | |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
396 | if (object) |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
397 | { |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
398 | QModelIndex index = this->indexOf(object); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
399 | history()->add<EditHistoryEntry>(index, before, after); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
400 | redoVertices(); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
401 | emit objectModified(object); |
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
402 | } |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
403 | } |
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
404 | |
1440 | 405 | void LDDocument::handleImminentObjectRemoval(const Uuid& index) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
407 | LDObject* object = lookup(index); |
949
a9ba8ffd9534
actually added updaterevision.py, more fixing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
946
diff
changeset
|
408 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
409 | if (not isFrozen() and not m_isBeingDestroyed) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | { |
1269
ec691d9472b3
Added LDObject serialization and refactored the internal resource managing to use it. No more tearing objects from one model into another, and this provides a stable way to keep an object's state in memory such as the edit history.
Santeri Piippo
parents:
1263
diff
changeset
|
411 | history()->add<DelHistoryEntry>(index); |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
412 | m_objectVertices.remove(object); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | bool LDDocument::hasUnsavedChanges() const |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | { |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
420 | return not isFrozen() and history()->position() != savePosition(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | // |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
788
diff
changeset
|
425 | QString LDDocument::getDisplayName() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | { |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
427 | if (not name().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | return name(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
656
diff
changeset
|
430 | if (not defaultName().isEmpty()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | return "[" + defaultName() + "]"; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | |
920
147497785496
- fixed stability problems
Teemu Piippo <crimsondusk64@gmail.com>
parents:
902
diff
changeset
|
433 | return QObject::tr ("untitled"); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | // |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
438 | void LDDocument::initializeCachedData() |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
439 | { |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
440 | if (m_needsRecache) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
441 | { |
1384 | 442 | this->m_polygonData.clear(); |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1074
diff
changeset
|
443 | Model model {m_documents}; |
1377
0b9a946002be
fixed changing a document not updating its references in other files
Teemu Piippo <teemu@hecknology.net>
parents:
1340
diff
changeset
|
444 | this->inlineContents(model, true, true); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
445 | |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
446 | for (LDObject* obj : model.objects()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
447 | { |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1118
diff
changeset
|
448 | if (obj->type() == LDObjectType::SubfileReference) |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
449 | { |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
450 | print ("Warning: unable to inline %1 into %2", |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
451 | static_cast<LDSubfileReference*> (obj)->referenceName(), |
867
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
452 | getDisplayName()); |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
453 | continue; |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
454 | } |
557cb07dbe57
- now tries to download missing files off ldraw.org
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
455 | |
1400 | 456 | LDPolygon data = obj->getPolygon(); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
457 | |
1400 | 458 | if (data.isValid()) |
459 | m_polygonData << data; | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
460 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
461 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
462 | m_needsRecache = false; |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
463 | } |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
464 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
465 | if (m_verticesOutdated) |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
466 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
467 | m_objectVertices.clear(); |
1079
67c6e5d32e68
More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.
Teemu Piippo <teemu@hecknology.net>
parents:
1074
diff
changeset
|
468 | Model model {m_documents}; |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
469 | inlineContents(model, true, false); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
470 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
471 | for (LDObject* object : model) |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
472 | { |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
473 | auto iterator = m_objectVertices.find (object); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
474 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
475 | if (iterator == m_objectVertices.end()) |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
476 | iterator = m_objectVertices.insert (object, QSet<Vertex>()); |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
477 | else |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
478 | iterator->clear(); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
479 | |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1262
diff
changeset
|
480 | object->getVertices(documentManager(), *iterator); |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
481 | } |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
482 | |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
483 | m_vertices.clear(); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
484 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
485 | for (const QSet<Vertex>& vertices : m_objectVertices) |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
486 | m_vertices.unite(vertices); |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
487 | |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
488 | m_verticesOutdated = false; |
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
489 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
490 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
491 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
492 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
493 | // |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1384
diff
changeset
|
494 | QVector<LDPolygon> LDDocument::inlinePolygons() |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
495 | { |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
496 | initializeCachedData(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
497 | return polygonData(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
498 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
499 | |
1288
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1280
diff
changeset
|
500 | /* |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1280
diff
changeset
|
501 | * Inlines this document into the given model |
d1e45f90654b
Header parsing complete, moved all parsing code into a new class. Documents are now all loaded in one go.
Teemu Piippo <teemu@hecknology.net>
parents:
1280
diff
changeset
|
502 | */ |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
503 | void LDDocument::inlineContents(Model& model, bool deep, bool renderinline) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | { |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
505 | // Protect against circular references by not inling if called by recursion again. |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
506 | if (not m_isInlining) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | { |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
508 | m_isInlining = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
510 | // First ask the manager to deal with this inline (this takes logoed studs into account) |
1424
737df8e904af
removed a duplicate member
Teemu Piippo <teemu@hecknology.net>
parents:
1400
diff
changeset
|
511 | if (not documentManager()->preInline(this, model, deep, renderinline)) |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
512 | { |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
513 | for (LDObject* object : objects()) |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
514 | { |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
515 | // Skip those without effect on the model meaning |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
516 | if (object->isScemantic()) |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
517 | { |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
518 | // Got another sub-file reference, recurse and inline it too if we're deep-inlining. |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
519 | // If not, just add it into the objects normally. |
1394
8d9d0532b3df
fixed cylinder rendering
Teemu Piippo <teemu@hecknology.net>
parents:
1391
diff
changeset
|
520 | if (deep and object->isRasterizable()) |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
521 | { |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
522 | LDSubfileReference* reference = static_cast<LDSubfileReference*>(object); |
1391
5fa4bf1fc781
added work done on cylinders
Teemu Piippo <teemu@hecknology.net>
parents:
1384
diff
changeset
|
523 | reference->rasterize( |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1298
diff
changeset
|
524 | documentManager(), |
1306
be85306198a2
red/green view rework complete
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
525 | this->winding(), |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1298
diff
changeset
|
526 | model, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1298
diff
changeset
|
527 | deep, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1298
diff
changeset
|
528 | renderinline |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1298
diff
changeset
|
529 | ); |
1298
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
530 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
531 | else |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
532 | { |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
533 | model.insertCopy(model.size(), object); |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
534 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
535 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
536 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
537 | } |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
538 | |
dbc8bb2a4d84
fixed infinite recursion and integrated the subfilereference editor
Teemu Piippo <teemu@hecknology.net>
parents:
1295
diff
changeset
|
539 | m_isInlining = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
541 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | // |
1329
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
545 | QString LDDocument::shortenName(const QFileInfo& path) // [static] |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | { |
1329
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
547 | QString shortname = path.fileName(); |
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
548 | QString topdirname = QFileInfo {path.absoluteFilePath()}.dir().dirName(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
549 | |
1329
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
550 | if (isOneOf(topdirname, "s", "48", "8")) |
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
551 | return topdirname + "\\" + shortname; |
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
552 | else |
025578d6e491
rewrote LDDocument::shortenName using Qt stuff
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
553 | return shortname; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
555 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
556 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | // |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
558 | const QSet<Vertex>& LDDocument::inlineVertices() |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
559 | { |
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
560 | initializeCachedData(); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
561 | return m_vertices; |
719
f2cc5964f52d
- sped up known vertex information gathering by an order of magnitude
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
562 | } |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
563 | |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
564 | void LDDocument::redoVertices() |
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
565 | { |
1102
c73f9d2e8b85
Cleaned up code in LDDocument and removed unnecessary flags and methods. Flags turned into bools.
Teemu Piippo <teemu@hecknology.net>
parents:
1101
diff
changeset
|
566 | m_verticesOutdated = true; |
835
268413885cb1
- reimplemented vertex tracking using a method similar to what the GL compiler uses
Teemu Piippo <crimsondusk64@gmail.com>
parents:
834
diff
changeset
|
567 | } |
1340
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
568 | |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
569 | decltype(LDHeader::license) LDHeader::defaultLicense() |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
570 | { |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
571 | if (config::useCaLicense()) |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
572 | return LDHeader::CaLicense; |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
573 | else |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
574 | return LDHeader::UnspecifiedLicense; |
ea1b3ea9a3ca
more work on 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1329
diff
changeset
|
575 | } |