diff options
author | Gard Spreemann <gspr@nonempty.org> | 2020-08-20 09:03:17 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2020-08-20 09:03:17 +0200 |
commit | 4e1b4e9877732d1e1887674e48312902437f08c5 (patch) | |
tree | 7993cbc3ad71eed10da830aca85ef0b99d163bac /src/data/style.cpp | |
parent | 99f00a3ef9d1bd2d686b1521d25c9afedb880b34 (diff) | |
parent | 300267089b80785551c4721684280efe654ec834 (diff) |
Merge tag 'v2.1.6' into debian/sid
Diffstat (limited to 'src/data/style.cpp')
-rw-r--r-- | src/data/style.cpp | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/src/data/style.cpp b/src/data/style.cpp index d0f011d..f4aa892 100644 --- a/src/data/style.cpp +++ b/src/data/style.cpp @@ -62,7 +62,22 @@ QColor Style::fillColor(bool tikzitOverride) const QBrush Style::brush() const
{
- return QBrush(fillColor());
+ if (hasFill()) {
+ return QBrush(fillColor());
+ } else {
+ return Qt::NoBrush;
+ }
+}
+
+bool Style::hasFill() const
+{
+ return (propertyWithDefault("fill", "none") != "none");
+}
+
+bool Style::hasStroke() const
+{
+ if (isEdgeStyle()) return propertyWithDefault("draw", "black") != "none";
+ else return (propertyWithDefault("draw", "none") != "none");
}
QString Style::shape(bool tikzitOverride) const
@@ -152,24 +167,28 @@ Style::DrawStyle Style::drawStyle() const QPen Style::pen() const
{
- QPen p(strokeColor());
- p.setWidthF((float)strokeThickness() * 2.0f);
-
- QVector<qreal> pat;
- switch (drawStyle()) {
- case Dashed:
- pat << 3.0 << 3.0;
- p.setDashPattern(pat);
- break;
- case Dotted:
- pat << 1.0 << 1.0;
- p.setDashPattern(pat);
- break;
- case Solid:
- break;
- }
+ if (hasStroke()) {
+ QPen p(strokeColor());
+ p.setWidthF((float)strokeThickness() * 2.0f);
+
+ QVector<qreal> pat;
+ switch (drawStyle()) {
+ case Dashed:
+ pat << 3.0 << 3.0;
+ p.setDashPattern(pat);
+ break;
+ case Dotted:
+ pat << 1.0 << 1.0;
+ p.setDashPattern(pat);
+ break;
+ case Solid:
+ break;
+ }
- return p;
+ return p;
+ } else {
+ return Qt::NoPen;
+ }
}
QPainterPath Style::path() const
@@ -225,19 +244,27 @@ QIcon Style::icon() const px.fill(Qt::transparent);
QPainter painter(&px);
- if (_data == 0) {
- QPen pen(Qt::black);
- pen.setWidth(3);
- } else {
- painter.setPen(pen());
+// if (_data == 0) {
+// QPen pen(Qt::black);
+// pen.setWidth(3);
+// } else {
+// painter.setPen(pen());
+// }
+
+ QPen pn = pen();
+ painter.setPen(pn);
+
+ if (hasFill()) {
+ painter.fillRect(10,50,80,30,brush());
}
painter.drawLine(10, 50, 90, 50);
- QPen pn = pen();
pn.setStyle(Qt::SolidLine);
painter.setPen(pn);
+
+
switch (arrowHead()) {
case Pointer:
painter.drawLine(90,50,80,40);
|