Sun, 03 Nov 2019 13:07:04 +0200
fixed translations being updated twice at the same time, that's bad
6 | 1 | #include <QBrush> |
2 | #include <QFont> | |
3 | 3 | #include "modelobject.h" |
4 | ||
6 | 5 | /* |
3 | 6 | static Uuid &getUuidForNewObject() |
7 | { | |
8 | static Uuid running_uuid {0, 0}; | |
9 | incrementUuid(running_uuid); | |
10 | return running_uuid; | |
11 | } | |
6 | 12 | */ |
13 | ||
14 | static unsigned int getIdForNewObject() | |
15 | { | |
16 | static unsigned int id = 0; | |
17 | id += 1; | |
18 | return id; | |
19 | } | |
3 | 20 | |
21 | modelobjects::BaseObject::BaseObject() : | |
6 | 22 | id {getIdForNewObject()} |
3 | 23 | { |
24 | } | |
25 | ||
26 | modelobjects::BaseObject::~BaseObject() | |
27 | { | |
28 | } | |
29 | ||
30 | bool modelobjects::BaseObject::hasColor() const | |
31 | { | |
32 | return false; | |
33 | } | |
34 | ||
35 | QVariant modelobjects::BaseObject::getProperty(Property id) const | |
36 | { | |
37 | Q_UNUSED(id); | |
38 | return {}; | |
39 | } | |
40 | ||
41 | auto modelobjects::BaseObject::setProperty(Property id, const QVariant& value) | |
42 | -> SetPropertyResult | |
43 | { | |
44 | Q_UNUSED(id) | |
45 | Q_UNUSED(value) | |
46 | return SetPropertyResult::PropertyNotHandled; | |
47 | } | |
48 | ||
6 | 49 | QBrush modelobjects::BaseObject::textRepresentationForeground() const |
50 | { | |
51 | return {}; | |
52 | } | |
53 | ||
54 | QBrush modelobjects::BaseObject::textRepresentationBackground() const | |
55 | { | |
56 | return {}; | |
57 | } | |
58 | ||
59 | QFont modelobjects::BaseObject::textRepresentationFont() const | |
60 | { | |
61 | return {}; | |
62 | } | |
63 | ||
3 | 64 | modelobjects::ColoredBaseObject::ColoredBaseObject(const Color color_index) : |
65 | color_index{color_index} | |
66 | { | |
67 | } | |
68 | ||
69 | bool modelobjects::ColoredBaseObject::hasColor() const | |
70 | { | |
71 | return true; | |
72 | } | |
73 | ||
74 | QVariant modelobjects::ColoredBaseObject::getProperty(Property id) const | |
75 | { | |
76 | switch (id) | |
77 | { | |
78 | case Property::Color: | |
79 | return color_index.index; | |
80 | default: | |
81 | return BaseObject::getProperty(id); | |
82 | } | |
83 | } | |
84 | ||
85 | auto modelobjects::ColoredBaseObject::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 | color_index.index = value_int; | |
97 | return SetPropertyResult::Success; | |
98 | } | |
99 | else | |
100 | { | |
101 | return SetPropertyResult::InvalidValue; | |
102 | } | |
103 | } | |
104 | default: | |
105 | return BaseObject::setProperty(id, value); | |
106 | } | |
107 | } | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
108 | |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
109 | QString modelobjects::Empty::textRepresentation() const |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
110 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
111 | return ""; |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
112 | } |