DocumentModel.hpp
1 #pragma once
2 #include <score/model/IdentifiedObject.hpp>
3 #include <score/model/Identifier.hpp>
4 #include <score/selection/Selection.hpp>
5 
6 #include <ossia/detail/json.hpp>
7 
8 #include <QByteArray>
9 #include <QVariant>
10 
11 #include <vector>
12 #include <verdigris>
13 
14 namespace score
15 {
16 class DocumentDelegateFactory;
17 class DocumentDelegateModel;
18 class DocumentPlugin;
19 class Document;
20 struct ApplicationContext;
21 
28 class SCORE_LIB_BASE_EXPORT DocumentModel final : public IdentifiedObject<DocumentModel>
29 {
30  W_OBJECT(DocumentModel)
31  friend class Document;
32 
33 public:
35  const Id<DocumentModel>& id, const score::DocumentContext& ctx,
36  DocumentDelegateFactory& fact, QObject* parent);
37  DocumentModel(QObject* parent);
38  ~DocumentModel();
39 
40  DocumentDelegateModel& modelDelegate() const { return *m_model; }
41 
42  void on_documentClosing();
43 
44  // Plugin models
45  void addPluginModel(DocumentPlugin* m);
46  const std::vector<DocumentPlugin*>& pluginModels() { return m_pluginModels; }
47 
48  void pluginModelsChanged() E_SIGNAL(SCORE_LIB_BASE_EXPORT, pluginModelsChanged)
49 
50 private:
51  void loadDocumentAsJson(
52  score::DocumentContext& ctx, const rapidjson::Value&,
54  void loadDocumentAsByteArray(
55  score::DocumentContext& ctx, const QByteArray&, DocumentDelegateFactory& fact);
56 
57  std::vector<DocumentPlugin*> m_pluginModels;
58  DocumentDelegateModel* m_model{}; // note : this *has* to be last due to init order
59 };
60 }
The IdentifiedObject class.
Definition: IdentifiedObject.hpp:19
The id_base_t class.
Definition: Identifier.hpp:57
Used to provide custom document types.
Definition: DocumentDelegateFactory.hpp:26
Definition: DocumentDelegateModel.hpp:11
The Document class is the central part of the software.
Definition: Document.hpp:51
Model part of a document.
Definition: DocumentModel.hpp:29
Extend a document with custom data and systems.
Definition: DocumentPluginBase.hpp:24
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DocumentContext.hpp:18