3 #include "chaptersdialog.h"
7 ChaptersDialog::ChaptersDialog(Book *book, QWidget *parent): ListWindow(parent)
9 setWindowTitle(tr("Chapters"));
12 foreach (QString id, book->chapters) {
13 QString contentTitle = book->content[id].name;
14 data.append(contentTitle);
17 QStringListModel *model = new QStringListModel(data, this);
19 list->setSelectionMode(QAbstractItemView::SingleSelection);
20 list->setModel(model);
21 list->setUniformItemSizes(true);
23 connect(list, SIGNAL(activated(const QModelIndex &)),
24 this, SLOT(onItemActivated(const QModelIndex &)));
27 void ChaptersDialog::onItemActivated(const QModelIndex &index)
29 emit goToChapter(index.row());