aboutsummaryrefslogtreecommitdiff
path: root/stfstrokeitem.cc
diff options
context:
space:
mode:
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);
+ }
+ }
+}