3 #include "infodialog.h"
8 InfoDialog::InfoDialog(Book *book_, QWidget *parent):
9 QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
10 Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint),
13 setWindowTitle(tr("Book Details"));
14 Info *info = new Info(book);
15 QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical, this);
16 QPushButton *read = new QPushButton(tr("Read"), this);
17 QPushButton *remove = new QPushButton(tr("Delete"), this);
18 connect(read, SIGNAL(clicked()), this, SLOT(onReadBook()));
19 connect(remove, SIGNAL(clicked()), this, SLOT(onRemoveBook()));
20 buttonBox->addButton(read, QDialogButtonBox::ActionRole);
21 buttonBox->addButton(remove, QDialogButtonBox::ActionRole);
23 QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
24 horizontalLayout->addWidget(info);
25 horizontalLayout->addWidget(buttonBox);
26 setLayout(horizontalLayout);
29 void InfoDialog::onReadBook()
31 Library::instance()->setNowReading(Library::instance()->find(book));
35 void InfoDialog::onRemoveBook()
37 if (QMessageBox::Yes ==
38 QMessageBox::question(this,
40 "Delete book \"" + book->name() + "\"?",
41 QMessageBox::Yes | QMessageBox::No)) {
42 Library::instance()->remove(Library::instance()->find(book));