- message = createResult(results.at(0).name, results.at(0).street, results.at(0).city);
- QSqlQuery query;
-
- DB::connect();
-
- query.prepare("INSERT INTO cache(number, name, street, city) VALUES(:number, :name, :street, :city)");
- query.bindValue(":number", details.query);
- query.bindValue(":name", results.at(0).name);
- query.bindValue(":street", results.at(0).street);
- query.bindValue(":city", results.at(0).city);
-
- if(!query.exec())
- {
- qDebug() << "Unable to save cache";
- }
-
- QString cacheSize = Settings::instance()->get("cache_size");
-
- // Delete old entries from cache
- if(cacheSize.toInt() > 0)
- {
- if(!query.exec("DELETE c1 FROM cache AS c1 LEFT JOIN (SELECT id FROM cache ORDER BY id DESC LIMIT " + cacheSize + ") AS c2 ON c1.id = c2.id WHERE c2.id IS NULL"))
- {
- qDebug() << "Unable to delete old cache entries";
- }
- }
-
- DB::disconnect();
+ message = createResult(results.at(0).name, results.at(0).street, results.at(0).city);
+ Eniro::Result result = results.at(0);
+ result.number = details.query;
+ Cache::instance().addItem(result);
+ }
+
+ retries_ = -1;
+ currentSearch_ = "";
+
+ if(closeConnection_)
+ {
+ connectionManager_->disconnect();
+ closeConnection_ = false;