Facelift bookmarks dialog. Add Maemo-friendly dialog box class.
[dorian] / infodialog.cpp
index 7deb3c5..202d906 100644 (file)
@@ -1,29 +1,53 @@
 #include <QtGui>
 
 #include "infodialog.h"
-#include "info.h"
 #include "book.h"
 #include "library.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): Dialog(parent), book(b)
 {
     setWindowTitle(tr("Book Details"));
-    Info *info = new Info(book);
-    QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical, this);
+
+    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();
+    }
+
     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);
-
-    QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
-    horizontalLayout->addWidget(info);
-    horizontalLayout->addWidget(buttonBox);
-    setLayout(horizontalLayout);
+    addButton(read, QDialogButtonBox::ActionRole);
+    addButton(remove, QDialogButtonBox::ActionRole);
 }
 
 void InfoDialog::onReadBook()