QCAD
Open Source 2D CAD
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 <QMap>
28 #include <QPair>
29 #include <QVariant>
30 
31 #include "RDebug.h"
32 #include "RMath.h"
33 #include "RPropertyTypeId.h"
34 
48 public:
49  enum Option {
50  NoOptions = 0x0,
51  ReadOnly = 0x1,
52  Invisible = 0x2,
53  Angle = 0x4,
54  AffectsOtherProperties = 0x8,
55  IgnoreCase = 0x10,
56  AllowMixedValue = 0x20,
57  List = 0x40,
58  Mixed = 0x80,
59  RichText = 0x100,
60  Style = 0x200,
61  DimensionLabel = 0x400,
62  Label = 0x800,
63  Pattern = 0x1000,
64  Custom = 0x2000,
65  Integer = 0x4000,
66  Redundant = 0x8000,
67  VisibleToParent = 0x10000,
68  KnownVariable = 0x20000,
69  NumericallySorted = 0x40000,
70  Percentage = 0x80000 | Integer,
71  Sum = 0x100000 | ReadOnly | Redundant,
72  Undeletable = 0x200000,
74  OnRequest = 0x400000
75  };
76  Q_DECLARE_FLAGS(Options, Option)
77 
78 public:
79  RPropertyAttributes() : options(NoOptions) {}
80 
81  RPropertyAttributes(RPropertyAttributes::Options options) :
82  options(options) {
83  }
84 
85  void setOption(RPropertyAttributes::Option option, bool on);
86 
87  bool isReadOnly() const {
88  return options.testFlag(ReadOnly);
89  }
90 
91  void setReadOnly(bool readOnly) {
92  setOption(ReadOnly, readOnly);
93  }
94 
95  bool isInvisible() const {
96  return options.testFlag(Invisible);
97  }
98 
99  void setInvisible(bool invisible) {
100  setOption(Invisible, invisible);
101  }
102 
103  bool isUndeletable() const {
104  return options.testFlag(Undeletable);
105  }
106 
107  void setUndeletable(bool undeletable) {
108  setOption(Undeletable, undeletable);
109  }
110 
111  bool isList() const {
112  return options.testFlag(List);
113  }
114 
115  void setList(bool on) {
116  setOption(List, on);
117  }
118 
119  bool isAngleType() const {
120  return options.testFlag(Angle);
121  }
122 
123  void setAngleType(bool angle) {
124  setOption(Angle, angle);
125  }
126 
127  bool getIgnoreCase() const {
128  return options.testFlag(IgnoreCase);
129  }
130 
131  void setIgnoreCase(bool ignoreCase) {
132  setOption(IgnoreCase, ignoreCase);
133  }
134 
135  bool affectsOtherProperties() const {
136  return options.testFlag(AffectsOtherProperties);
137  }
138 
139  void setAffectsOtherProperties(bool affectsOtherProperties) {
140  setOption(AffectsOtherProperties, affectsOtherProperties);
141  }
142 
143  void setAllowMixedValue(bool allowMixedValue) {
144  setOption(AllowMixedValue, allowMixedValue);
145  }
146 
148  return options.testFlag(AllowMixedValue);
149  }
150 
151  QSet<QString> getChoices() const {
152  return choices;
153  }
154 
155  void setChoices(QSet<QString> choices) {
156  this->choices = choices;
157  }
158 
159  bool hasChoices() {
160  return !choices.isEmpty();
161  }
162 
163 // QList<QVariant> getEnumChoices() const {
164 // return enumChoices;
165 // }
166 
167 // void setEnumChoices(QList<QVariant> ec) {
168 // enumChoices = ec;
169 // }
170 
171 // bool hasEnumChoices() const {
172 // return !enumChoices.isEmpty();
173 // }
174 
175  bool isRichText() const {
176  return options.testFlag(RichText);
177  }
178 
179  void setRichText(bool on) {
180  setOption(RichText, on);
181  }
182 
183  bool isStyle() const {
184  return options.testFlag(Style);
185  }
186 
187  void setStyle(bool on) {
188  setOption(Style, on);
189  }
190 
191  void mixWith(const RPropertyAttributes & other);
192 
193  bool isMixed() const {
194  return options.testFlag(Mixed);
195  }
196 
197  void setMixed(bool mixed) {
198  setOption(Mixed, mixed);
199  }
200 
201  bool isSum() const {
202  return options.testFlag(Sum);
203  }
204 
205  void setSum(bool sum) {
206  setOption(Sum, sum);
207  }
208 
209  bool isOnRequest() const {
210  return options.testFlag(OnRequest);
211  }
212 
213  void setOnRequest(bool onRequest) {
214  setOption(OnRequest, onRequest);
215  }
216 
217  bool isLabel() const {
218  return options.testFlag(Label);
219  }
220 
221  bool isDimensionLabel() const {
222  return options.testFlag(DimensionLabel);
223  }
224 
225  bool isInteger() const {
226  return options.testFlag(Integer);
227  }
228 
229  bool isRedundant() const {
230  return options.testFlag(Redundant);
231  }
232 
233  void setRedundant(bool on) {
234  setOption(Redundant, on);
235  }
236 
237  bool isVisibleToParent() const {
238  return options.testFlag(VisibleToParent);
239  }
240 
241  bool isNumericallySorted() const {
242  return options.testFlag(NumericallySorted);
243  }
244 
245  void setNumericallySorted(bool on) {
246  setOption(NumericallySorted, on);
247  }
248 
250  return propertyTypeId;
251  }
252 
254  propertyTypeId = pid;
255  }
256 
257  QString getLabel() const {
258  return label;
259  }
260 
261  void setLabel(const QString& l) {
262  label = l;
263  }
264 
265  bool operator == (const RPropertyAttributes& other) const {
266  if (isInvisible() != other.isInvisible()) {
267  return false;
268  }
269  if (isAngleType() != other.isAngleType()) {
270  return false;
271  }
272  if (affectsOtherProperties() != other.affectsOtherProperties()) {
273  return false;
274  }
275  if (isList() != other.isList()) {
276  return false;
277  }
278  if (choices != other.choices) {
279  return false;
280  }
281  if (propertyTypeId != other.propertyTypeId) {
282  return false;
283  }
284 
285  return true;
286  }
287 
288  bool operator !=(const RPropertyAttributes& other) const {
289  return !operator ==(other);
290  }
291 
292 
293 private:
294  RPropertyAttributes::Options options;
295  QSet<QString> choices;
296  QString label;
298 };
299 
300 Q_DECLARE_OPERATORS_FOR_FLAGS(RPropertyAttributes::Options)
301 
305 Q_DECLARE_METATYPE(QFlags<RPropertyAttributes::Option>*)
308 Q_DECLARE_METATYPE(_RPairVariantPropertyAttributes*)
309 Q_DECLARE_METATYPE(_RPairVariantPropertyAttributes)
310 
311 #endif
bool isReadOnly() const
Definition: RPropertyAttributes.h:87
void setMixed(bool mixed)
Definition: RPropertyAttributes.h:197
void setOnRequest(bool onRequest)
Definition: RPropertyAttributes.h:213
bool isVisibleToParent() const
Definition: RPropertyAttributes.h:237
RPropertyAttributes::Options options
Definition: RPropertyAttributes.h:294
bool getAllowMixedValue()
Definition: RPropertyAttributes.h:147
QString getLabel() const
Definition: RPropertyAttributes.h:257
bool isAngleType() const
Definition: RPropertyAttributes.h:119
QSet< QString > getChoices() const
Definition: RPropertyAttributes.h:151
bool affectsOtherProperties() const
Definition: RPropertyAttributes.h:135
void setSum(bool sum)
Definition: RPropertyAttributes.h:205
QString label
Definition: RPropertyAttributes.h:296
bool getIgnoreCase() const
Definition: RPropertyAttributes.h:127
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
RPropertyAttributes(RPropertyAttributes::Options options)
Definition: RPropertyAttributes.h:81
#define QCADCORE_EXPORT
Definition: core_global.h:10
RPropertyTypeId getPropertyTypeId() const
Definition: RPropertyAttributes.h:249
bool isLabel() const
Definition: RPropertyAttributes.h:217
void setAffectsOtherProperties(bool affectsOtherProperties)
Definition: RPropertyAttributes.h:139
bool isDimensionLabel() const
Definition: RPropertyAttributes.h:221
bool isSum() const
Definition: RPropertyAttributes.h:201
void setIgnoreCase(bool ignoreCase)
Definition: RPropertyAttributes.h:131
bool isInteger() const
Definition: RPropertyAttributes.h:225
bool isNumericallySorted() const
Definition: RPropertyAttributes.h:241
void setLabel(const QString &l)
Definition: RPropertyAttributes.h:261
bool isInvisible() const
Definition: RPropertyAttributes.h:95
bool isOnRequest() const
Definition: RPropertyAttributes.h:209
Q_DECLARE_METATYPE(RMath *)
void setPropertyTypeId(RPropertyTypeId pid)
Definition: RPropertyAttributes.h:253
QPair< QVariant, RPropertyAttributes > _RPairVariantPropertyAttributes
Definition: RPropertyAttributes.h:302
void setInvisible(bool invisible)
Definition: RPropertyAttributes.h:99
void setRedundant(bool on)
Definition: RPropertyAttributes.h:233
Option
Definition: RPropertyAttributes.h:49
void setAngleType(bool angle)
Definition: RPropertyAttributes.h:123
void setStyle(bool on)
Definition: RPropertyAttributes.h:187
bool isUndeletable() const
Definition: RPropertyAttributes.h:103
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPropertyAttributes.h:47
void setChoices(QSet< QString > choices)
Definition: RPropertyAttributes.h:155
bool isRedundant() const
Definition: RPropertyAttributes.h:229
QSet< QString > choices
Definition: RPropertyAttributes.h:295
bool isStyle() const
Definition: RPropertyAttributes.h:183
void setRichText(bool on)
Definition: RPropertyAttributes.h:179
bool hasChoices()
Definition: RPropertyAttributes.h:159
void setNumericallySorted(bool on)
Definition: RPropertyAttributes.h:245
bool isRichText() const
Definition: RPropertyAttributes.h:175
void setAllowMixedValue(bool allowMixedValue)
Definition: RPropertyAttributes.h:143
bool isMixed() const
Definition: RPropertyAttributes.h:193
void setList(bool on)
Definition: RPropertyAttributes.h:115
void setReadOnly(bool readOnly)
Definition: RPropertyAttributes.h:91
RPropertyTypeId propertyTypeId
Definition: RPropertyAttributes.h:297
void setUndeletable(bool undeletable)
Definition: RPropertyAttributes.h:107
bool isList() const
Definition: RPropertyAttributes.h:111