Author: aschnell
Date: Fri Jan 23 23:42:20 2009
New Revision: 54970
URL: http://svn.opensuse.org/viewcvs/yast?rev=54970&view=rev
Log:
- work on encoding
- work on double-click
Modified:
trunk/qt-graph/src/QGraph.cc
trunk/qt-graph/src/QGraph.h
Modified: trunk/qt-graph/src/QGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.cc?rev=54970&r1=54969&r2=54970&view=diff
==============================================================================
--- trunk/qt-graph/src/QGraph.cc (original)
+++ trunk/qt-graph/src/QGraph.cc Fri Jan 23 23:42:20 2009
@@ -113,12 +113,12 @@
QString
-QGraph::aggetToQString(void* obj, const char* name, const char* fallback) const
+QGraph::aggetToQString(void* obj, const char* name, const QString& fallback) const
{
const char* tmp = agget(obj, const_cast(name));
if (tmp == NULL || strlen(tmp) == 0)
- return QString(fallback);
- return QString(tmp);
+ return fallback;
+ return QString::fromUtf8(tmp);
}
@@ -267,7 +267,7 @@
font.setPixelSize(textlabel->fontsize);
painter->setFont(font);
- QString text(textlabel->text);
+ QString text(QString::fromUtf8(textlabel->text));
QFontMetrics fm(painter->fontMetrics());
QRectF rect(fm.boundingRect(text));
rect.moveCenter(gToQ(textlabel->p, false));
@@ -278,6 +278,11 @@
void
QGraph::renderGraph(graph_t* graph)
{
+ if (GD_charset(graph) != 0)
+ {
+ qWarning("unsupported charset");
+ }
+
// don't use gToQ here since it adjusts the values
QRectF rect(GD_bb(graph).LL.x, GD_bb(graph).LL.y, GD_bb(graph).UR.x, GD_bb(graph).UR.y);
const qreal border = 20.0;
@@ -294,7 +299,7 @@
drawLabel(ND_label(node), &painter);
painter.end();
- Node* item = new Node(haha2(node), picture);
+ Node* item = new Node(node->name, haha2(node), picture);
item->setPos(gToQ(ND_coord_i(node)));
@@ -345,8 +350,9 @@
}
-Node::Node(const QPainterPath& path, const QPicture& picture)
+Node::Node(const QString& name, const QPainterPath& path, const QPicture& picture)
: QGraphicsPathItem(path),
+ name(name),
picture(picture)
{
}
@@ -370,4 +376,43 @@
}
+void
+Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*)
+{
+ qDebug("double click on %s", (const char*) name.toUtf8());
+}
+
+
+void
+Node::mousePressEvent(QGraphicsSceneMouseEvent*)
+{
+ qDebug("press on %s", (const char*) name.toUtf8());
+}
+
+
+Edge::Edge(const QPainterPath& path, const QPicture& picture)
+ : QGraphicsPathItem(path),
+ picture(picture)
+{
+}
+
+
+QRectF
+Edge::boundingRect() const
+{
+ return QGraphicsPathItem::boundingRect().united(picture.boundingRect());
+}
+
+
+void
+Edge::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ painter->save();
+ QGraphicsPathItem::paint(painter, option, widget);
+ painter->restore();
+
+ picture.play(painter);
+}
+
+
#include "QGraph.moc"
Modified: trunk/qt-graph/src/QGraph.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.h?rev=54970&r1=54969&r2=54970&view=diff
==============================================================================
--- trunk/qt-graph/src/QGraph.h (original)
+++ trunk/qt-graph/src/QGraph.h Fri Jan 23 23:42:20 2009
@@ -27,7 +27,7 @@
#include <QWheelEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
-#include <QGraphicsRectItem>
+#include <QGraphicsPathItem>
#include <QPicture>
@@ -70,7 +70,7 @@
*/
QPointF gToQ(const pointf& p, bool trans = true) const;
- QString aggetToQString(void* obj, const char* name, const char* fallback) const;
+ QString aggetToQString(void* obj, const char* name, const QString& fallback) const;
QColor aggetToQColor(void* obj, const char* name, const QColor& fallback) const;
@@ -94,20 +94,42 @@
public:
- Node(const QPainterPath& path, const QPicture& picture);
+ Node(const QString& name, const QPainterPath& path, const QPicture& picture);
QRectF boundingRect() const;
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
+protected:
+
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
+ void mousePressEvent(QGraphicsSceneMouseEvent* event);
+
private:
+ QString name;
+
QPicture picture;
};
-typedef Node Edge;
+class Edge : public QGraphicsPathItem
+{
+
+public:
+
+ Edge(const QPainterPath& path, const QPicture& picture);
+
+ QRectF boundingRect() const;
+
+ void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
+
+private:
+
+ QPicture picture;
+
+};
#endif // QGraph_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org