Added isBookmark() to translation and other changes to inform gui about
authorBartosz Szatkowski <bulislaw@linux.com>
Tue, 17 Aug 2010 11:22:49 +0000 (13:22 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Tue, 17 Aug 2010 11:22:49 +0000 (13:22 +0200)
bookmarked translation

trunk/src/base/backbone/BookmarkTranslations.h
trunk/src/includes/translation.h
trunk/src/plugins/xdxf/src/xdxfplugin.cpp

index 5a89ce4..29ff21e 100644 (file)
@@ -41,6 +41,7 @@ public:
         _key = key;
         _dictionaryInfo = dbName;
         _bookmarks = bookmarks;
+        _bookmark = 1;
     }
 
     //! \return word to be translated
index 8d4332b..c32e75d 100644 (file)
@@ -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*);
index cab4493..42312e4 100644 (file)
@@ -89,6 +89,7 @@ QList<Translation*> 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<Translation*> 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<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
     QSet<Translation*> translations;
     QFile dictionaryFile(path);
 
+    word = word.toLower();
     word = removeAccents(word);
 
     stopped = false;
@@ -141,7 +144,8 @@ QList<Translation*> 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)) {