Author: aschnell Date: Sat Jan 24 15:56:23 2009 New Revision: 54971 URL: http://svn.opensuse.org/viewcvs/yast?rev=54971&view=rev Log: - some cleanup Modified: trunk/qt-graph/src/QGraph.cc trunk/qt-graph/src/QGraph.h trunk/qt-graph/src/YQGraphPluginImpl.cc trunk/qt-graph/src/YQGraphPluginImpl.h Modified: trunk/qt-graph/src/QGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.cc?rev=54971&r1=54970&r2=54971&view=diff ============================================================================== --- trunk/qt-graph/src/QGraph.cc (original) +++ trunk/qt-graph/src/QGraph.cc Sat Jan 24 15:56:23 2009 @@ -66,14 +66,14 @@ { switch (event->key()) { - case Qt::Key_Plus: - scaleView(1.2); - break; - case Qt::Key_Minus: - scaleView(1.0 / 1.2); - break; - default: - QGraphicsView::keyPressEvent(event); + case Qt::Key_Plus: + scaleView(1.2); + break; + case Qt::Key_Minus: + scaleView(1.0 / 1.2); + break; + default: + QGraphicsView::keyPressEvent(event); } } @@ -182,11 +182,11 @@ void QGraph::renderGraph(const std::string& filename, const std::string& layoutAlgorithm) { - GVC_t* gvc = gvContext(); - FILE* fp = fopen(filename.c_str(), "r"); if (fp) { + GVC_t* gvc = gvContext(); + graph_t* graph = agread(fp); char* tmp = strdup(layoutAlgorithm.c_str()); @@ -197,13 +197,15 @@ gvFreeLayout(gvc, graph); agclose(graph); + + gvFreeContext(gvc); + + fclose(fp); } else { - qWarning("failed to open %s", filename.c_str()); + qCritical("failed to open %s", filename.c_str()); } - - gvFreeContext(gvc); } @@ -299,7 +301,7 @@ drawLabel(ND_label(node), &painter); painter.end(); - Node* item = new Node(node->name, haha2(node), picture); + QNode* item = new QNode(node->name, haha2(node), picture); item->setPos(gToQ(ND_coord_i(node))); @@ -335,7 +337,7 @@ drawArrow(QLineF(gToQ(bz.list[bz.size-1]), gToQ(bz.ep)), color, &painter); painter.end(); - Edge* item = new Edge(path, picture); + QEdge* item = new QEdge(path, picture); QPen pen(color); pen.setStyle(aggetToQPenStyle(edge, "style", Qt::SolidLine)); @@ -350,7 +352,7 @@ } -Node::Node(const QString& name, const QPainterPath& path, const QPicture& picture) +QNode::QNode(const QString& name, const QPainterPath& path, const QPicture& picture) : QGraphicsPathItem(path), name(name), picture(picture) @@ -358,15 +360,8 @@ } -QRectF -Node::boundingRect() const -{ - return QGraphicsPathItem::boundingRect().united(picture.boundingRect()); -} - - void -Node::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +QNode::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { painter->save(); QGraphicsPathItem::paint(painter, option, widget); @@ -377,20 +372,20 @@ void -Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) +QNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) { qDebug("double click on %s", (const char*) name.toUtf8()); } void -Node::mousePressEvent(QGraphicsSceneMouseEvent*) +QNode::mousePressEvent(QGraphicsSceneMouseEvent*) { qDebug("press on %s", (const char*) name.toUtf8()); } -Edge::Edge(const QPainterPath& path, const QPicture& picture) +QEdge::QEdge(const QPainterPath& path, const QPicture& picture) : QGraphicsPathItem(path), picture(picture) { @@ -398,14 +393,14 @@ QRectF -Edge::boundingRect() const +QEdge::boundingRect() const { return QGraphicsPathItem::boundingRect().united(picture.boundingRect()); } void -Edge::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +QEdge::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { painter->save(); QGraphicsPathItem::paint(painter, option, widget); Modified: trunk/qt-graph/src/QGraph.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.h?rev=54971&r1=54970&r2=54971&view=diff ============================================================================== --- trunk/qt-graph/src/QGraph.h (original) +++ trunk/qt-graph/src/QGraph.h Sat Jan 24 15:56:23 2009 @@ -89,22 +89,20 @@ }; -class Node : public QGraphicsPathItem +class QNode : public QGraphicsPathItem { public: - Node(const QString& name, const QPainterPath& path, const QPicture& picture); - - QRectF boundingRect() const; + QNode(const QString& name, const QPainterPath& path, const QPicture& picture); void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); protected: - + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event); - + private: QString name; @@ -114,12 +112,12 @@ }; -class Edge : public QGraphicsPathItem +class QEdge : public QGraphicsPathItem { public: - Edge(const QPainterPath& path, const QPicture& picture); + QEdge(const QPainterPath& path, const QPicture& picture); QRectF boundingRect() const; Modified: trunk/qt-graph/src/YQGraphPluginImpl.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/YQGraphPluginImpl.cc?rev=54971&r1=54970&r2=54971&view=diff ============================================================================== --- trunk/qt-graph/src/YQGraphPluginImpl.cc (original) +++ trunk/qt-graph/src/YQGraphPluginImpl.cc Sat Jan 24 15:56:23 2009 @@ -32,7 +32,7 @@ // term of the package selection dialog, creates the widget // tree and creates the YQGraph. // -extern "C" +extern "C" { YQGraphPluginImpl GP; } Modified: trunk/qt-graph/src/YQGraphPluginImpl.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/YQGraphPluginImpl.h?rev=54971&r1=54970&r2=54971&view=diff ============================================================================== --- trunk/qt-graph/src/YQGraphPluginImpl.h (original) +++ trunk/qt-graph/src/YQGraphPluginImpl.h Sat Jan 24 15:56:23 2009 @@ -30,7 +30,7 @@ virtual YGraph * createGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); - + virtual YGraph * createGraph( YWidget * parent, graph_t * graph ); }; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org