Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54975 - in /trunk/qt-graph/src: QGraph.cc QGraph.h
  • From: aschnell@xxxxxxxxxxxxxxxx
  • Date: Sun, 25 Jan 2009 19:10:52 -0000
  • Message-id: <E1LRANg-0005QR-1o@xxxxxxxxxxxxxxxx>
Author: aschnell
Date: Sun Jan 25 20:10:51 2009
New Revision: 54975

URL: http://svn.opensuse.org/viewcvs/yast?rev=54975&view=rev
Log:
- work on double-click event

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=54975&r1=54974&r2=54975&view=diff
==============================================================================
--- trunk/qt-graph/src/QGraph.cc (original)
+++ trunk/qt-graph/src/QGraph.cc Sun Jan 25 20:10:51 2009
@@ -21,6 +21,10 @@

#include <math.h>

+#include <QKeyEvent>
+#include <QWheelEvent>
+#include <QGraphicsSceneMouseEvent>
+
#include "QGraph.h"


@@ -58,6 +62,10 @@
scene = new QGraphicsScene(this);
scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex);
setScene(scene);
+
+ signalMapper = new QSignalMapper(this);
+ connect(signalMapper, SIGNAL(mapped(const QString&)),
+ this, SIGNAL(nodeDoubleClickEvent(const QString&)));
}


@@ -287,7 +295,7 @@

// 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);
- scene->setSceneRect(rect.adjusted(-5, -5, 5, 5));
+ scene->setSceneRect(rect.adjusted(-5, -5, +5, +5));

size = rect.size();

@@ -300,7 +308,7 @@
drawLabel(ND_label(node), &painter);
painter.end();

- QNode* item = new QNode(node->name, haha2(node), picture);
+ QNode* item = new QNode(haha2(node), picture);

item->setPos(gToQ(ND_coord_i(node)));

@@ -317,6 +325,9 @@

scene->addItem(item);

+ signalMapper->setMapping(item, QString(node->name));
+ connect(item, SIGNAL(doubleClickEvent()), signalMapper, SLOT(map()));
+
for (edge_t* edge = agfstout(graph, node); edge != NULL; edge =
agnxtout(graph, edge))
{
const splines* spl = ED_spl(edge);
@@ -351,9 +362,8 @@
}


-QNode::QNode(const QString& name, const QPainterPath& path, const QPicture&
picture)
+QNode::QNode(const QPainterPath& path, const QPicture& picture)
: QGraphicsPathItem(path),
- name(name),
picture(picture)
{
}
@@ -371,16 +381,16 @@


void
-QNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*)
+QNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
- qDebug("double click on %s", (const char*) name.toUtf8());
+ if (event->button() == Qt::LeftButton)
+ emit doubleClickEvent();
}


void
QNode::mousePressEvent(QGraphicsSceneMouseEvent*)
{
- qDebug("press on %s", (const char*) name.toUtf8());
}



Modified: trunk/qt-graph/src/QGraph.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/qt-graph/src/QGraph.h?rev=54975&r1=54974&r2=54975&view=diff
==============================================================================
--- trunk/qt-graph/src/QGraph.h (original)
+++ trunk/qt-graph/src/QGraph.h Sun Jan 25 20:10:51 2009
@@ -23,11 +23,10 @@
#include <gvc.h>
#include <string>

-#include <QKeyEvent>
-#include <QWheelEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPathItem>
+#include <QSignalMapper>
#include <QPicture>


@@ -46,6 +45,10 @@
virtual void renderGraph(const std::string& filename, const std::string&
layoutAlgorithm);
virtual void renderGraph(graph_t* graph);

+signals:
+
+ void nodeDoubleClickEvent(const QString& name);
+
protected:

void keyPressEvent(QKeyEvent* event);
@@ -57,6 +60,7 @@
void init();

QGraphicsScene* scene;
+ QSignalMapper* signalMapper;

QSizeF size;

@@ -89,15 +93,20 @@
};


-class QNode : public QGraphicsPathItem
+class QNode : public QObject, public QGraphicsPathItem
{
+ Q_OBJECT

public:

- QNode(const QString& name, const QPainterPath& path, const QPicture&
picture);
+ QNode(const QPainterPath& path, const QPicture& picture);

void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
QWidget* widget);

+signals:
+
+ void doubleClickEvent();
+
protected:

void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
@@ -105,8 +114,6 @@

private:

- QString name;
-
QPicture picture;

};

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

< Previous Next >
This Thread
  • No further messages