Initial release.
[dorian] / infodialog.cpp
index 210bac2..378c77c 100644 (file)
@@ -3,10 +3,14 @@
 #include "infodialog.h"
 #include "book.h"
 #include "library.h"
+#include "trace.h"
 
-InfoDialog::InfoDialog(Book *b, QWidget *parent): Dialog(parent), book(b)
+InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
+        Dyalog(parent, showButtons), book(b)
 {
-    setWindowTitle(tr("Book Details"));
+    TRACE;
+
+    setWindowTitle(tr("Book details"));
 
     if (book) {
         QLabel *title = new QLabel(book->title, this);
@@ -42,18 +46,15 @@ InfoDialog::InfoDialog(Book *b, QWidget *parent): Dialog(parent), book(b)
         addStretch();
     }
 
-    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()));
-    addButton(read, QDialogButtonBox::ActionRole);
-    addButton(remove, QDialogButtonBox::DestructiveRole);
+    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()
@@ -62,7 +63,6 @@ void InfoDialog::onRemoveBook()
         QMessageBox::question(this, tr("Delete book"),
             tr("Delete book \"%1\" from library?").arg(book->shortName()),
             QMessageBox::Yes | QMessageBox::No)) {
-        Library::instance()->remove(Library::instance()->find(book));
-        close();
+        done(InfoDialog::Delete);
     }
 }