X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=infodialog.cpp;h=378c77c2450b0598ba60c0617422bb5a99cd7a9b;hb=549e8d8b51f631005863aa7f4f3cb2683a901669;hp=7deb3c54074a2af21d40241fb26ab9565aa814c3;hpb=9f29e40a91e0adf35bee94726c5e8c925fed059f;p=dorian diff --git a/infodialog.cpp b/infodialog.cpp index 7deb3c5..378c77c 100644 --- a/infodialog.cpp +++ b/infodialog.cpp @@ -1,45 +1,68 @@ #include #include "infodialog.h" -#include "info.h" #include "book.h" #include "library.h" +#include "trace.h" -InfoDialog::InfoDialog(Book *book_, QWidget *parent): - QDialog(parent, Qt::Dialog | Qt::WindowTitleHint | - Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint), - book(book_) +InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons): + Dyalog(parent, showButtons), book(b) { - setWindowTitle(tr("Book Details")); - Info *info = new Info(book); - QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical, this); - QPushButton *read = new QPushButton(tr("Read"), this); - QPushButton *remove = new QPushButton(tr("Delete"), this); - connect(read, SIGNAL(clicked()), this, SLOT(onReadBook())); - connect(remove, SIGNAL(clicked()), this, SLOT(onRemoveBook())); - buttonBox->addButton(read, QDialogButtonBox::ActionRole); - buttonBox->addButton(remove, QDialogButtonBox::ActionRole); + TRACE; - QHBoxLayout *horizontalLayout = new QHBoxLayout(this); - horizontalLayout->addWidget(info); - horizontalLayout->addWidget(buttonBox); - setLayout(horizontalLayout); + setWindowTitle(tr("Book details")); + + if (book) { + QLabel *title = new QLabel(book->title, this); + addWidget(title); + if (book->subject != "") { + QLabel *subject = new QLabel(book->subject, this); + addWidget(subject); + } + if (book->creators.size()) { + QLabel *creators = new QLabel(this); + QString c = "By " + book->creators[0]; + for (int i = 1; i < book->creators.size(); i++) { + c += ", " + book->creators[i]; + } + creators->setText(c); + addWidget(creators); + } + QLabel *path = new QLabel("File: " + book->path(), this); + addWidget(path); + if (book->publisher != "") { + QLabel *publisher = + new QLabel("Published by " + book->publisher, this); + addWidget(publisher); + } + if (book->source != "") { + QLabel *source = new QLabel("Source: " + book->source, this); + addWidget(source); + } + if (book->rights != "") { + QLabel *rights = new QLabel(book->rights, this); + addWidget(rights); + } + addStretch(); + } + + addButton(tr("Read"), this, SLOT(onReadBook()), + QDialogButtonBox::ActionRole); + addButton(tr("Delete"), this, SLOT(onRemoveBook()), + QDialogButtonBox::DestructiveRole); } void InfoDialog::onReadBook() { - Library::instance()->setNowReading(Library::instance()->find(book)); - close(); + done(InfoDialog::Read); } void InfoDialog::onRemoveBook() { if (QMessageBox::Yes == - QMessageBox::question(this, - tr("Delete book"), - "Delete book \"" + book->name() + "\"?", - QMessageBox::Yes | QMessageBox::No)) { - Library::instance()->remove(Library::instance()->find(book)); - close(); + QMessageBox::question(this, tr("Delete book"), + tr("Delete book \"%1\" from library?").arg(book->shortName()), + QMessageBox::Yes | QMessageBox::No)) { + done(InfoDialog::Delete); } }