rights->setWordWrap(true);
addWidget(rights);
}
+ if (book->dateAdded.isValid()) {
+ QLabel *added = new QLabel("Added to library: " +
+ book->dateAdded.toString(Qt::SystemLocaleShortDate), this);
+ added->setWordWrap(true);
+ addWidget(added);
+ }
+ if (book->dateOpened.isValid()) {
+ QLabel *opened = new QLabel("Last read: " +
+ book->dateOpened.toString(Qt::SystemLocaleShortDate), this);
+ opened->setWordWrap(true);
+ addWidget(opened);
+ }
addStretch();
}
// Add action buttons
addButton(tr("Add book"), this, SLOT(onAdd()), "add");
- addButton(tr("Add books from folder"), this, SLOT(onAddFolder()), "folder");
+ addButton(tr("Add books from folder"), this,
+ SLOT(onAddFolder()), "folder");
addButton(tr("Search the Web"), this, SLOT(onSearch()), "search");
// Set selected item
}
// Get book file name
- QString path = QFileDialog::getOpenFileName(this, tr("Add Book"),
+ QString path = QFileDialog::getOpenFileName(this, tr("Add book"),
lastDir, "Books (*.epub)");
if (path == "") {
return;
if (!parse()) {
return false;
}
+ dateOpened = QDateTime::currentDateTimeUtc();
save();
emit opened(path());
return true;
cover = makeCover(coverPath);
}
- // If there is an "ncx" item in content, parse it: That's the real table of
- // contents
+ // If there is an "ncx" item in content, parse it: That's the real table
+ // of contents
QString ncxFileName;
if (content.contains("ncx")) {
ncxFileName = content["ncx"].href;
QString note = data[QString("bookmark%1note").arg(i)].toString();
mBookmarks.append(Bookmark(part, pos, note));
}
+ dateAdded = data["dateadded"].toDateTime();
+ dateOpened = data["dateopened"].toDateTime();
}
void Book::save()
data[QString("bookmark%1pos").arg(i)] = mBookmarks[i].pos;
data[QString("bookmark%1note").arg(i)] = mBookmarks[i].note;
}
+ data["dateadded"] = dateAdded;
+ data["dateopened"] = dateOpened;
BookDb::instance()->save(path(), data);
}
#include <QMetaType>
#include <QObject>
#include <QTemporaryFile>
+#include <QDateTime>
class QPixmap;
qreal pos;
QString note;
bool operator<(const Bookmark &other) const {
- return (part == other.part)? (pos < other.pos): (part < other.part);
+ return (part == other.part)? (pos<other.pos): (part<other.part);
}
};
QString rights; //< Rights.
QString tocPath; //< Path to toc NCX file.
QString coverPath; //< Path to cover HTML file.
- QStringList chapters; //< Main navigation items from EPUB.
+ QStringList chapters; //< Main navigation items.
qint64 size; //< Size of all parts.
+ QDateTime dateAdded; //< Date book added to library.
+ QDateTime dateOpened; //< Date book was last read.
signals:
/** Emitted if @see open() succeeds. */
beginInsertRows(QModelIndex(), size, size);
Book *book = new Book(path);
book->peek();
+ book->dateAdded = QDateTime::currentDateTimeUtc();
mBooks.append(book);
save();
endInsertRows();