diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2018-04-10 16:07:44 +0200 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2018-04-10 16:07:44 +0200 |
commit | eac7dee2d8ba86001afbc61c4e9d7baae7341cb8 (patch) | |
tree | 4214eb557fbeee94144c298bd2ec5e5a0e2df27f /src/data/nodestyle.cpp | |
parent | facfa3e8aa7e3c278b0016c02c6a9f1f019903e2 (diff) |
added edgestyles, but cant apply to nodes yet
Diffstat (limited to 'src/data/nodestyle.cpp')
-rw-r--r-- | src/data/nodestyle.cpp | 80 |
1 files changed, 16 insertions, 64 deletions
diff --git a/src/data/nodestyle.cpp b/src/data/nodestyle.cpp index b3d72fb..3f2c921 100644 --- a/src/data/nodestyle.cpp +++ b/src/data/nodestyle.cpp @@ -3,91 +3,43 @@ NodeStyle *noneStyle = new NodeStyle(); -NodeStyle::NodeStyle() : _name("none"), _data(0) +NodeStyle::NodeStyle() : Style() { } -NodeStyle::NodeStyle(QString name, GraphElementData *data): _name(name), _data(data) +NodeStyle::NodeStyle(QString name, GraphElementData *data): Style(name, data) { } -bool NodeStyle::isNone() { return _data == 0; } - -GraphElementData *NodeStyle::data() const -{ - return _data; -} - -QString NodeStyle::name() const -{ - return _name; -} - -NodeStyle::Shape NodeStyle::shape() const -{ - if (_data == 0) return NodeStyle::Circle; - - QString sh = _data->property("shape"); - if (sh.isNull()) return NodeStyle::Circle; - else if (sh == "circle") return NodeStyle::Circle; - else if (sh == "rectangle") return NodeStyle::Rectangle; - else return NodeStyle::Circle; -} - QColor NodeStyle::fillColor() const { if (_data == 0) return Qt::white; - QString col = _data->property("fill"); - - if (col.isNull()) { - return QColor(Qt::white); - } else { - QColor namedColor(col); - if (namedColor.isValid()) { - return namedColor; - } else { - // TODO: read RGB colors - return QColor(Qt::white); - } - } -} - -QColor NodeStyle::strokeColor() const -{ - if (_data == 0) return Qt::black; + QString col = propertyWithDefault("fill", "white"); - QString col = _data->property("draw"); - - if (col.isNull()) { - return QColor(Qt::black); + QColor namedColor(col); + if (namedColor.isValid()) { + return namedColor; } else { - QColor namedColor(col); - if (namedColor.isValid()) { - return namedColor; - } else { - // TODO: read RGB colors - return QColor(Qt::white); - } + // TODO: read RGB colors + return QColor(Qt::white); } } -int NodeStyle::strokeThickness() const +QBrush NodeStyle::brush() const { - return 1; + return QBrush(fillColor()); } -QPen NodeStyle::pen() const +NodeStyle::Shape NodeStyle::shape() const { - QPen p(strokeColor()); - p.setWidthF((float)strokeThickness() * 3.0f); - return p; -} + if (_data == 0) return NodeStyle::Circle; -QBrush NodeStyle::brush() const -{ - return QBrush(fillColor()); + QString sh = propertyWithDefault("shape", "circle"); + if (sh == "circle") return NodeStyle::Circle; + else if (sh == "rectangle") return NodeStyle::Rectangle; + else return NodeStyle::Circle; } QPainterPath NodeStyle::path() const |