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);
18 if (book->subject != "") {
19 QLabel *subject = new QLabel(book->subject, this);
22 if (book->creators.size()) {
23 QLabel *creators = new QLabel(this);
24 QString c = "By " + book->creators[0];
25 for (int i = 1; i < book->creators.size(); i++) {
26 c += ", " + book->creators[i];
31 QLabel *path = new QLabel("File: " + book->path(), this);
33 if (book->publisher != "") {
35 new QLabel("Published by " + book->publisher, this);
38 if (book->source != "") {
39 QLabel *source = new QLabel("Source: " + book->source, this);
42 if (book->rights != "") {
43 QLabel *rights = new QLabel(book->rights, this);
49 addButton(tr("Read"), this, SLOT(onReadBook()),
50 QDialogButtonBox::ActionRole);
51 addButton(tr("Delete"), this, SLOT(onRemoveBook()),
52 QDialogButtonBox::DestructiveRole);
55 void InfoDialog::onReadBook()
57 done(InfoDialog::Read);
60 void InfoDialog::onRemoveBook()
62 if (QMessageBox::Yes ==
63 QMessageBox::question(this, tr("Delete book"),
64 tr("Delete book \"%1\" from library?").arg(book->shortName()),
65 QMessageBox::Yes | QMessageBox::No)) {
66 done(InfoDialog::Delete);