#include "../../includes/settings.h"
#include "../../includes/translation.h"
#include "../../includes/History.h"
+#include "Bookmarks.h"
/*! Inner part of dictionary - glues together GUI and plugins
*/
void searchHtml(QList<Translation*>);
- // TODO addToBookmark(Translation*);
- // TODO removeFromBookmark(Translation*);
+
+ /*! add 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
+ */
+ void addBookmark(QList<Translation*> translations) {
+ foreach(Translation* translation, translations)
+ QtConcurrent::run(&bookmarks, &Bookmarks::add, translation);
+ }
+
+
+ /*! Remove bookmarks to given translatios
+ \param translation remove bookmark to this translation
+ */
+ void removeBookmark(QList<Translation*> translations) {
+ foreach(Translation* translation, translations)
+ bookmarks.remove(translation);
+ }
+
+
+ /*! Searching for list of bookmarks may take some time, so i moved it to
+ new thread (to avoid gui blocking), when ready bookmarksReady is emited
+ and result is returned after calling getBookmarks()
+ */
+ void fetchBookmarks() {
+ _bookmarksResult.clear();
+ _innerBookmarks = QtConcurrent::run(bookmarks, &Bookmarks::list);
+ _bookmarkWatcher.setFuture(_innerBookmarks);
+ }
+
+ /*! \return list of all bookmarks
+ */
+ QList<Translation*> getBookmarks() {
+ return _bookmarksResult;
+ }
+
+
Q_SIGNALS:
/*! emmited when backbone is ready to close - after getting stop signal it
//! throwed when searches are stopped
void searchCanceled();
+ //! emmited when bookmark list is ready to fetch
+ void bookmarksReady();
+
+private Q_SLOTS:
+ void bookmarksListReady();
private:
QList<CommonDictInterface*> _plugins;
QFuture<QList<Translation*> > _innerResult;
QFuture<QString> _innerHtmlResult;
+ QFuture<QList<Translation*> > _innerBookmarks;
QMultiHash<QString, Translation*> _result;
QStringList _htmlResult;
+ QList<Translation*> _bookmarksResult;
//QTime _time;
QString _pluginPath, _defaultPluginPath;
QString _configPath;
QString _defaultConfigPath;
QFutureWatcher<QList<Translation*> > _resultWatcher;
+ QFutureWatcher<QList<Translation*> > _bookmarkWatcher;
QFutureWatcher<QString> _htmlResultWatcher;
int _searchLimit, _defaultSearchLimit;
int _activeSearchNum;
int _historyLen, _defaultHistoryLen;
bool dryRun;
bool stopped;
+ Bookmarks bookmarks;
void init();