Author: aschnell
Date: Thu Jan 15 11:06:20 2009
New Revision: 54639
URL: http://svn.opensuse.org/viewcvs/yast?rev=54639&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=54639&r1=54638&r2=54639&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc (original)
+++ branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc Thu Jan 15 11:06:20 2009
@@ -19,6 +19,8 @@
/-*/
+#include
+
#include <fstream>
#include
@@ -41,6 +43,8 @@
#include <QMenu>
#include <QGraphicsScene>
#include <QGraphicsPathItem>
+#include <QKeyEvent>
+#include <QWheelEvent>
#define YUILogComponent "qt-graph"
#include "YUILog.h"
@@ -75,9 +79,44 @@
}
+void
+YQGraph::keyPressEvent(QKeyEvent* event)
+{
+ 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);
+ }
+}
+
+
+void
+YQGraph::wheelEvent(QWheelEvent* event)
+{
+ scaleView(pow(2.0, -event->delta() / 240.0));
+}
+
+
+void
+YQGraph::scaleView(qreal scaleFactor)
+{
+ qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
+ if (factor < 0.05 || factor > 10)
+ return;
+
+ scale(scaleFactor, scaleFactor);
+}
+
+
// transform graphviz point into Qt QPointF
QPointF
-gToQ(const point& p)
+YQGraph::gToQ(const point& p) const
{
return QPointF(p.x, p.y);
}
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=54639&r1=54638&r2=54639&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h (original)
+++ branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h Thu Jan 15 11:06:20 2009
@@ -68,6 +68,14 @@
void rebuildGraph();
+protected:
+
+ void keyPressEvent(QKeyEvent* event);
+ void wheelEvent(QWheelEvent* event);
+ void scaleView(qreal scaleFactor);
+
+ QPointF gToQ(const point& p) const;
+
private:
void populateScene(QGraphicsScene* scene);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org