src/lddocument.h

changeset 1291
9c570a30c98a
parent 1288
d1e45f90654b
child 1295
ac8f0297885b
equal deleted inserted replaced
1290:8db26042f3d1 1291:9c570a30c98a
26 #include "hierarchyelement.h" 26 #include "hierarchyelement.h"
27 27
28 struct LDGLData; 28 struct LDGLData;
29 class DocumentManager; 29 class DocumentManager;
30 30
31 enum Winding
32 {
33 NoWinding,
34 CounterClockwise,
35 Clockwise,
36 };
37
31 struct LDHeader 38 struct LDHeader
32 { 39 {
33 struct HistoryEntry 40 struct HistoryEntry
34 { 41 {
35 QDate date; 42 QDate date;
36 QString author; 43 QString author;
37 QString description; 44 QString description;
38 enum { UserName, RealName } authorType = UserName;
39 }; 45 };
40 enum FileType 46 enum FileType
41 { 47 {
48 NoHeader,
42 Part, 49 Part,
43 Subpart, 50 Subpart,
44 Shortcut, 51 Shortcut,
45 Primitive, 52 Primitive,
46 Primitive_8, 53 Primitive_8,
47 Primitive_48, 54 Primitive_48,
48 Configuration, 55 Configuration,
49 } type = Part; 56 } type = NoHeader;
50 enum Qualifier 57 enum Qualifier
51 { 58 {
52 Alias = 1 << 0, 59 Alias = 1 << 0,
53 Physical_Color = 1 << 1, 60 Physical_Color = 1 << 1,
54 Flexible_Section = 1 << 2, 61 Flexible_Section = 1 << 2,
55 }; 62 };
56 QFlags<Qualifier> qualfiers; 63 QFlags<Qualifier> qualfiers;
57 QString description; 64 QString description;
58 QString name; 65 QString name;
59 struct 66 QString author;
60 {
61 QString realName;
62 QString userName;
63 } author;
64 QString category; 67 QString category;
65 QString cmdline; 68 QString cmdline;
66 QStringList help; 69 QString help;
67 QStringList keywords; 70 QString keywords;
68 QVector<HistoryEntry> history; 71 QVector<HistoryEntry> history;
72 Winding winding = NoWinding;
69 enum 73 enum
70 { 74 {
71 NoWinding, 75 Unspecified,
72 CounterClockwise,
73 Clockwise,
74 } winding = NoWinding;
75 enum
76 {
77 CaLicense, 76 CaLicense,
78 NonCaLicense 77 NonCaLicense
79 } license = CaLicense; 78 } license = Unspecified;
80 }; 79 };
81 80
82 Q_DECLARE_OPERATORS_FOR_FLAGS(QFlags<LDHeader::Qualifier>) 81 Q_DECLARE_OPERATORS_FOR_FLAGS(QFlags<LDHeader::Qualifier>)
83 82 Winding operator^(Winding one, Winding other);
84 decltype(LDHeader::winding) operator^(
85 decltype(LDHeader::winding) one,
86 decltype(LDHeader::winding) other
87 );
88 83
89 // 84 //
90 // This class stores a document either as a editable file for the user or for 85 // This class stores a document either as a editable file for the user or for
91 // subfile caching. 86 // subfile caching.
92 // 87 //
99 class LDDocument : public Model, public HierarchyElement 94 class LDDocument : public Model, public HierarchyElement
100 { 95 {
101 Q_OBJECT 96 Q_OBJECT
102 97
103 public: 98 public:
99 LDHeader header;
100
104 LDDocument (DocumentManager* parent); 101 LDDocument (DocumentManager* parent);
105 ~LDDocument(); 102 ~LDDocument();
106 103
107 void addHistoryStep(); 104 void addHistoryStep();
108 void clearHistory(); 105 void clearHistory();
127 bool save (QString path = "", qint64* sizeptr = nullptr); 124 bool save (QString path = "", qint64* sizeptr = nullptr);
128 long savePosition() const; 125 long savePosition() const;
129 void setDefaultName (QString value); 126 void setDefaultName (QString value);
130 void setFrozen(bool value); 127 void setFrozen(bool value);
131 void setFullPath (QString value); 128 void setFullPath (QString value);
132 void setHeader(LDHeader&& header);
133 void setName (QString value); 129 void setName (QString value);
134 void setSavePosition (long value); 130 void setSavePosition (long value);
135 void setTabIndex (int value); 131 void setTabIndex (int value);
136 int tabIndex() const; 132 int tabIndex() const;
137 void undo(); 133 void undo();
141 137
142 protected: 138 protected:
143 LDObject* withdrawAt(int position); 139 LDObject* withdrawAt(int position);
144 140
145 private: 141 private:
146 LDHeader m_header;
147 QString m_name; 142 QString m_name;
148 QString m_fullPath; 143 QString m_fullPath;
149 QString m_defaultName; 144 QString m_defaultName;
150 EditHistory* m_history; 145 EditHistory* m_history;
151 bool m_isFrozen = true; // Document may not be modified 146 bool m_isFrozen = true; // Document may not be modified

mercurial