Re-design ListWindow.
[dorian] / chaptersdialog.cpp
1 #include <QStringListModel>
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     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     // FIXME
19     // connect(list, SIGNAL(activated(const QModelIndex &)),
20     //         this, SLOT(onItemActivated(const QModelIndex &)));
21 }
22
23 void ChaptersDialog::onItemActivated(const QModelIndex &index)
24 {
25     emit goToChapter(index.row());
26     close();
27 }