Fix random error when remove word from bookmark. Fix show all bookmark feature.
[mdictionary] / src / mdictionary / backbone / backbone.h
index a9f05c0..f59bc3d 100644 (file)
 #include <QTime>
 #include <QDir>
 #include <QThread>
+#include <QDebug>
 #include <QSettings>
 #include <QFutureWatcher>
+#include <QMultiMap>
 #include "../../include/CommonDictInterface.h"
 #include "../../include/settings.h"
 #include "../../include/translation.h"
@@ -80,7 +82,7 @@
      * search_bookmarks - true/false, whether search in bookmarks
 
     Searching schema:
-        At first GUI should ask for list of words matching given pattern,
+        At first GUI should ask for a list of words matching a given pattern,
         then each Translation object is capable of finding its own final translation
 
       List of words:
@@ -105,9 +107,9 @@ class Backbone : public QObject
     Q_OBJECT
 
 public:
-    /*!\param pluginPath path to plugins (leave blank for default)
-      \param configPath path to folder with configuration files
-      \param dry dry run is mode without paying attention to configuration etc
+    /*! \param pluginPath path to plugins (leave blank for default)
+        \param configPath path to folder with configuration files
+        \param dry dry run is mode without paying attention to configuration etc
           mainly for testing
       */
     Backbone(QString pluginPath="", QString configPath="",
@@ -124,7 +126,7 @@ public:
     //! \return history of performed searches
     History* history();
 
-    //! \return return search fesult
+    //! \return search fesult
     QMultiHash<QString, Translation*> result();
 
     //! \return maximum number of words that plugin could find
@@ -145,16 +147,16 @@ public Q_SLOTS:
     void stopSearching();
 
     /*! searches for a word translation
-       \param word to be translated
+       \param word word to be translated
       */
     void search(QString word);
 
     /*! sets active dictionaries (searches are performed only in active dicts)
        \param List of dictionaries to be activated
       */
-    void selectedDictionaries(QList<CommonDictInterface* >);
+    void selectedDictionaries(QList<CommonDictInterface*>);
 
-    /*! adds new dictionary and activates it
+    /*! adds a new dictionary and activates it
       \param dict dictionary to be added
       \param active decides whether searches are perfomed in given dictionaries
       */
@@ -165,7 +167,7 @@ public Q_SLOTS:
     void quit();
 
 
-    /*! Fired by FutureWatcher when list of words is ready (after calling search)
+    /*! Fired by FutureWatcher when a list of words is ready (after calling search),
         fetch Future<...> to final result
       */
     void translationReady();
@@ -175,7 +177,7 @@ public Q_SLOTS:
       */
     void xmlTranslationReady();
 
-    /*! Removes given dictionary
+    /*! Removes a given dictionary
         \param dict dictionary to be deleted
       */
     void removeDictionary(CommonDictInterface* dict);
@@ -191,17 +193,13 @@ public Q_SLOTS:
 
     /*! adds bookmarks to given translations (translation object is fetched and
       added to bookmarks data base (key and translation stored in db))
-      \param translation translation object to be stored in db
+      \param translations list of Translation objects to be stored in db
       */
-    void addBookmark(QList<Translation*> translations) {
-        foreach(Translation* translation, translations)
-            //_bookmarks.add(translation);
-            QtConcurrent::run(_bookmarks, &Bookmarks::add, translation);
-    }
+    void addBookmark(QList<Translation*> translations);
 
 
     /*! Removes bookmarks to given translations
-      \param translation remove bookmark to this translation
+      \param translations remove bookmark to these translations
       */
     void removeBookmark(QList<Translation*> translations) {
         foreach(Translation* translation, translations)
@@ -217,7 +215,7 @@ public Q_SLOTS:
     }
 
 
-   /*! Searching a list of bookmarks may take some time, so I moved it to
+   /*! Searching a list of bookmarks may take some time, so it's moved to a
        new thread (to avoid GUI blocking), further it's consistent with ordinary
        searching a list of words (\see search)
        */
@@ -231,9 +229,10 @@ public Q_SLOTS:
         _innerBookmarks = QtConcurrent::run(_bookmarks,
                 &Bookmarks::list);
         _bookmarkSearchWatcher.setFuture(_innerBookmarks);
-   }
-
 
+        Q_EMIT bookmarkMode();
+        qDebug()<<"1";
+   }
 
    /*! Sets settings for backbone: history_size, search_limit,
        searching backends (search_bookmarks, search_dictionaries)
@@ -241,7 +240,6 @@ public Q_SLOTS:
        */
     void setSettings(Settings* settings);
 
-
     /*! \return corresponding settings object with history_size, search_limit,
        searching backends (search_bookmarks, search_dictionaries)
        */
@@ -272,10 +270,14 @@ Q_SIGNALS:
     /*! emitted by direct connection to plugins notifying signals
         \param Notify::NotifyType GUI may decide to show different types in
             different ways
-        \param QString text of the notification
+        \param text of the notification
     */
     void notify(Notify::NotifyType, QString);
 
+    void bookmarkReady();
+
+    void bookmarkMode();
+
 private Q_SLOTS:
     void bookmarksListReady();