aboutsummaryrefslogtreecommitdiff
path: root/stfstrokeitem.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-14 01:35:25 +0200
committerJavier <dev.git@javispedro.com>2015-06-14 01:35:25 +0200
commit59feffc5a253fec33b310f7a0105c8ef42b9019b (patch)
tree855c7c86b4413d813d2a6c40d167eb78ee3250d3 /stfstrokeitem.cc
parent72a71a2003028fc97d74cebecebb1541d66ded86 (diff)
downloadscribiu-59feffc5a253fec33b310f7a0105c8ef42b9019b.tar.gz
scribiu-59feffc5a253fec33b310f7a0105c8ef42b9019b.zip
paperreplay working
Diffstat (limited to 'stfstrokeitem.cc')
-rw-r--r--stfstrokeitem.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/stfstrokeitem.cc b/stfstrokeitem.cc
new file mode 100644
index 0000000..caf1ae5
--- /dev/null
+++ b/stfstrokeitem.cc
@@ -0,0 +1,36 @@
+#include <QtCore/QDebug>
+#include <QtGui/QPen>
+#include <QtGui/QCursor>
+#include <QtGui/QGraphicsScene>
+#include <QtGui/QGraphicsSceneMouseEvent>
+#include "notebookview.h"
+#include "stfstrokeitem.h"
+
+StfStrokeItem::StfStrokeItem(const QPainterPath &stroke, const PaperReplay::Session &session, qint64 startTime, qint64 endTime, QGraphicsItem *parent)
+ : QGraphicsPathItem(stroke, parent), _session(session),
+ _startTime(startTime), _endTime(endTime)
+{
+ if (_session.isValid()) {
+ setPen(QPen(Qt::green));
+ setCursor(Qt::PointingHandCursor);
+ }
+}
+
+int StfStrokeItem::type() const
+{
+ return Type;
+}
+
+void StfStrokeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (_session.isValid() && !_session.fileName().isEmpty()) {
+ QGraphicsView *view = scene()->views().first();
+ if (NotebookView *nbview = qobject_cast<NotebookView*>(view)) {
+ event->accept();
+ qint64 time = _startTime - _session.startTime();
+ if (time < 10) time = 0;
+
+ nbview->requestPaperReplay(_session.fileName(), time);
+ }
+ }
+}