diff options
Diffstat (limited to 'notebookmodel.cc')
-rw-r--r-- | notebookmodel.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/notebookmodel.cc b/notebookmodel.cc index 3898df7..9a51bf9 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); @@ -157,7 +172,7 @@ QVariant NotebookModel::data(const QModelIndex &index, int role) const case Qt::TextAlignmentRole: switch (index.column()) { case 0: - return Qt::AlignLeft; + return QVariant::fromValue<int>(Qt::AlignLeft | Qt::AlignVCenter); case 1: case 2: return Qt::AlignCenter; @@ -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 ¬ebook) const { QDir dir = notebookDir(pen, notebook); - if (dir.exists(".sync.lck")) { + if (dir.exists(PEN_SYNC_LOCK_FILE)) { return true; } else { return false; @@ -457,8 +472,9 @@ void NotebookModel::handleChangedDirectory(const QString &path) qDebug() << "changed" << path; if (path == _dataDir.absolutePath()) { refresh(); - } else if (path.endsWith(".pen")) { + } else if (path.endsWith("." PEN_EXTENSION, Qt::CaseInsensitive) + || path.endsWith("." ARCHIVE_EXTENSION, Qt::CaseInsensitive)) { QFileInfo finfo(path); - refreshPen(finfo.baseName()); + refreshPen(finfo.fileName()); } } |