Fix forward navigation control on Linux.
[dorian] / infodialog.cpp
1 #include <QtGui>
2
3 #include "infodialog.h"
4 #include "book.h"
5 #include "library.h"
6 #include "trace.h"
7
8 InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
9         Dyalog(parent, showButtons), book(b)
10 {
11     TRACE;
12
13     setWindowTitle(tr("Book details"));
14
15     if (book) {
16         QLabel *title = new QLabel(book->title, this);
17         title->setWordWrap(true);
18         addWidget(title);
19         if (book->subject != "") {
20             QLabel *subject = new QLabel(book->subject, this);
21             subject->setWordWrap(true);
22             addWidget(subject);
23         }
24         if (book->creators.size()) {
25             QLabel *creators = new QLabel(this);
26             creators->setWordWrap(true);
27             creators->setText(book->creators.join(", "));
28             addWidget(creators);
29         }
30         QLabel *path = new QLabel("File: " + book->path(), this);
31         path->setWordWrap(true);
32         addWidget(path);
33         if (book->publisher != "") {
34             QLabel *publisher =
35                     new QLabel("Published by " + book->publisher, this);
36             publisher->setWordWrap(true);
37             addWidget(publisher);
38         }
39         if (book->source != "") {
40             QLabel *source = new QLabel("Source: " + book->source, this);
41             source->setWordWrap(true);
42             addWidget(source);
43         }
44         if (book->rights != "") {
45             QLabel *rights = new QLabel(book->rights, this);
46             rights->setWordWrap(true);
47             addWidget(rights);
48         }
49         if (book->dateAdded.isValid()) {
50             QLabel *added = new QLabel("Added to library: " +
51              book->dateAdded.toLocalTime().toString(Qt::SystemLocaleShortDate),
52              this);
53             added->setWordWrap(true);
54             addWidget(added);
55         }
56         if (book->dateOpened.isValid()) {
57             QLabel *opened = new QLabel("Last read: " +
58              book->dateOpened.toLocalTime().toString(Qt::SystemLocaleShortDate),
59              this);
60             opened->setWordWrap(true);
61             addWidget(opened);
62         }
63         addStretch();
64     }
65
66     addButton(tr("Read"), this, SLOT(onReadBook()),
67               QDialogButtonBox::ActionRole);
68 #ifndef Q_OS_SYMBIAN
69     addButton(tr("Delete"), this, SLOT(onRemoveBook()),
70               QDialogButtonBox::DestructiveRole);
71 #endif
72 }
73
74 void InfoDialog::onReadBook()
75 {
76     done(InfoDialog::Read);
77 }
78
79 void InfoDialog::onRemoveBook()
80 {
81     if (QMessageBox::Yes ==
82         QMessageBox::question(this, tr("Delete book"),
83             tr("Delete book \"%1\" from library?").arg(book->shortName()),
84             QMessageBox::Yes | QMessageBox::No)) {
85         done(InfoDialog::Delete);
86     }
87 }