cur.exec();
}
-void Bookmarks::add(QString key,QString removeAccentKey,QString value){
+void Bookmarks::add(QString key,QString value){
checkAndCreateDb();
QSqlDatabase db = getDbCnx();
if(!db.isOpen() && !db.open()) {
QSqlQuery cur(db);
cur.prepare("insert into bookmarks values (?,?,?)");
cur.addBindValue(key);
- cur.addBindValue(removeAccentKey);
+ cur.addBindValue(removeAccents(key));
cur.addBindValue(value);
cur.exec();
}
*/
void add(Translation* translation);
- void add(QString key,QString removeAccentKey,QString value);
+ void add(QString key,QString value);
/*! Removes word and corresponding translation cache from bookmarks list
\param translation translation to be removed
bool ConfigGenerator::generateCss(QString file) {
generateFile(":/xsl/style.css", file);
+ return true;
}
SLOT(bookmarksListReady()));
connect(&_bookmarkSearchWatcher, SIGNAL(finished()), this,
SLOT(translationReady()));
+ connect(&_translationsListWatcher, SIGNAL(finished()),
+ this, SLOT(bookmarkReadyFuture()));
// In common opinion perfect thread count is cores_number+1 (in qt perfect
// thread count is set to cores number) so iam changin it
return _xmlResult;
}
-void Backbone::addBookmark(QList<Translation*> translations) {
+void Backbone::addBookmarkFuture(QList<Translation*> translations) {
if(translations.size()>0) {
+ qDebug()<<"size"<<translations.size();
Translation *tr = translations.at(0);
foreach(CommonDictInterface* dict, activeDicts()) {
Translation* trans = dict->getTranslationFor(tr->key());
foreach(translation,translations){
translation->setBookmark(true);
trans.insert(translation->toXml(),translation->key());
-
}
+ _xmlResult.clear();
foreach(QString value,trans.keys()){
+ qDebug()<<"dodaje"<<value;
QString key= trans.value(value);
- _bookmarks.add(key,key,value);
+ _bookmarks.add(key,value);
+ _xmlResult.append(value);
}
+}
+
+void Backbone::addBookmark(QList<Translation*> translations) {
+ _translationsListWatcher.setFuture(QtConcurrent::run(this ,
+ &Backbone::addBookmarkFuture,translations));
+ /* foreach(Translation *trans,translations){
+ _bookmarks.add(trans); */
- // Translation* translation;
- // foreach(translation, translations)
- // _bookmarks.add(translation);
- // emit bookmarkReady();
}
+void Backbone::bookmarkReadyFuture(){
+ qDebug()<<"zaraz stop";
+ emit xmlReady();
+}
void Backbone::searchXml(QList<Translation *> translations) {
_xmlResult.clear();
}
}
- _innerXmlResult = QtConcurrent::mapped(dummy,
- &TranslationPtr::toHtml);
+ _innerXmlResult = QtConcurrent::mapped(dummy, &TranslationPtr::toHtml);
_xmlResultWatcher.setFuture(_innerXmlResult);
}
-
void Backbone::xmlTranslationReady() {
-
QFutureIterator<QString> it(_innerXmlResult);
QSet<QString> uniqe;
while(it.hasNext())
}
-
void Backbone::bookmarksListReady() {
_bookmarksResult = _innerBookmarks.result();
Q_EMIT bookmarksReady();
}
-
-
void Backbone::setSettings(Settings *settings) {
_historyLen = settings->value("history_size").toInt();
_searchLimit = settings->value("search_limit").toInt();
}
-
-
Settings* Backbone::settings() {
Settings * settings = new Settings();
settings->setValue("history_size", QString("%1").arg(_historyLen));
what kind of function may be used there see Qt docs */
static int _searchLimit;
-
+ void addBookmarkFuture(QList<Translation*> translations);
public Q_SLOTS:
//! stops all current searches and emits searchCanceled signal
*/
Settings* settings();
-
-
+ void bookmarkReadyFuture();
QFuture<QList<Translation*> > _innerBookmarks; //Res of search in bookmarks
QFuture<QList<Translation*> > _innerListBookmarks; //Res of search in bookmarks
QFuture<QStringList> _innerXmlBookmarks; //Xml result of bookmarks search
+ QFuture<void> _innerTranslationsList;
+
QMultiHash<QString, Translation*> _result; //Final result of word search
QStringList _xmlResult; // Final result of xml search
QFutureWatcher<QList<Translation*> > _bookmarkWatcher;
QFutureWatcher<QList<Translation*> > _bookmarkSearchWatcher;
QFutureWatcher<QString> _xmlResultWatcher;
+ QFutureWatcher<void> _translationsListWatcher;
QString _pluginPath;
int HistoryListDialog::exec() {
historyListWidget->setFocus();
QDialog::exec();
+ return 0;
}
#ifndef Q_WS_MAEMO_5
hideWelcomeScreen();
#endif
-
Q_EMIT showTranslation(backbone->xmls());
wordListWidget->setFocus();
#ifdef Q_WS_MAEMO_5
}
-
-
-
void MainWindow::searchingInterrupted() {
//make sure to unset exact search mode
setExactSearch(false);
connect(backbone, SIGNAL(closeOk()),
this, SLOT(close()));
-
-
- //connect(wordListWidget, SIGNAL(addBookmark(QList<Translation*>)),
- // this, SIGNAL(setBusy()));
-
- //connect(backbone, SIGNAL(bookmarkReady()),
- // this, SIGNAL(setIdle()));
}
void MainWindow::connectSearchBar() {
connect(wordListWidget, SIGNAL(showTranslation(QList<Translation*>)),
this, SIGNAL(searchTranslations(QList<Translation*>)));
-
-
-
connect(this, SIGNAL(setBusy()),
wordListWidget, SLOT(lockList()));
wordListWidget, SLOT(unlockList()));
connect(wordListWidget, SIGNAL(addBookmark(QList<Translation*>)),
+ this, SIGNAL(setBusy()));
+
+ connect(wordListWidget, SIGNAL(addBookmark(QList<Translation*>)),
backbone, SLOT(addBookmark(QList<Translation*>)));
connect(wordListWidget, SIGNAL(removeBookmark(QList<Translation*>)),
initLanguages();
http = new QHttp();
- connect(http, SIGNAL(done(bool)), this, SLOT(done()));
+ //connect(http, SIGNAL(done(bool)), this, SLOT(done()));
threa=new QThread();
http->moveToThread(threa);
threa->start();
error=http->errorString();
if(lastState!=http->state()) {
lastState=http->state();
- if(lastState==0){
+ if(lastState==0)
done();
- }
}
}
if(error!="" && error!="Unknown error") {
if(!noNetworkErrorShowed) {
noNetworkErrorShowed = true;
+ qDebug()<<error;
Q_EMIT notify(Notify::Warning,
tr("GooglePlugin: %1").arg(error));
}
QString GooglePlugin::jsonParse(QString result) {
- //qDebug()<<"Json"<<result;
int pos=0,pos2=0,index=0,size=0;
QString returnLang;
QString translation;
result+=words.at(i)->at(j)+", ";
result.remove(result.size()-2,2);
}
- //qDebug()<<"PO"<<result;
return result;
}
if((regWord.exactMatch(readKey)
|| regWord.exactMatch(removeAccents(readKey)))
&& (i<limit || limit==0) && !reader.atEnd()) {
- // qDebug()<<readKey;
translations<<(new TranslationXdxf(readKey.toLower(),
_dictionaryInfo,this));
if(translations.size()==limit && limit!=0)
void XdxfPlugin::stop() {
- //qDebug()<<"stop";
stopped=true;
}
if(reader.name()=="full_name")
_name=reader.readElementText();
else
- qDebug()<<"no full_name";
+ qDebug()<<"Dictionary dont have full_name";
reader.readNextStartElement();
if(reader.name()=="description")
_infoNote=reader.readElementText();
else
- qDebug()<<"no description";
+ qDebug()<<"Dictionary dont have description";
_dictionaryInfo= _name + " [" + _langFrom + "-"
+ _langTo + "]";
bool XdxfPlugin::makeCache(QString) {
XdxfCachingDialog d(_dictDialog->lastDialogParent());
-
-// qDebug()<<_dictDialog->lastDialogParent();
-
connect(&d, SIGNAL(cancelCaching()),
this, SLOT(stop()));
connect(this, SIGNAL(updateCachingProgress(int,int)),