X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=chaptersdialog.cpp;h=20f7824c062fbdc039df8955a0ec9c74ed9b5786;hb=d651145f54a754e135df407c56dc114c80e2bd52;hp=0b972d7934fc76b41e1946b6d95051c0150411b0;hpb=d73e3bc69c913c97373e1f0e3be72b73091c33bb;p=dorian diff --git a/chaptersdialog.cpp b/chaptersdialog.cpp index 0b972d7..20f7824 100644 --- a/chaptersdialog.cpp +++ b/chaptersdialog.cpp @@ -1,31 +1,26 @@ -#include +#include #include "chaptersdialog.h" #include "book.h" -ChaptersDialog::ChaptersDialog(Book *book, QWidget *parent): ListWindow(parent) +ChaptersDialog::ChaptersDialog(Book *book, QWidget *parent): + ListWindow(tr("(No chapters)"), parent) { setWindowTitle(tr("Chapters")); - - list = new QListWidget(this); - list->setSelectionMode(QAbstractItemView::SingleSelection); if (book) { foreach (QString id, book->chapters) { QString contentTitle = book->content[id].name; - (void)new QListWidgetItem(contentTitle, list); + data.append(contentTitle); } } - addList(list); - connect(list, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(onItemActivated(QListWidgetItem*))); - -#ifndef Q_WS_MAEMO_5 - addAction(tr("Close"), this, SLOT(close()), QDialogButtonBox::RejectRole); -#endif // Q_WS_MAEMO_5 + QStringListModel *model = new QStringListModel(data, this); + setModel(model); + connect(this, SIGNAL(activated(const QModelIndex &)), + this, SLOT(onItemActivated(const QModelIndex &))); } -void ChaptersDialog::onItemActivated(QListWidgetItem *item) +void ChaptersDialog::onItemActivated(const QModelIndex &index) { - emit goToChapter(list->row(item)); + emit goToChapter(index.row()); close(); }