13 class Model : public QAbstractListModel |
14 class Model : public QAbstractListModel |
14 { |
15 { |
15 Q_OBJECT |
16 Q_OBJECT |
16 public: |
17 public: |
17 class EditContext; |
18 class EditContext; |
18 Model(); |
19 Model(QObject* parent = nullptr); |
19 Model(const Model&) = delete; |
20 Model(const Model&) = delete; |
20 int size() const; |
21 int size() const; |
21 EditContext edit(); |
22 EditContext edit(); |
22 int rowCount(const QModelIndex&) const override; |
23 int rowCount(const QModelIndex&) const override; |
23 QVariant data(const QModelIndex& index, int role) const override; |
24 QVariant data(const QModelIndex& index, int role) const override; |
24 QVariant getHeaderProperty(const HeaderProperty property); |
25 QVariant getHeaderProperty(const HeaderProperty property); |
25 const QString& getName() const; |
26 const QString& getName() const; |
26 QVariant getObjectProperty(const int index, const linetypes::Property property) const; |
27 QVariant getObjectProperty(const int index, const linetypes::Property property) const; |
|
28 std::vector<gl::Polygon> getPolygons(class DocumentManager* documents) const; |
|
29 void getObjectPolygons(const int index, std::vector<gl::Polygon>& polygons_out, linetypes::GetPolygonsContext* context) const; |
27 signals: |
30 signals: |
28 void objectAdded(linetypes::Id id, int position); |
31 void objectAdded(linetypes::Id id, int position); |
29 private: |
32 private: |
30 using ModelObjectPointer = std::unique_ptr<linetypes::Object>; |
33 using ModelObjectPointer = std::unique_ptr<linetypes::Object>; |
31 template<typename T, typename... Args> |
34 template<typename T, typename... Args> |
36 bool modified = false; |
39 bool modified = false; |
37 QString path; |
40 QString path; |
38 LDHeader header; |
41 LDHeader header; |
39 std::vector<ModelObjectPointer> body; |
42 std::vector<ModelObjectPointer> body; |
40 std::map<linetypes::Id, linetypes::Object*> objectsById; |
43 std::map<linetypes::Id, linetypes::Object*> objectsById; |
|
44 mutable std::vector<gl::Polygon> cachedPolygons; |
|
45 mutable bool needRecache = true; |
41 }; |
46 }; |
42 |
47 |
43 template<typename T, typename... Args> |
48 template<typename T, typename... Args> |
44 T* Model::append(Args&&... args) |
49 T* Model::append(Args&&... args) |
45 { |
50 { |