Author: aschnell Date: Thu Jan 15 16:24:26 2009 New Revision: 54659 URL: http://svn.opensuse.org/viewcvs/yast?rev=54659&view=rev Log: - backup Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc?rev=54659&r1=54658&r2=54659&view=diff ============================================================================== --- branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc (original) +++ branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc Thu Jan 15 16:24:26 2009 @@ -207,7 +207,7 @@ { yuiError() << "failed to open " << filename << endl; } - + gvFreeContext(gvc); } @@ -244,14 +244,18 @@ if (strcmp(ND_shape(node)->name, "ellipse") == 0) { - QGraphicsEllipseItem* shape = scene->addEllipse(rect); + Node* shape = new Node(rect); + shape->label = QString(ND_label(node)->text); + scene->addItem(shape); shape->setPen(pen1); shape->setBrush(brush1); item = shape; } else { - QGraphicsRectItem* shape = scene->addRect(rect); + Node* shape = new Node(rect); + shape->label = QString(ND_label(node)->text); + scene->addItem(shape); shape->setPen(pen1); shape->setBrush(brush1); item = shape; @@ -261,9 +265,6 @@ if (tooltip && tooltip[0] != '\0') item->setToolTip(tooltip); - QGraphicsSimpleTextItem* text = new QGraphicsSimpleTextItem(ND_label(node)->text, item); - text->translate(x, y); // ??? - for (Agedge_t* edge = agfstedge(graph, node); edge != NULL; edge = agnxtedge(graph, edge, node)) { const splines* spl = ED_spl(edge); @@ -315,4 +316,24 @@ } +Node::Node(const QRectF& rect, QGraphicsItem* parent) + : QGraphicsRectItem(rect, parent) +{ +} + + +Node::~Node() +{ +} + + +void +Node::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) +{ + QGraphicsRectItem::paint(painter, option, widget); + painter->setPen(Qt::black); + painter->drawText(rect(), Qt::AlignCenter | Qt::AlignHCenter, label); +} + + #include "YQGraph.moc" Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h?rev=54659&r1=54658&r2=54659&view=diff ============================================================================== --- branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h (original) +++ branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h Thu Jan 15 16:24:26 2009 @@ -32,6 +32,7 @@ #include <QLabel> #include <QMenu> #include <QGraphicsView> +#include <QGraphicsItem> class QGraphicsScene; @@ -87,4 +88,21 @@ }; + +class Node : public QGraphicsRectItem +{ + +public: + + Node(const QRectF& rect, QGraphicsItem* parent = 0); + ~Node(); + + void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); + + QString label; + +}; + + + #endif // YQGraph_h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org