diff options
Diffstat (limited to 'stfgraphicsitem.cc')
-rw-r--r-- | stfgraphicsitem.cc | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/stfgraphicsitem.cc b/stfgraphicsitem.cc index 414cf6c..3c3a48b 100644 --- a/stfgraphicsitem.cc +++ b/stfgraphicsitem.cc @@ -2,38 +2,51 @@ #include <QtGui/QPainterPath> #include "stfreader.h" +#include "smartpen.h" +#include "stfstrokeitem.h" #include "stfgraphicsitem.h" class StfToGraphicsPathItems : public StfReader::StrokeHandler { QGraphicsItem *parent; + PaperReplay::SessionList replays; + PaperReplay::Session replay; + qint64 startTime, lastTime; QPainterPath path; QRectF bound; public: - StfToGraphicsPathItems(QGraphicsItem* parent) - : parent(parent), path(), bound(0.0, 0.0, 1.0, 1.0) { + StfToGraphicsPathItems(const PaperReplay::SessionList &replays, QGraphicsItem* parent) + : parent(parent), replays(replays), path(), bound(0.0, 0.0, 1.0, 1.0) { } ~StfToGraphicsPathItems() { } - bool startStroke(const QPoint& p, int force, quint64 time) { + bool startStroke(const QPoint& p, int force, qint64 time) { Q_UNUSED(force); - Q_UNUSED(time); + QList<PaperReplay::Session> sessions = replays.sessionsDuringTime(time); + if (!sessions.isEmpty()) { + replay = sessions.first(); + } else { + replay = PaperReplay::Session(); + } + startTime = time; + lastTime = time; path = QPainterPath(QPointF(p)); return true; } - bool strokePoint(const QPoint& p, int force, quint64 time) { + bool strokePoint(const QPoint& p, int force, qint64 time) { Q_UNUSED(force); Q_UNUSED(time); + lastTime = time; path.lineTo(QPointF(p)); return true; } bool endStroke() { bound |= path.boundingRect(); - new QGraphicsPathItem(path, parent); + new StfStrokeItem(path, replay, startTime, lastTime, parent); /* Parent will take the child down with him when deleted. */ return true; } @@ -43,12 +56,12 @@ public: } }; -StfGraphicsItem::StfGraphicsItem(QIODevice *dev, QGraphicsItem *parent) : +StfGraphicsItem::StfGraphicsItem(QIODevice *dev, const PaperReplay::SessionList &replays, QGraphicsItem *parent) : QGraphicsItem(parent) { setFlags(ItemHasNoContents); - StfToGraphicsPathItems h(this); + StfToGraphicsPathItems h(replays, this); StfReader r; r.setStrokeHandler(&h); if (r.parse(dev)) { |