-#include <QtGui>
+#include <QStringListModel>
#include "chaptersdialog.h"
#include "book.h"
+#include "listview.h"
ChaptersDialog::ChaptersDialog(Book *book, QWidget *parent): ListWindow(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);
}
}
+ QStringListModel *model = new QStringListModel(data, this);
+ list = new ListView;
+ list->setSelectionMode(QAbstractItemView::SingleSelection);
+ list->setModel(model);
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
+ connect(list, 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();
}