15 * You should have received a copy of the GNU General Public License |
15 * You should have received a copy of the GNU General Public License |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #pragma once |
19 #pragma once |
20 #include <QSet> |
20 #include <set> |
21 #include "main.h" |
21 #include "main.h" |
22 #include "hierarchyelement.h" |
22 #include "hierarchyelement.h" |
23 |
23 |
24 class Model; |
24 class Model; |
25 |
25 |
26 class DocumentManager : public QObject, public HierarchyElement |
26 class DocumentManager : public QObject, public HierarchyElement |
27 { |
27 { |
28 Q_OBJECT |
28 Q_OBJECT |
29 |
29 |
30 public: |
30 public: |
31 using Documents = QSet<LDDocument*>; |
31 using Documents = std::set<std::unique_ptr<LDDocument>>; |
|
32 using iterator = Documents::iterator; |
32 |
33 |
33 DocumentManager (QObject* parent = nullptr); |
34 DocumentManager (QObject* parent = nullptr); |
34 ~DocumentManager(); |
35 ~DocumentManager(); |
35 |
36 |
36 void addRecentFile (QString path); |
37 void addRecentFile (QString path); |
37 const Documents& allDocuments() const { return m_documents; } |
38 const Documents& allDocuments() const; |
|
39 Documents::iterator begin(); |
38 void clear(); |
40 void clear(); |
39 LDDocument* createNew(); |
41 LDDocument* createNew(bool implicit); |
|
42 Documents::iterator end(); |
40 QString findDocument(QString name) const; |
43 QString findDocument(QString name) const; |
41 LDDocument* findDocumentByName (QString name); |
44 iterator findDocumentByName(const QString& name); |
42 LDDocument* getDocumentByName (QString filename); |
45 LDDocument* getDocumentByName (QString filename); |
43 bool isSafeToCloseAll(); |
46 bool isSafeToCloseAll(); |
44 void loadLogoedStuds(); |
47 void loadLogoedStuds(); |
45 LDDocument* openDocument( |
48 LDDocument* openDocument(QString path, bool search, bool implicit); |
46 QString path, |
|
47 bool search, |
|
48 bool implicit, |
|
49 LDDocument* fileToOverride = nullptr |
|
50 ); |
|
51 void openMainModel (QString path); |
49 void openMainModel (QString path); |
52 bool preInline (LDDocument* doc, Model& model, bool deep, bool renderinline); |
50 bool preInline (LDDocument* doc, Model& model, bool deep, bool renderinline); |
53 |
51 |
54 signals: |
52 signals: |
|
53 void documentCreated(LDDocument* document, bool cache); |
55 void documentClosed(LDDocument* document); |
54 void documentClosed(LDDocument* document); |
56 |
55 |
57 private: |
56 private: |
58 Q_SLOT void printParseErrorMessage(QString message); |
57 Q_SLOT void printParseErrorMessage(QString message); |
59 |
58 |
60 Documents m_documents; |
59 std::set<std::unique_ptr<LDDocument>> m_documents; |
61 bool m_loadingMainFile; |
60 bool m_loadingMainFile; |
62 bool m_isLoadingLogoedStuds; |
61 bool m_isLoadingLogoedStuds; |
63 LDDocument* m_logoedStud; |
62 LDDocument* m_logoedStud; |
64 LDDocument* m_logoedStud2; |
63 LDDocument* m_logoedStud2; |
65 }; |
64 }; |