46 using MissingDependencies = std::map<QString, QString>; |
46 using MissingDependencies = std::map<QString, QString>; |
47 DocumentManager(QObject* parent = nullptr); |
47 DocumentManager(QObject* parent = nullptr); |
48 auto begin() const { return this->openModels.begin(); } |
48 auto begin() const { return this->openModels.begin(); } |
49 auto end() const { return this->openModels.end(); } |
49 auto end() const { return this->openModels.end(); } |
50 ModelId newModel(); |
50 ModelId newModel(); |
51 Model* findDependencyByName(const ModelId modelId, const QString& name); |
51 QTextDocument* findDependencyByName(const ModelId modelId, const QString& name); |
52 Model* getModelById(ModelId modelId); |
52 QTextDocument* getModelById(ModelId modelId); |
53 std::optional<ModelId> openModel(const QString& path, QTextStream& errorStream, const OpenType openType); |
53 std::optional<ModelId> openModel(const QString& path, QTextStream& errorStream, const OpenType openType); |
54 std::map<QString, QString> loadDependenciesForAllModels(const LibrariesModel &libraries); |
54 std::map<QString, QString> loadDependenciesForAllModels(const LibrariesModel &libraries); |
55 void closeDocument(const ModelId modelId); |
55 void closeDocument(const ModelId modelId); |
56 const QString* modelPath(ModelId modelId) const; |
56 const QString* modelPath(ModelId modelId) const; |
57 void setModelPath( |
57 void setModelPath( |
58 const ModelId modelId, |
58 const ModelId modelId, |
59 const QString& newPath, |
59 const QString& newPath, |
60 const LibrariesModel &libraries, |
60 const LibrariesModel &libraries, |
61 QTextStream &errorStream); |
61 QTextStream &errorStream); |
62 bool saveModel(const ModelId modelId, QTextStream& errors); |
62 bool saveModel(const ModelId modelId, QTextStream& errors); |
63 std::optional<ModelId> findIdForModel(const Model* model) const; |
63 std::optional<ModelId> findIdForModel(const QTextDocument* model) const; |
64 PolygonCache* getPolygonCacheForModel(ModelId modelId); |
64 PolygonCache* getPolygonCacheForModel(ModelId modelId); |
65 const ModelInfo* find(ModelId modelId) const; |
65 const ModelInfo* find(ModelId modelId) const; |
66 void setModelPayload(ModelId modelId, QObject* object); |
66 void setModelPayload(ModelId modelId, QObject* object); |
67 template<typename T> |
67 template<typename T> |
68 T* findPayload(ModelId modelId) const |
68 T* findPayload(ModelId modelId) const |
73 Q_SIGNALS: |
73 Q_SIGNALS: |
74 void message(const Message& message); |
74 void message(const Message& message); |
75 private: |
75 private: |
76 int modelIdCounter = 0; |
76 int modelIdCounter = 0; |
77 std::map<ModelId, ModelInfo> openModels; |
77 std::map<ModelId, ModelInfo> openModels; |
78 void collectReferences(QSet<QString> &referenced, const QString& name, const Model* model); |
78 void collectReferences(QSet<QString> &referenced, const QString& name, const QTextDocument* model); |
79 void updateDependencies(ModelInfo* model); |
79 void updateDependencies(ModelInfo* model); |
80 void prune(); |
80 void prune(); |
81 void makePolygonCacheForModel(const ModelId modelId); |
81 void makePolygonCacheForModel(const ModelId modelId); |
82 }; |
82 }; |
83 |
83 |