Sun, 03 Nov 2019 18:17:08 +0200
split quadrilateral and triangle into their own source files
| 6 | 1 | #include <QBrush> |
| 2 | #include <QFont> | |
| 14 | 3 | #include "object.h" |
| 3 | 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 | |
| 13 | 21 | linetypes::Object::Object() : |
| 6 | 22 | id {getIdForNewObject()} |
| 3 | 23 | { |
| 24 | } | |
| 25 | ||
| 13 | 26 | linetypes::Object::~Object() |
| 3 | 27 | { |
| 28 | } | |
| 29 | ||
| 13 | 30 | bool linetypes::Object::hasColor() const |
| 3 | 31 | { |
| 32 | return false; | |
| 33 | } | |
| 34 | ||
| 13 | 35 | QVariant linetypes::Object::getProperty(Property id) const |
| 3 | 36 | { |
| 37 | Q_UNUSED(id); | |
| 38 | return {}; | |
| 39 | } | |
| 40 | ||
| 13 | 41 | auto linetypes::Object::setProperty(Property id, const QVariant& value) |
| 3 | 42 | -> SetPropertyResult |
| 43 | { | |
| 44 | Q_UNUSED(id) | |
| 45 | Q_UNUSED(value) | |
| 46 | return SetPropertyResult::PropertyNotHandled; | |
| 47 | } | |
| 48 | ||
| 13 | 49 | QBrush linetypes::Object::textRepresentationForeground() const |
| 6 | 50 | { |
| 51 | return {}; | |
| 52 | } | |
| 53 | ||
| 13 | 54 | QBrush linetypes::Object::textRepresentationBackground() const |
| 6 | 55 | { |
| 56 | return {}; | |
| 57 | } | |
| 58 | ||
| 13 | 59 | QFont linetypes::Object::textRepresentationFont() const |
| 6 | 60 | { |
| 61 | return {}; | |
| 62 | } | |
| 63 | ||
| 13 | 64 | linetypes::ColoredObject::ColoredObject(const Color color_index) : |
| 65 | colorIndex{color_index} | |
| 3 | 66 | { |
| 67 | } | |
| 68 | ||
| 13 | 69 | bool linetypes::ColoredObject::hasColor() const |
| 3 | 70 | { |
| 71 | return true; | |
| 72 | } | |
| 73 | ||
| 13 | 74 | QVariant linetypes::ColoredObject::getProperty(Property id) const |
| 3 | 75 | { |
| 76 | switch (id) | |
| 77 | { | |
| 78 | case Property::Color: | |
| 13 | 79 | return colorIndex.index; |
| 3 | 80 | default: |
| 13 | 81 | return Object::getProperty(id); |
| 3 | 82 | } |
| 83 | } | |
| 84 | ||
| 13 | 85 | auto linetypes::ColoredObject::setProperty(Property id, const QVariant& value) |
| 3 | 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 | { | |
| 13 | 96 | colorIndex.index = value_int; |
| 3 | 97 | return SetPropertyResult::Success; |
| 98 | } | |
| 99 | else | |
| 100 | { | |
| 101 | return SetPropertyResult::InvalidValue; | |
| 102 | } | |
| 103 | } | |
| 104 | default: | |
| 13 | 105 | return Object::setProperty(id, value); |
| 3 | 106 | } |
| 107 | } | |
|
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
108 | |
| 13 | 109 | QString linetypes::Empty::textRepresentation() const |
|
8
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 | } |