aboutsummaryrefslogtreecommitdiff
path: root/paperreplay.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-14 03:32:35 +0200
committerJavier <dev.git@javispedro.com>2015-06-14 03:32:35 +0200
commit46cb4b079be113996214660020d6ef0c3d1f1e80 (patch)
tree4f3c7ec2d09fe532b2d0a640aadffe52d6abf67a /paperreplay.cc
parent59feffc5a253fec33b310f7a0105c8ef42b9019b (diff)
downloadscribiu-46cb4b079be113996214660020d6ef0c3d1f1e80.tar.gz
scribiu-46cb4b079be113996214660020d6ef0c3d1f1e80.zip
paperless replay also working
Diffstat (limited to 'paperreplay.cc')
-rw-r--r--paperreplay.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/paperreplay.cc b/paperreplay.cc
index e0e654e..5baeac7 100644
--- a/paperreplay.cc
+++ b/paperreplay.cc
@@ -17,6 +17,17 @@ bool readUtfString(QDataStream &stream, QString &s)
s = QString::fromUtf8(buffer);
return true;
}
+
+QString findPenSerial(const QString &path)
+{
+ QDir dir(path + "/userdata");
+ QStringList entries = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ if (entries.isEmpty()) {
+ return QString();
+ } else {
+ return entries.first();
+ }
+}
}
PaperReplay::PaperReplay(QObject *parent) :
@@ -47,6 +58,11 @@ quint64 PaperReplay::Session::id() const
return d ? d->id : 0;
}
+QString PaperReplay::Session::name() const
+{
+ return d->name;
+}
+
QString PaperReplay::Session::fileName() const
{
return d->file;
@@ -62,6 +78,11 @@ qint64 PaperReplay::Session::endTime() const
return d->end;
}
+bool PaperReplay::Session::startTimeLess(const Session &a, const Session &b)
+{
+ return a.d->start < b.d->start;
+}
+
PaperReplay::SessionList::SessionList()
{
}
@@ -90,8 +111,14 @@ QList<PaperReplay::Session> PaperReplay::SessionList::sessionsDuringTime(qint64
return sessions;
}
-bool PaperReplay::open(const QString &path, const QString &penSerial, quint64 notebookGuid)
+bool PaperReplay::open(const QString &path, quint64 notebookGuid)
{
+ QString penSerial = findPenSerial(path);
+ if (penSerial.isEmpty()) {
+ qDebug() << "Cannot open paper replay:" << path << "does not contain any pen data";
+ return false;
+ }
+
_dir.setPath(path + QString("/userdata/%1/Paper Replay/99/%2/sessions")
.arg(penSerial)
.arg(qulonglong(notebookGuid), notebookGuid == 0 ? 1 : 16, 16, QLatin1Char('0')));
@@ -123,6 +150,8 @@ bool PaperReplay::open(const QString &path, const QString &penSerial, quint64 no
session.d->file = sessionDir.filePath(session.d->file);
}
+ _sessions.insert(sessionId, session);
+
foreach (quint64 page, session.d->pages) {
_byPageTime[page].insert(session.d->start, session);
}
@@ -133,9 +162,15 @@ bool PaperReplay::open(const QString &path, const QString &penSerial, quint64 no
void PaperReplay::close()
{
_byPageTime.clear();
+ _sessions.clear();
_dir.setPath(QString());
}
+QList<PaperReplay::Session> PaperReplay::sessions() const
+{
+ return _sessions.values();
+}
+
PaperReplay::SessionList PaperReplay::sessions(quint64 pageAddress) const
{
return SessionList(_byPageTime[pageAddress]);