loadPlugins();
loadDicts();
- if(!connect(&_timer, SIGNAL(timeout()), this, SLOT(translation())))
- qDebug() << "Timer signal not connected";
+ connect(&_timerSearch, SIGNAL(timeout()), this, SLOT(translationReady()));
+ connect(&_timerHtmlSearch, SIGNAL(timeout()), this,
+ SLOT(htmlTranslationReady()));
}
Backbone::Backbone(QString pluginPath, QString configPath, QObject *parent)
void Backbone::stopSearching() {
- _timer.stop();
+ _timerSearch.stop();
_innerResult.clear();
foreach(CommonDictInterface* dict, _dicts.keys())
dict->stop();
void Backbone::search(QStringList words) {
- _timer.stop();
+ _timerSearch.stop();
_result.clear();
_innerResult.clear();
- _timer.start(_interval);
+ _timerSearch.start(_interval);
foreach(QString word, words)
foreach(CommonDictInterface* dict, _dicts.keys())
if(_dicts[dict] == 1) {
-void Backbone::translation() {
+void Backbone::translationReady() {
foreach(QFuture<QList<Translation*> > trans, _innerResult) {
if(!trans.isFinished())
continue;
_innerResult.removeOne(trans);
}
if(!_innerResult.size()) {
- _timer.stop();
+ _timerSearch.stop();
Q_EMIT ready();
}
}
}
}
+
+
void Backbone::dictUpdated() {
QDir confDir(_configPath);
if(!confDir.exists())
saveState(&set, dict->settings(), _dicts[dict], dict->hash());
}
+
+
void Backbone::saveState(QSettings* set, Settings* plugSet, bool active
, uint hash) {
if(!set || !plugSet)
set->setValue(section + "/" + key, plugSet->value(key));
set->setValue(section + "/active", active);
}
+
+
+
+QStringList Backbone::htmls() {
+ return _htmlResult;
+}
+
+
+
+void Backbone::searchHtml(QList<Translation *> translations) {
+ _timerHtmlSearch.stop();
+ _htmlResult.clear();
+ _innerHtmlResult.clear();
+ _timerHtmlSearch.start();
+
+ foreach(Translation* trans, translations)
+ _innerHtmlResult.append(
+ QtConcurrent::run(trans, &Translation::toHtml()));
+}
+
+void Backbone::htmlTranslationReady() {
+
+}