Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54887 - in /trunk/qt-graph: examples/edge-style.dot src/QGraph.cc src/QGraph.h
  • From: aschnell@xxxxxxxxxxxxxxxx
  • Date: Thu, 22 Jan 2009 11:45:07 -0000
  • Message-id: <E1LPxzf-0000JP-8Q@xxxxxxxxxxxxxxxx>
Author: aschnell
Date: Thu Jan 22 12:45:06 2009
New Revision: 54887

URL: http://svn.opensuse.org/viewcvs/yast?rev=54887&view=rev
Log:
- added basic edge style support

Added:
trunk/qt-graph/examples/edge-style.dot
Modified:
trunk/qt-graph/src/QGraph.cc
trunk/qt-graph/src/QGraph.h

Added: trunk/qt-graph/examples/edge-style.dot
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/examples/edge-style.dot?rev=54887&view=auto
==============================================================================
--- trunk/qt-graph/examples/edge-style.dot (added)
+++ trunk/qt-graph/examples/edge-style.dot Thu Jan 22 12:45:06 2009
@@ -0,0 +1,8 @@
+digraph
+{
+ node [style="filled"];
+
+ A -> B [style="solid"];
+ B -> C [style="dashed"];
+ C -> A [style="dotted"];
+}

Modified: trunk/qt-graph/src/QGraph.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.cc?rev=54887&r1=54886&r2=54887&view=diff
==============================================================================
--- trunk/qt-graph/src/QGraph.cc (original)
+++ trunk/qt-graph/src/QGraph.cc Thu Jan 22 12:45:06 2009
@@ -123,15 +123,29 @@


QColor
-QGraph::aggetToQColor(void* obj, const char* name, const char* fallback) const
+QGraph::aggetToQColor(void* obj, const char* name, const QColor& fallback)
const
{
const char* tmp = agget(obj, const_cast<char*>(name));
if (tmp == NULL || strlen(tmp) == 0)
- return QColor(fallback);
+ return fallback;
return QColor(tmp);
}


+Qt::PenStyle
+QGraph::aggetToQPenStyle(void* obj, const char* name, const Qt::PenStyle
fallback) const
+{
+ const char* tmp = agget(obj, const_cast<char*>(name));
+ if (tmp == NULL || strlen(tmp) == 0)
+ return fallback;
+ if (strcmp(tmp, "dashed") == 0)
+ return Qt::DashLine;
+ if (strcmp(tmp, "dotted") == 0)
+ return Qt::DotLine;
+ return fallback;
+}
+
+
void
QGraph::arrow(QPainterPath& path, const QLineF& line, const QString& type)
const
{
@@ -279,10 +293,6 @@
size = rect.size();


- QPen pen2(Qt::black);
- pen2.setWidthF(1);
-
-
for (node_t* node = agfstnode(graph); node != NULL; node =
agnxtnode(graph, node))
{
Node* shape = new Node(haha2(node));
@@ -291,11 +301,11 @@

shape->setPos(gToQ(ND_coord_i(node), true));

- QPen pen(aggetToQColor(node, "color", "black"));
+ QPen pen(aggetToQColor(node, "color", Qt::black));
pen.setWidthF(1.0);
shape->setPen(pen);

- QBrush brush(aggetToQColor(node, "fillcolor", "gray"));
+ QBrush brush(aggetToQColor(node, "fillcolor", Qt::gray));
shape->setBrush(brush);

QPainter painter;
@@ -329,7 +339,11 @@

QGraphicsPathItem* shape = scene->addPath(path);

- shape->setPen(pen2);
+ QPen pen(aggetToQColor(edge, "color", Qt::black));
+ pen.setStyle(aggetToQPenStyle(edge, "style", Qt::SolidLine));
+ pen.setWidthF(1.0);
+ shape->setPen(pen);
+
shape->setZValue(-1.0);
}
}

Modified: trunk/qt-graph/src/QGraph.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.h?rev=54887&r1=54886&r2=54887&view=diff
==============================================================================
--- trunk/qt-graph/src/QGraph.h (original)
+++ trunk/qt-graph/src/QGraph.h Thu Jan 22 12:45:06 2009
@@ -72,7 +72,9 @@

QString aggetToQString(void* obj, const char* name, const char* fallback)
const;

- QColor aggetToQColor(void* obj, const char* name, const char* fallback)
const;
+ QColor aggetToQColor(void* obj, const char* name, const QColor& fallback)
const;
+
+ Qt::PenStyle aggetToQPenStyle(void* obj, const char* name, const
Qt::PenStyle fallback) const;

void arrow(QPainterPath& path, const QLineF& line, const QString& type)
const;


--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages