X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=searchresultsdialog.cpp;h=db0192b8fc0e4da6912b5c539cab09c76a0fcd20;hb=HEAD;hp=71381337b811c4034f52371d532dcd38d44f5384;hpb=fb0f700559dc6ae38e4544b66101d44077244839;p=dorian diff --git a/searchresultsdialog.cpp b/searchresultsdialog.cpp index 7138133..db0192b 100644 --- a/searchresultsdialog.cpp +++ b/searchresultsdialog.cpp @@ -1,11 +1,10 @@ #include -#include -#ifdef Q_WS_MAEMO_5 -#include -#endif +#include +#include +#include +#include -#include "listview.h" #include "searchresultsdialog.h" #include "searchresultinfodialog.h" #include "trace.h" @@ -14,9 +13,9 @@ #include "platform.h" SearchResultsDialog::SearchResultsDialog(const QList results_, - QWidget *parent): ListWindow(parent), results(results_) + QWidget *parent): ListWindow(tr("(No results)"), parent), results(results_) { - setWindowTitle(tr("Search Results")); + setWindowTitle(tr("Search results")); foreach (Search::Result result, results) { QString author; @@ -27,13 +26,8 @@ SearchResultsDialog::SearchResultsDialog(const QList results_, } QStringListModel *model = new QStringListModel(data, this); - list = new ListView; - list->setSelectionMode(QAbstractItemView::SingleSelection); - list->setModel(model); - list->setUniformItemSizes(true); - addList(list); - addItemAction(tr("Download book"), this, SLOT(onDownload())); - connect(list, SIGNAL(activated(const QModelIndex &)), + setModel(model); + connect(this, SIGNAL(activated(const QModelIndex &)), this, SLOT(onItemActivated(const QModelIndex &))); Search *search = Search::instance(); connect(search, SIGNAL(beginDownload(int)), this, SLOT(onBeginDownload(int))); @@ -42,12 +36,12 @@ SearchResultsDialog::SearchResultsDialog(const QList results_, this, SLOT(onEndDownload(int, const Search::Result &, const QString &))); - progress = new ProgressDialog(tr("Downloading Book"), this); + progress = new ProgressDialog(tr("Downloading book"), this); } void SearchResultsDialog::onItemActivated(const QModelIndex &index) { - Trace t("SearchResultsDialog::onItemActivated"); + TRACE; Search::Result result = results[index.row()]; qDebug() << "Book" << index.row() << ":" << result.title; SearchResultInfoDialog *d = new SearchResultInfoDialog(result, this); @@ -61,15 +55,10 @@ void SearchResultsDialog::onItemActivated(const QModelIndex &index) } } -void SearchResultsDialog::onDownload() -{ - onItemActivated(list->currentIndex()); -} - QString SearchResultsDialog::downloadName() const { - Trace t("SearchResultsDialog::downloadName"); - QString dir = Platform::downloadDir(); + TRACE; + QString dir = Platform::instance()->downloadDir(); QDir().mkpath(dir); // Not sure if this works. QDir API is quiet lame. unsigned i = 0; QString fileName; @@ -86,7 +75,7 @@ QString SearchResultsDialog::downloadName() const void SearchResultsDialog::onBeginDownload(int size) { Q_UNUSED(size); - Trace t("SearchResultsDialog::onBeginDownload"); + TRACE; progress->showWait(); } @@ -94,18 +83,17 @@ void SearchResultsDialog::onEndDownload(int status, const Search::Result &result const QString &fileName) { Q_UNUSED(result); - Trace t("SearchResultsDialog::onEndDownload"); + TRACE; progress->reset(); if (Search::Ok == status) { Library::instance()->add(fileName); int row = results.indexOf(result); if (-1 != row) { - list->model()->removeRow(row); + results.removeAt(row); + model()->removeRow(row); } -#ifdef Q_WS_MAEMO_5 - QMaemo5InformationBox::information(this, - tr("Downloaded \"%1\"\nand added to the library").arg(result.title), - QMaemo5InformationBox::DefaultTimeout); -#endif + Platform::instance()-> + information(tr("Downloaded \"%1\"\nand added to the " + "library").arg(result.title), this); } }