projects
/
jenirok
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Danish Eniro search fixed.
[jenirok]
/
src
/
gui
/
resultwindow.cpp
diff --git
a/src/gui/resultwindow.cpp
b/src/gui/resultwindow.cpp
index
e9da90a
..
1bd7cb4
100644
(file)
--- a/
src/gui/resultwindow.cpp
+++ b/
src/gui/resultwindow.cpp
@@
-30,7
+30,7
@@
#include "sourcecoreconfig.h"
ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent),
#include "sourcecoreconfig.h"
ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent),
-source_(0), list_(0), connectionManager_(0)
+source_(0), list_(0), connectionManager_(0), timer_(0), searching_(false), retries_(0)
{
setAttribute(Qt::WA_Maemo5StackedWindow);
setWindowTitle(tr("Search results"));
{
setAttribute(Qt::WA_Maemo5StackedWindow);
setWindowTitle(tr("Search results"));
@@
-56,6
+56,16
@@
void ResultWindow::search(SearchDialog::SearchDetails& details)
list_->clear();
}
list_->clear();
}
+ show();
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+
+ if(!connectionManager_)
+ {
+ connectionManager_ = new ConnectionManager();
+ }
+
+ connectionManager_->connect();
+
Source::SourceId id = Source::stringToId(Settings::instance()->get("source"));
if(!source_ || id != sourceId_)
Source::SourceId id = Source::stringToId(Settings::instance()->get("source"));
if(!source_ || id != sourceId_)
@@
-90,24
+100,33
@@
void ResultWindow::search(SearchDialog::SearchDetails& details)
config->apply(source_);
delete config;
config->apply(source_);
delete config;
- show();
- setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
-
- if(!connectionManager_)
+ if(searching_)
{
{
- connectionManager_ = new ConnectionManager();
+ source_->abort();
+ timer_ = startTimer(SEARCH_INTERVAL);
}
}
- connectionManager_->connect();
+ while(timer_)
+ {
+ QApplication::processEvents(QEventLoop::WaitForMoreEvents);
+ }
- source_->abort();
- source_->search(Source::SearchDetails(details.name, details.location, details.type));
+ list_->clear();
+ searching_ = true;
+ retries_ = 0;
+ currentSearch_ = Source::SearchDetails(details.name, details.location, details.type);
+ source_->search(currentSearch_);
}
void ResultWindow::resultAvailable(Source::Result const& result,
Source::SearchDetails const& details)
{
}
void ResultWindow::resultAvailable(Source::Result const& result,
Source::SearchDetails const& details)
{
+ if(!list_)
+ {
+ return;
+ }
+
Q_UNUSED(details);
if(!result.number.isEmpty())
Q_UNUSED(details);
if(!result.number.isEmpty())
@@
-148,6
+167,15
@@
void ResultWindow::requestFinished(QVector <Source::Result> const& results,
if(error)
{
if(error)
{
+ if(retries_ < RETRIES)
+ {
+ qDebug() << "Searching failed, retrying...";
+ retries_++;
+ list_->clear();
+ source_->search(currentSearch_);
+ return;
+ }
+
QString errorString;
Source::Error error = source_->error();
QString errorString;
Source::Error error = source_->error();
@@
-180,6
+208,8
@@
void ResultWindow::requestFinished(QVector <Source::Result> const& results,
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ searching_ = false;
+
}
void ResultWindow::itemClicked(QListWidgetItem* item)
}
void ResultWindow::itemClicked(QListWidgetItem* item)
@@
-197,15
+227,20
@@
void ResultWindow::itemClicked(QListWidgetItem* item)
void ResultWindow::setVisible(bool visible)
{
void ResultWindow::setVisible(bool visible)
{
- QMainWindow::setVisible(visible);
-
if(!visible && source_)
{
source_->abort();
if(!visible && source_)
{
source_->abort();
-
-
}
}
+
+ QMainWindow::setVisible(visible);
}
}
+void ResultWindow::timerEvent(QTimerEvent* event)
+{
+ Q_UNUSED(event);
+
+ killTimer(timer_);
+ timer_ = 0;
+}