aboutsummaryrefslogtreecommitdiff
path: root/notebookmodel.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2021-09-12 19:41:12 +0200
committerJavier <dev.git@javispedro.com>2021-09-12 19:41:12 +0200
commitac7b085449fb49f54225d22c7c229da6ad120e2b (patch)
tree7910cc8c9a3268dbacbbe434c7f3cea4eedafd3d /notebookmodel.cc
parent66dd35254724ec5d4471a8be71f92e06cf0fa8e8 (diff)
downloadscribiu-ac7b085449fb49f54225d22c7c229da6ad120e2b.tar.gz
scribiu-ac7b085449fb49f54225d22c7c229da6ad120e2b.zip
remove PEN_EPOCH mistake and get usertime from the pen
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r--notebookmodel.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/notebookmodel.cc b/notebookmodel.cc
index 3898df7..5709b8b 100644
--- a/notebookmodel.cc
+++ b/notebookmodel.cc
@@ -72,6 +72,21 @@ QString NotebookModel::penDirectory(const QString &name) const
return _dataDir.filePath(name);
}
+NotebookModel::PenTime NotebookModel::penUserTime(const QString &name) const
+{
+ QDir penDir = penDirectory(name);
+ QFile userTimeFile(penDir.filePath(PEN_USER_TIME_FILE));
+ if (userTimeFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QString data = QString::fromUtf8(userTimeFile.readLine(32));
+ userTimeFile.close();
+ return data.toULongLong();
+ }
+
+ qWarning() << "Could not read last user time for pen" << name << "; shown dates are likely to be off";
+
+ return 0;
+}
+
QString NotebookModel::notebookDirectory(const QString &penName, const QString &nbName) const
{
return _dataDir.filePath(penName + "/" + nbName);
@@ -423,7 +438,7 @@ bool NotebookModel::isPenArchive(const QString &pen) const
bool NotebookModel::isPenLocked(const QString &pen) const
{
QDir dir = penDir(pen);
- if (dir.exists(".sync.lck")) {
+ if (dir.exists(PEN_SYNC_LOCK_FILE)) {
return true; // TODO check if stale
} else {
return false;
@@ -433,7 +448,7 @@ bool NotebookModel::isPenLocked(const QString &pen) const
bool NotebookModel::isNotebookLocked(const QString &pen, const QString &notebook) const
{
QDir dir = notebookDir(pen, notebook);
- if (dir.exists(".sync.lck")) {
+ if (dir.exists(PEN_SYNC_LOCK_FILE)) {
return true;
} else {
return false;