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