Fix forward navigation control on Linux.
[dorian] / chaptersdialog.cpp
1 #include <QStringListModel>
2
3 #include "chaptersdialog.h"
4 #include "book.h"
5
6 ChaptersDialog::ChaptersDialog(Book *book, QWidget *parent):
7         ListWindow(tr("(No chapters)"), parent)
8 {
9     setWindowTitle(tr("Chapters"));
10     if (book) {
11         foreach (QString id, book->chapters) {
12             QString contentTitle = book->content[id].name;
13             data.append(contentTitle);
14         }
15     }
16     QStringListModel *model = new QStringListModel(data, this);
17     setModel(model);
18     connect(this, SIGNAL(activated(const QModelIndex &)),
19             this, SLOT(onItemActivated(const QModelIndex &)));
20 }
21
22 void ChaptersDialog::onItemActivated(const QModelIndex &index)
23 {
24     emit goToChapter(index.row());
25     close();
26 }