Update from old repository.
[dorian] / dorian / info.cpp
1 #include <QtGui>
2 #include <QDebug>
3
4 #include "info.h"
5 #include "book.h"
6
7 Info::Info(Book *book, QWidget *parent): QScrollArea(parent)
8 {
9 #ifdef Q_WS_MAEMO_5
10     setProperty("FingerScrollable", true);
11     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
12 #else
13     setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
14 #endif
15     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
16     setFrameStyle(QFrame::NoFrame);
17
18     QWidget *contents = new QWidget(this);
19     QVBoxLayout *layout = new QVBoxLayout(contents);
20     layout->setMargin(0);
21     contents->setLayout(layout);
22
23     if (book) {
24         QLabel *title = new QLabel(book->title, contents);
25         layout->addWidget(title);
26         if (book->subject != "") {
27             QLabel *subject = new QLabel(book->subject, contents);
28             layout->addWidget(subject);
29         }
30         if (book->creators.size()) {
31             QLabel *creators = new QLabel(contents);
32             QString c = "By " + book->creators[0];
33             for (int i = 1; i < book->creators.size(); i++) {
34                 c += ", " + book->creators[i];
35             }
36             creators->setText(c);
37             layout->addWidget(creators);
38         }
39         QLabel *path = new QLabel("File: " + book->path(), contents);
40         layout->addWidget(path);
41         if (book->publisher != "") {
42             QLabel *publisher =
43                     new QLabel("Published by " + book->publisher, contents);
44             layout->addWidget(publisher);
45         }
46         if (book->source != "") {
47             QLabel *source = new QLabel("Source: " + book->source, contents);
48             layout->addWidget(source);
49         }
50         if (book->rights != "") {
51             QLabel *rights = new QLabel(book->rights, contents);
52             layout->addWidget(rights);
53         }
54     }
55
56     layout->addStretch();
57     setWidget(contents);
58     contents->show();
59     setWidgetResizable(true);
60 }