From 7ced0355f99cd3fc69bb94d4fbf52bee38a85d59 Mon Sep 17 00:00:00 2001 From: Bartosz Szatkowski Date: Tue, 17 Aug 2010 13:22:49 +0200 Subject: [PATCH] Added isBookmark() to translation and other changes to inform gui about bookmarked translation --- trunk/src/base/backbone/BookmarkTranslations.h | 1 + trunk/src/includes/translation.h | 14 ++++++++++++++ trunk/src/plugins/xdxf/src/xdxfplugin.cpp | 12 +++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/trunk/src/base/backbone/BookmarkTranslations.h b/trunk/src/base/backbone/BookmarkTranslations.h index 5a89ce4..29ff21e 100644 --- a/trunk/src/base/backbone/BookmarkTranslations.h +++ b/trunk/src/base/backbone/BookmarkTranslations.h @@ -41,6 +41,7 @@ public: _key = key; _dictionaryInfo = dbName; _bookmarks = bookmarks; + _bookmark = 1; } //! \return word to be translated diff --git a/trunk/src/includes/translation.h b/trunk/src/includes/translation.h index 8d4332b..c32e75d 100644 --- a/trunk/src/includes/translation.h +++ b/trunk/src/includes/translation.h @@ -37,6 +37,7 @@ as late as possible*/ class Translation { public: + Translation () { _bookmark = 0; } //! \return word to be translated virtual QString key() const = 0; @@ -51,6 +52,19 @@ class Translation { //! \return parsed raw format into html virtual QString toHtml() const = 0; + //! \retrun whether given translation is taken from bookmarks + bool isBookmark() const { + return _bookmark; + } + + //! \param b if true then translation is from bookmarks + void setBookmark(bool b) { + _bookmark = b; + } + + protected: + bool _bookmark; + }; Q_DECLARE_METATYPE(Translation*); diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp index cab4493..42312e4 100644 --- a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp +++ b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp @@ -89,6 +89,7 @@ QList XdxfPlugin::searchWordListCache(QString word, int limit) { stopped = false; if(word.indexOf("*")==-1 && word.indexOf("?")== 0) word+="%"; + word = word.toLower(); word = word.replace("*", "%"); word = word.replace("?", "_"); word = removeAccents(word); @@ -100,8 +101,9 @@ QList XdxfPlugin::searchWordListCache(QString word, int limit) { cur.addBindValue(limit); cur.exec(); while(cur.next()) - translations.insert(new TranslationXdxf(cur.value(0).toString(), - _infoNote, this)); + translations.insert(new TranslationXdxf( + cur.value(0).toString().toLower(), + _infoNote, this)); return translations.toList(); } @@ -111,6 +113,7 @@ QList XdxfPlugin::searchWordListFile(QString word, int limit) { QSet translations; QFile dictionaryFile(path); + word = word.toLower(); word = removeAccents(word); stopped = false; @@ -141,7 +144,8 @@ QList XdxfPlugin::searchWordListFile(QString word, int limit) { ok=false; /*if key word is in the dictionary more that one */ } if(ok) /*add key word to list*/ - translations<<(new TranslationXdxf(a,_infoNote,this)); + translations<<(new TranslationXdxf(a.toLower(), + _infoNote,this)); i++; if(i>=limit && limit!=0) break; @@ -167,6 +171,7 @@ QString XdxfPlugin::searchCache(QString key) { QString result; QString cacheFilePath = _settings->value("cache_path"); db.setDatabaseName(cacheFilePath); + key = key.toLower(); if(!db.open()) { qDebug() << "Database error" << db.lastError().text() << endl; @@ -187,6 +192,7 @@ QString XdxfPlugin::searchCache(QString key) { QString XdxfPlugin::searchFile(QString key) { + key = key.toLower(); QFile dictionaryFile(path); QString resultString(""); if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) { -- 1.7.9.5