src/documentmanager.h

Sun, 12 Mar 2017 11:03:44 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 12 Mar 2017 11:03:44 +0200
changeset 1210
0b3b35f560f2
parent 1159
6ad8cdcd88d9
child 1211
83b8ed708909
permissions
-rw-r--r--

More work on library collections

997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1072
9ce9496427f2 Happy new year 2017!
Teemu Piippo <teemu@hecknology.net>
parents: 1016
diff changeset
3 * Copyright (C) 2013 - 2017 Teemu Piippo
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
20 #include <QSet>
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "main.h"
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "hierarchyelement.h"
1210
0b3b35f560f2 More work on library collections
Teemu Piippo <teemu@hecknology.net>
parents: 1159
diff changeset
23 #include "librarycollection.h"
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
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
25 class Model;
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
26
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 class DocumentManager : public QObject, public HierarchyElement
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 {
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 Q_OBJECT
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 public:
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
32 using Documents = QSet<LDDocument*>;
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 DocumentManager (QObject* parent = nullptr);
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 ~DocumentManager();
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 void addRecentFile (QString path);
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
38 const Documents& allDocuments() const { return m_documents; }
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 void clear();
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
40 LDDocument* createNew();
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 LDDocument* findDocumentByName (QString name);
1210
0b3b35f560f2 More work on library collections
Teemu Piippo <teemu@hecknology.net>
parents: 1159
diff changeset
42 QString findDocumentPath (QString relpath);
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 LDDocument* getDocumentByName (QString filename);
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 bool isSafeToCloseAll();
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
45 void loadFileContents(QIODevice* fp, Model& model, int* numWarnings, bool* ok);
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 void loadLogoedStuds();
1016
3b279b5e57d3 Fixed line length warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
47 LDDocument* openDocument (QString path, bool search, bool implicit, LDDocument* fileToOverride = nullptr,
3b279b5e57d3 Fixed line length warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
48 bool* aborted = nullptr);
1210
0b3b35f560f2 More work on library collections
Teemu Piippo <teemu@hecknology.net>
parents: 1159
diff changeset
49 QFile* openLDrawFile (QString relpath, QString* pathpointer);
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 void openMainModel (QString path);
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
51 bool preInline (LDDocument* doc, Model& model, bool deep, bool renderinline);
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
1114
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1097
diff changeset
53 static const QStringList specialSubdirectories;
ffd49a28f49e Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents: 1097
diff changeset
54
1097
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1073
diff changeset
55 signals:
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1073
diff changeset
56 void documentClosed(LDDocument* document);
9a9e6ce0c5dc Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents: 1073
diff changeset
57
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 private:
1159
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1114
diff changeset
59 Q_SLOT void printParseErrorMessage(QString message);
6ad8cdcd88d9 print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents: 1114
diff changeset
60
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
61 Documents m_documents;
1210
0b3b35f560f2 More work on library collections
Teemu Piippo <teemu@hecknology.net>
parents: 1159
diff changeset
62 LibraryCollection m_libraries;
998
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
63 bool m_loadingMainFile;
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
64 bool m_isLoadingLogoedStuds;
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
65 LDDocument* m_logoedStud;
5be0ce31ce60 Now compiles again
Teemu Piippo <crimsondusk64@gmail.com>
parents: 997
diff changeset
66 LDDocument* m_logoedStud2;
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 };
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
1012
413ecd6b9801 It worx again!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
69 QString Basename (QString path);
413ecd6b9801 It worx again!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 998
diff changeset
70 QString Dirname (QString path);

mercurial