aboutsummaryrefslogtreecommitdiff
path: root/stfstrokeitem.cc
blob: caf1ae5cb91216d55c3805d78c38c34b00f1f59c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
		}
	}
}