QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RPropertyAttributes.h
Go to the documentation of this file.
1
20#ifndef RPROPERTYATTRIBUTES_H
21#define RPROPERTYATTRIBUTES_H
22
23#include "core_global.h"
24
25#include <QString>
26#include <QSet>
27#include <QPair>
28#include <QVariant>
29
43public:
44 enum Option {
45 NoOptions = 0x0,
46 ReadOnly = 0x1,
47 Invisible = 0x2,
48 Angle = 0x4,
49 AffectsOtherProperties = 0x8,
50 IgnoreCase = 0x10,
51 AllowMixedValue = 0x20,
52 List = 0x40,
53 Mixed = 0x80,
54 RichText = 0x100,
55 Style = 0x200,
56 DimensionLabel = 0x400,
57 Label = 0x800,
58 Pattern = 0x1000,
59 Custom = 0x2000,
60 Integer = 0x4000,
61 Redundant = 0x8000,
62 VisibleToParent = 0x10000,
63 KnownVariable = 0x20000,
64 NumericallySorted = 0x40000,
65 Percentage = 0x80000 | Integer,
66 Sum = 0x100000 | ReadOnly | Redundant,
68 Undeletable = 0x200000,
69 OnRequest = 0x400000,
70 Location = 0x800000,
71 RefPoint = 0x1000000,
72 Geometry = Location | RefPoint,
73 Scale = 0x2000000,
74 Area = 0x4000000,
75 UnitLess = 0x8000000,
76 DimStyleOverride = 0x10000000,
77 CustomApp001 = 0x20000000,
78 StoreIndex = 0x40000000
79 };
80 Q_DECLARE_FLAGS(Options, Option)
81
82public:
83 RPropertyAttributes() : options(NoOptions) {}
84
85 RPropertyAttributes(RPropertyAttributes::Options options) :
86 options(options) {
87 }
88
89 void setOption(RPropertyAttributes::Option option, bool on);
90
91 bool isReadOnly() const {
92 return options.testFlag(ReadOnly);
93 }
94
95 void setReadOnly(bool readOnly) {
96 setOption(ReadOnly, readOnly);
97 }
98
99 bool isInvisible() const {
100 return options.testFlag(Invisible);
101 }
102
103 void setInvisible(bool invisible) {
104 setOption(Invisible, invisible);
105 }
106
107 bool isUndeletable() const {
108 return options.testFlag(Undeletable);
109 }
110
111 void setUndeletable(bool undeletable) {
112 setOption(Undeletable, undeletable);
113 }
114
115 bool isList() const {
116 return options.testFlag(List);
117 }
118
119 void setList(bool on) {
120 setOption(List, on);
121 }
122
123 bool isAngleType() const {
124 return options.testFlag(Angle);
125 }
126
127 void setAngleType(bool angle) {
128 setOption(Angle, angle);
129 }
130
131 bool getIgnoreCase() const {
132 return options.testFlag(IgnoreCase);
133 }
134
135 void setIgnoreCase(bool ignoreCase) {
136 setOption(IgnoreCase, ignoreCase);
137 }
138
140 return options.testFlag(AffectsOtherProperties);
141 }
142
143 void setAffectsOtherProperties(bool affectsOtherProperties) {
144 setOption(AffectsOtherProperties, affectsOtherProperties);
145 }
146
147 void setAllowMixedValue(bool allowMixedValue) {
148 setOption(AllowMixedValue, allowMixedValue);
149 }
150
152 return options.testFlag(AllowMixedValue);
153 }
154
155 QStringList getChoices() const {
156 return choices;
157 }
158
159 void setChoices(const QStringList& choices, bool storeIndex = false) {
160 this->choices = choices;
161 setOption(StoreIndex, storeIndex);
162 }
163
164 bool hasChoices() {
165 return !choices.isEmpty();
166 }
167
168 bool getStoreIndex() const {
169 return options.testFlag(StoreIndex);
170 }
171
172// QList<QVariant> getEnumChoices() const {
173// return enumChoices;
174// }
175
176// void setEnumChoices(QList<QVariant> ec) {
177// enumChoices = ec;
178// }
179
180// bool hasEnumChoices() const {
181// return !enumChoices.isEmpty();
182// }
183
184 bool isRichText() const {
185 return options.testFlag(RichText);
186 }
187
188 void setRichText(bool on) {
189 setOption(RichText, on);
190 }
191
192 bool isStyle() const {
193 return options.testFlag(Style);
194 }
195
196 void setStyle(bool on) {
197 setOption(Style, on);
198 }
199
200 void mixWith(const RPropertyAttributes & other);
201
202 bool isMixed() const {
203 return options.testFlag(Mixed);
204 }
205
206 void setMixed(bool mixed) {
207 setOption(Mixed, mixed);
208 }
209
210 bool isSum() const {
211 return options.testFlag(Sum);
212 }
213
214 void setSum(bool sum) {
215 setOption(Sum, sum);
216 }
217
218 bool isOnRequest() const {
219 return options.testFlag(OnRequest);
220 }
221
222 void setOnRequest(bool onRequest) {
223 setOption(OnRequest, onRequest);
224 }
225
226 bool isLabel() const {
227 return options.testFlag(Label);
228 }
229
230 bool isCustom() const {
231 return options.testFlag(Custom);
232 }
233
234 bool isDimensionLabel() const {
235 return options.testFlag(DimensionLabel);
236 }
237
238 void setInteger(bool i) {
239 setOption(Integer, i);
240 }
241
242 bool isInteger() const {
243 return options.testFlag(Integer);
244 }
245
246 bool isRedundant() const {
247 return options.testFlag(Redundant);
248 }
249
250 void setRedundant(bool on) {
251 setOption(Redundant, on);
252 }
253
254 bool isVisibleToParent() const {
255 return options.testFlag(VisibleToParent);
256 }
257
258 bool isNumericallySorted() const {
259 return options.testFlag(NumericallySorted);
260 }
261
262 void setNumericallySorted(bool on) {
263 setOption(NumericallySorted, on);
264 }
265
266 bool isScaleType() const {
267 return options.testFlag(Scale);
268 }
269
270 void setScaleType(bool v) {
271 setOption(Scale, v);
272 }
273
274 bool isAreaType() const {
275 return options.testFlag(Area);
276 }
277
278 void setAreaType(bool v) {
279 setOption(Area, v);
280 }
281
282 bool isUnitLess() const {
283 return options.testFlag(UnitLess);
284 }
285
286 void setUnitLess(bool v) {
287 setOption(UnitLess, v);
288 }
289
290 bool isPercentage() const {
291 return options.testFlag(Percentage);
292 }
293
294 bool isCustomApp001() const {
295 return options.testFlag(CustomApp001);
296 }
297
298 void setCustomApp001(bool v) {
299 setOption(CustomApp001, v);
300 }
301
302 QString getLabel() const {
303 return label;
304 }
305
306 void setLabel(const QString& l) {
307 label = l;
308 }
309
310 bool operator == (const RPropertyAttributes& other) const {
311 if (isInvisible() != other.isInvisible()) {
312 return false;
313 }
314 if (isAngleType() != other.isAngleType()) {
315 return false;
316 }
317 if (affectsOtherProperties() != other.affectsOtherProperties()) {
318 return false;
319 }
320 if (isList() != other.isList()) {
321 return false;
322 }
323 if (choices != other.choices) {
324 return false;
325 }
326
327 return true;
328 }
329
330 bool operator !=(const RPropertyAttributes& other) const {
331 return !operator ==(other);
332 }
333
334
335private:
336 RPropertyAttributes::Options options;
337 QStringList choices;
338 QString label;
339};
340
341Q_DECLARE_OPERATORS_FOR_FLAGS(RPropertyAttributes::Options)
342
351
352#endif
Q_DECLARE_METATYPE(RMath *)
QPair< QVariant, RPropertyAttributes > _RPairVariantPropertyAttributes
Definition RPropertyAttributes.h:343
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RPropertyAttributes.h:42
bool isPercentage() const
Definition RPropertyAttributes.h:290
void setStyle(bool on)
Definition RPropertyAttributes.h:196
QStringList getChoices() const
Definition RPropertyAttributes.h:155
bool isCustom() const
Definition RPropertyAttributes.h:230
void setUndeletable(bool undeletable)
Definition RPropertyAttributes.h:111
bool isNumericallySorted() const
Definition RPropertyAttributes.h:258
Option
Definition RPropertyAttributes.h:44
void setAllowMixedValue(bool allowMixedValue)
Definition RPropertyAttributes.h:147
bool isMixed() const
Definition RPropertyAttributes.h:202
void setList(bool on)
Definition RPropertyAttributes.h:119
void setOnRequest(bool onRequest)
Definition RPropertyAttributes.h:222
bool isReadOnly() const
Definition RPropertyAttributes.h:91
void setChoices(const QStringList &choices, bool storeIndex=false)
Definition RPropertyAttributes.h:159
bool isInvisible() const
Definition RPropertyAttributes.h:99
void setNumericallySorted(bool on)
Definition RPropertyAttributes.h:262
bool isOnRequest() const
Definition RPropertyAttributes.h:218
bool isScaleType() const
Definition RPropertyAttributes.h:266
QStringList choices
Definition RPropertyAttributes.h:337
QString getLabel() const
Definition RPropertyAttributes.h:302
bool isVisibleToParent() const
Definition RPropertyAttributes.h:254
void setInteger(bool i)
Definition RPropertyAttributes.h:238
void setInvisible(bool invisible)
Definition RPropertyAttributes.h:103
bool affectsOtherProperties() const
Definition RPropertyAttributes.h:139
bool isSum() const
Definition RPropertyAttributes.h:210
void setSum(bool sum)
Definition RPropertyAttributes.h:214
void setIgnoreCase(bool ignoreCase)
Definition RPropertyAttributes.h:135
void setCustomApp001(bool v)
Definition RPropertyAttributes.h:298
void setScaleType(bool v)
Definition RPropertyAttributes.h:270
bool isUndeletable() const
Definition RPropertyAttributes.h:107
bool hasChoices()
Definition RPropertyAttributes.h:164
bool isDimensionLabel() const
Definition RPropertyAttributes.h:234
void setAreaType(bool v)
Definition RPropertyAttributes.h:278
QString label
Definition RPropertyAttributes.h:338
bool isStyle() const
Definition RPropertyAttributes.h:192
void setAngleType(bool angle)
Definition RPropertyAttributes.h:127
bool isRichText() const
Definition RPropertyAttributes.h:184
void setMixed(bool mixed)
Definition RPropertyAttributes.h:206
bool getIgnoreCase() const
Definition RPropertyAttributes.h:131
void setUnitLess(bool v)
Definition RPropertyAttributes.h:286
bool isAngleType() const
Definition RPropertyAttributes.h:123
RPropertyAttributes::Options options
Definition RPropertyAttributes.h:336
bool isRedundant() const
Definition RPropertyAttributes.h:246
bool getAllowMixedValue()
Definition RPropertyAttributes.h:151
bool isLabel() const
Definition RPropertyAttributes.h:226
void setRichText(bool on)
Definition RPropertyAttributes.h:188
bool isAreaType() const
Definition RPropertyAttributes.h:274
void setReadOnly(bool readOnly)
Definition RPropertyAttributes.h:95
bool isUnitLess() const
Definition RPropertyAttributes.h:282
void setLabel(const QString &l)
Definition RPropertyAttributes.h:306
bool isCustomApp001() const
Definition RPropertyAttributes.h:294
bool getStoreIndex() const
Definition RPropertyAttributes.h:168
void setAffectsOtherProperties(bool affectsOtherProperties)
Definition RPropertyAttributes.h:143
bool isInteger() const
Definition RPropertyAttributes.h:242
void setRedundant(bool on)
Definition RPropertyAttributes.h:250
RPropertyAttributes()
Definition RPropertyAttributes.h:83
bool isList() const
Definition RPropertyAttributes.h:115
RPropertyAttributes(RPropertyAttributes::Options options)
Definition RPropertyAttributes.h:85
Scales selected entities.
Definition Scale.js:11
#define QCADCORE_EXPORT
Definition core_global.h:10