#include "listview.h"
#include "trace.h"
#include "bookfinder.h"
+#include "searchdialog.h"
+#include "platform.h"
+#include "searchresultsdialog.h"
LibraryDialog::LibraryDialog(QWidget *parent): ListWindow(parent)
{
addItemAction(tr("Delete"), this, SLOT(onRemove()));
#endif // ! Q_WS_MAEMO_5
- addAction(tr("Add book"), this, SLOT(onAdd()), ":/icons/add.png");
- addAction(tr("Add books from folder"), this, SLOT(onAddFolder()),
- ":/icons/folder.png");
+ addAction(tr("Add book"), this, SLOT(onAdd()), "add");
+ addAction(tr("Add books from folder"), this, SLOT(onAddFolder()), "folder");
+ addAction(tr("Search the Web"), this, SLOT(onSearch()), "search");
// Create and add list view
list = new ListView(this);
progress->setMinimumDuration(0);
progress->setWindowModality(Qt::WindowModal);
progress->setCancelButton(0);
+#ifdef Q_WS_S60
+ progress->setFixedWidth(
+ QApplication::desktop()->availableGeometry().width());
+#endif
connect(Library::instance(), SIGNAL(nowReadingChanged()),
this, SLOT(onCurrentBookChanged()));
SLOT(onBookAdded()));
connect(list, SIGNAL(activated(const QModelIndex &)),
this, SLOT(onItemActivated(const QModelIndex &)));
+
+ // Create search dialog
+ searchDialog = new SearchDialog(this);
+ connect(Search::instance(), SIGNAL(endSearch()),
+ this, SLOT(showSearchResults()));
}
void LibraryDialog::onAdd()
switch (added) {
case 0: msg = tr("No new books found"); break;
- case 1: msg = tr("One new book added"); break;
- default: msg = tr("%1 new books added").arg(added);
+ case 1: msg = tr("One book added"); break;
+ default: msg = tr("%1 books added").arg(added);
}
progress->reset();
progress->setLabelText(QFileInfo(path).fileName());
progress->setValue(progress->value() + 1);
}
+
+void LibraryDialog::onSearch()
+{
+ int ret = searchDialog->exec();
+ if (ret != QDialog::Accepted) {
+ return;
+ }
+ Search::instance()->start(searchDialog->query());
+}
+
+void LibraryDialog::showSearchResults()
+{
+ QList<Search::Result> results = Search::instance()->results();
+ if (results.count() == 0) {
+ QMessageBox::information(this, tr("Search results"), tr("No books found"));
+ return;
+ }
+
+ SearchResultsDialog *dialog = new SearchResultsDialog(results, this);
+ connect(dialog, SIGNAL(add(const Search::Result &)),
+ this, SLOT(onAddSearchResult(const Search::Result &)));
+ dialog->show();
+}