4 #include "searchresultsdialog.h"
5 #include "searchresultinfodialog.h"
8 SearchResultsDialog::SearchResultsDialog(const QList<Search::Result> results_,
9 QWidget *parent): ListWindow(parent), results(results_)
11 setWindowTitle(tr("Search results"));
13 foreach (Search::Result result, results) {
15 if (result.authors.length()) {
16 author = result.authors[0];
18 data.append(result.title + "\n" + author);
21 QStringListModel *model = new QStringListModel(data, this);
23 list->setSelectionMode(QAbstractItemView::SingleSelection);
24 list->setModel(model);
25 list->setUniformItemSizes(true);
27 addItemAction(tr("Download book"), this, SLOT(onDownload()));
28 connect(list, SIGNAL(activated(const QModelIndex &)),
29 this, SLOT(onItemActivated(const QModelIndex &)));
32 void SearchResultsDialog::onItemActivated(const QModelIndex &index)
34 Trace t("SearchResultsDialog::onItemActivated");
35 Search::Result result = results[index.row()];
36 qDebug() << "Book" << index.row() << ":" << result.title;
37 SearchResultInfoDialog *d = new SearchResultInfoDialog(result, this);
38 d->setAttribute(Qt::WA_DeleteOnClose);
40 if (ret == QDialog::Accepted) {
41 qDebug() << "Accepted -> Start download";
45 void SearchResultsDialog::onDownload()
47 onItemActivated(list->currentIndex());