Enable tracing to file. Attempt to fix last position restoration on S^3.
[dorian] / searchresultsdialog.cpp
index 09bc217..f52af1f 100644 (file)
@@ -1,5 +1,9 @@
 #include <stdio.h>
+
 #include <QtGui>
+#include <QStringListModel>
+#include <QDir>
+#include <QFile>
 
 #include "listview.h"
 #include "searchresultsdialog.h"
@@ -43,7 +47,7 @@ SearchResultsDialog::SearchResultsDialog(const QList<Search::Result> results_,
 
 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);
@@ -64,7 +68,7 @@ void SearchResultsDialog::onDownload()
 
 QString SearchResultsDialog::downloadName() const
 {
-    Trace t("SearchResultsDialog::downloadName");
+    TRACE;
     QString dir = Platform::downloadDir();
     QDir().mkpath(dir); // Not sure if this works. QDir API is quiet lame.
     unsigned i = 0;
@@ -82,18 +86,15 @@ QString SearchResultsDialog::downloadName() const
 void SearchResultsDialog::onBeginDownload(int size)
 {
     Q_UNUSED(size);
-    Trace t("SearchResultsDialog::onBeginDownload");
-    progress->setMinimum(0);
-    progress->setMaximum(0);
-    progress->setValue(0);
-    progress->show();
+    TRACE;
+    progress->showWait();
 }
 
 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);
@@ -101,5 +102,7 @@ void SearchResultsDialog::onEndDownload(int status, const Search::Result &result
         if (-1 != row) {
             list->model()->removeRow(row);
         }
+        Platform::information(tr("Downloaded \"%1\"\nand added to the library").
+                              arg(result.title), this);
     }
 }