More Symbian fixes.
[dorian] / chaptersdialog.cpp
1 #include <QtGui>
2
3 #include "chaptersdialog.h"
4 #include "book.h"
5 #include "listview.h"
6
7 ChaptersDialog::ChaptersDialog(Book *book, QWidget *parent): ListWindow(parent)
8 {
9     setWindowTitle(tr("Chapters"));
10
11     if (book) {
12         foreach (QString id, book->chapters) {
13             QString contentTitle = book->content[id].name;
14             data.append(contentTitle);
15         }
16     }
17     QStringListModel *model = new QStringListModel(data, this);
18     list = new ListView;
19     list->setSelectionMode(QAbstractItemView::SingleSelection);
20     list->setModel(model);
21     list->setUniformItemSizes(true);
22     addList(list);
23     connect(list, SIGNAL(activated(const QModelIndex &)),
24             this, SLOT(onItemActivated(const QModelIndex &)));
25
26 #if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_SYMBIAN)
27     addAction(tr("Close"), this, SLOT(close()), QString(),
28               QDialogButtonBox::RejectRole);
29 #endif // Q_WS_MAEMO_5
30 }
31
32 void ChaptersDialog::onItemActivated(const QModelIndex &index)
33 {
34     emit goToChapter(index.row());
35     close();
36 }