summaryrefslogtreecommitdiff
path: root/src/data
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-04-05 14:21:24 +0200
committerAleks Kissinger <aleks0@gmail.com>2018-04-05 14:21:24 +0200
commite57923c7d767f5a532bc35571d74a5470eb76314 (patch)
tree8126896daf0ac998267da993fd2592c20bcd0789 /src/data
parent1a71fd8efa0350d1e121f6792e8fad67e82b25c1 (diff)
built-in style palette
Diffstat (limited to 'src/data')
-rw-r--r--src/data/nodestyle.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/data/nodestyle.cpp b/src/data/nodestyle.cpp
index 302ab84..b3d72fb 100644
--- a/src/data/nodestyle.cpp
+++ b/src/data/nodestyle.cpp
@@ -26,6 +26,8 @@ QString NodeStyle::name() const
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;
@@ -35,6 +37,8 @@ NodeStyle::Shape NodeStyle::shape() const
QColor NodeStyle::fillColor() const
{
+ if (_data == 0) return Qt::white;
+
QString col = _data->property("fill");
if (col.isNull()) {
@@ -52,6 +56,8 @@ QColor NodeStyle::fillColor() const
QColor NodeStyle::strokeColor() const
{
+ if (_data == 0) return Qt::black;
+
QString col = _data->property("draw");
if (col.isNull()) {
@@ -103,11 +109,29 @@ QIcon NodeStyle::icon() const
px.fill(Qt::transparent);
QPainter painter(&px);
QPainterPath pth = path();
- painter.setPen(pen());
- painter.setBrush(brush());
-
pth.translate(50.0f, 50.0f);
- painter.drawPath(pth);
+
+ if (_data == 0) {
+ QColor c(180,180,200);
+ painter.setPen(QPen(c));
+ painter.setBrush(QBrush(c));
+ painter.drawEllipse(QPointF(50.0f,50.0f), 3,3);
+
+ QPen pen(QColor(180,180,220));
+ pen.setWidth(3);
+ QVector<qreal> p;
+ p << 2.0 << 2.0;
+ pen.setDashPattern(p);
+ painter.setPen(pen);
+ painter.setBrush(Qt::NoBrush);
+ painter.drawPath(pth);
+ } else {
+ painter.setPen(pen());
+ painter.setBrush(brush());
+ painter.drawPath(pth);
+ }
+
+
return QIcon(px);
}