3 #include "infodialog.h"
7 InfoDialog::InfoDialog(Book *b, QWidget *parent): Dyalog(parent), book(b)
9 setWindowTitle(tr("Book Details"));
12 QLabel *title = new QLabel(book->title, this);
14 if (book->subject != "") {
15 QLabel *subject = new QLabel(book->subject, this);
18 if (book->creators.size()) {
19 QLabel *creators = new QLabel(this);
20 QString c = "By " + book->creators[0];
21 for (int i = 1; i < book->creators.size(); i++) {
22 c += ", " + book->creators[i];
27 QLabel *path = new QLabel("File: " + book->path(), this);
29 if (book->publisher != "") {
31 new QLabel("Published by " + book->publisher, this);
34 if (book->source != "") {
35 QLabel *source = new QLabel("Source: " + book->source, this);
38 if (book->rights != "") {
39 QLabel *rights = new QLabel(book->rights, this);
45 QPushButton *read = new QPushButton(tr("Read"), this);
46 QPushButton *remove = new QPushButton(tr("Delete"), this);
47 connect(read, SIGNAL(clicked()), this, SLOT(onReadBook()));
48 connect(remove, SIGNAL(clicked()), this, SLOT(onRemoveBook()));
49 addButton(read, QDialogButtonBox::ActionRole);
50 addButton(remove, QDialogButtonBox::DestructiveRole);
53 void InfoDialog::onReadBook()
55 Library::instance()->setNowReading(Library::instance()->find(book));
59 void InfoDialog::onRemoveBook()
61 if (QMessageBox::Yes ==
62 QMessageBox::question(this, tr("Delete book"),
63 tr("Delete book \"%1\" from library?").arg(book->shortName()),
64 QMessageBox::Yes | QMessageBox::No)) {
65 Library::instance()->remove(Library::instance()->find(book));