1 #include <QBrush> |
|
2 #include <QFont> |
|
3 #include "modelobject.h" |
|
4 |
|
5 /* |
|
6 static Uuid &getUuidForNewObject() |
|
7 { |
|
8 static Uuid running_uuid {0, 0}; |
|
9 incrementUuid(running_uuid); |
|
10 return running_uuid; |
|
11 } |
|
12 */ |
|
13 |
|
14 static unsigned int getIdForNewObject() |
|
15 { |
|
16 static unsigned int id = 0; |
|
17 id += 1; |
|
18 return id; |
|
19 } |
|
20 |
|
21 linetypes::Object::Object() : |
|
22 id {getIdForNewObject()} |
|
23 { |
|
24 } |
|
25 |
|
26 linetypes::Object::~Object() |
|
27 { |
|
28 } |
|
29 |
|
30 bool linetypes::Object::hasColor() const |
|
31 { |
|
32 return false; |
|
33 } |
|
34 |
|
35 QVariant linetypes::Object::getProperty(Property id) const |
|
36 { |
|
37 Q_UNUSED(id); |
|
38 return {}; |
|
39 } |
|
40 |
|
41 auto linetypes::Object::setProperty(Property id, const QVariant& value) |
|
42 -> SetPropertyResult |
|
43 { |
|
44 Q_UNUSED(id) |
|
45 Q_UNUSED(value) |
|
46 return SetPropertyResult::PropertyNotHandled; |
|
47 } |
|
48 |
|
49 QBrush linetypes::Object::textRepresentationForeground() const |
|
50 { |
|
51 return {}; |
|
52 } |
|
53 |
|
54 QBrush linetypes::Object::textRepresentationBackground() const |
|
55 { |
|
56 return {}; |
|
57 } |
|
58 |
|
59 QFont linetypes::Object::textRepresentationFont() const |
|
60 { |
|
61 return {}; |
|
62 } |
|
63 |
|
64 linetypes::ColoredObject::ColoredObject(const Color color_index) : |
|
65 colorIndex{color_index} |
|
66 { |
|
67 } |
|
68 |
|
69 bool linetypes::ColoredObject::hasColor() const |
|
70 { |
|
71 return true; |
|
72 } |
|
73 |
|
74 QVariant linetypes::ColoredObject::getProperty(Property id) const |
|
75 { |
|
76 switch (id) |
|
77 { |
|
78 case Property::Color: |
|
79 return colorIndex.index; |
|
80 default: |
|
81 return Object::getProperty(id); |
|
82 } |
|
83 } |
|
84 |
|
85 auto linetypes::ColoredObject::setProperty(Property id, const QVariant& value) |
|
86 -> SetPropertyResult |
|
87 { |
|
88 switch (id) |
|
89 { |
|
90 case Property::Color: |
|
91 { |
|
92 bool ok; |
|
93 const int value_int = value.toInt(&ok); |
|
94 if (ok) |
|
95 { |
|
96 colorIndex.index = value_int; |
|
97 return SetPropertyResult::Success; |
|
98 } |
|
99 else |
|
100 { |
|
101 return SetPropertyResult::InvalidValue; |
|
102 } |
|
103 } |
|
104 default: |
|
105 return Object::setProperty(id, value); |
|
106 } |
|
107 } |
|
108 |
|
109 QString linetypes::Empty::textRepresentation() const |
|
110 { |
|
111 return ""; |
|
112 } |
|