3 #include "infodialog.h"
8 InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
9 Dyalog(parent, showButtons), book(b)
13 setWindowTitle(tr("Book details"));
16 QLabel *title = new QLabel(book->title, this);
17 title->setWordWrap(true);
19 if (book->subject != "") {
20 QLabel *subject = new QLabel(book->subject, this);
21 subject->setWordWrap(true);
24 if (book->creators.size()) {
25 QLabel *creators = new QLabel(this);
26 creators->setWordWrap(true);
27 creators->setText(book->creators.join(", "));
30 QLabel *path = new QLabel("File: " + book->path(), this);
31 path->setWordWrap(true);
33 if (book->publisher != "") {
35 new QLabel("Published by " + book->publisher, this);
36 publisher->setWordWrap(true);
39 if (book->source != "") {
40 QLabel *source = new QLabel("Source: " + book->source, this);
41 source->setWordWrap(true);
44 if (book->rights != "") {
45 QLabel *rights = new QLabel(book->rights, this);
46 rights->setWordWrap(true);
49 if (book->dateAdded.isValid()) {
50 QLabel *added = new QLabel("Added to library: " +
51 book->dateAdded.toLocalTime().toString(Qt::SystemLocaleShortDate),
53 added->setWordWrap(true);
56 if (book->dateOpened.isValid()) {
57 QLabel *opened = new QLabel("Last read: " +
58 book->dateOpened.toLocalTime().toString(Qt::SystemLocaleShortDate),
60 opened->setWordWrap(true);
66 addButton(tr("Read"), this, SLOT(onReadBook()),
67 QDialogButtonBox::ActionRole);
68 addButton(tr("Delete"), this, SLOT(onRemoveBook()),
69 QDialogButtonBox::DestructiveRole);
72 void InfoDialog::onReadBook()
74 done(InfoDialog::Read);
77 void InfoDialog::onRemoveBook()
79 if (QMessageBox::Yes ==
80 QMessageBox::question(this, tr("Delete book"),
81 tr("Delete book \"%1\" from library?").arg(book->shortName()),
82 QMessageBox::Yes | QMessageBox::No)) {
83 done(InfoDialog::Delete);