*******************************************************************************/
-/*! /file backbone.cpp
+/*! \file backbone.cpp
\brief Backbone/core main header \see Backbone
Each plugin may live in multiple instances - each with its own dictionary,
backbone must provide way to create them at start (with specific Settings) and
- distinguich each ditionary.
+ distinguish each ditionary.
- Backbone also manage bookmarks and history: providing interface to gui
+ Backbone also manages bookmarks and history: providing interface to gui.
Backbone is also responsible for saving and spawning session via configs
file (stored in ~/.mdictionary) -> configs are kind of tricky because
- mDictionary is delivered with two simple dicts -> its necessary to separate default
- configs from user configs (updating/reinstaling app results in overwriten
+ mDictionary is delivered with two simple dicts -> it's necessary to separate default
+ configs from user configs (updating/reinstalling app results in overwritten
default config file), moreover config file there is general mdictionary
- configuration (aparto from dictionaries and plugin ones).
+ configuration (apart from dictionaries and plugin ones).
Other modules may set some internal backbone behaviour via \see setSettings():
Settings object with option given:
* history_size - int, size of stored searches
- * search_limit - int, how many different word may each dictionary returns
+ * search_limit - int, how many different words each dictionary may return
* search_dictionaries - true/false, whether search in dictionaries
* search_bookmarks - true/false, whether search in bookmarks
Searching schema:
First GUI should ask for list of words matching given pattern
- then eatch Translation object is capable of finging it own final translation
+ then each Translation object is capable of finding its own final translation
- List of word:
- - Gui call search(...)
- - Backbone call plugins searchWordList(...) in idealThreadCount()+1 threads
+ List of words:
+ - Gui calls search(...)
+ - Backbone calls plugins searchWordList(...) in idealThreadCount()+1 threads
- Backbone sets the FutureWatcher to be notifed when plugins are done
- - Backbone fetch results from Future<..> and formats it for gui then
+ - Backbone fetches results from Future<..> and formats it for gui then
emits ready()
- Gui calls result()
Final translation:
- - Gui call searchHtml()
- - Backbone starts for eatch translation object toHtml in separate threads
+ - Gui calls searchHtml()
+ - Backbone starts for each translation object toHtml in separate threads
- Backbone sets FutureWatcher to be notified after last toHtml returns
- - Backbone fetch translation from Future<...> objects and calls
+ - Backbone fetches translation from Future<...> objects and calls
htmlReady()
- - gui calls htmlResult()
+ - Gui calls htmlResult()
*/
class Backbone : public QObject
~Backbone();
Backbone(const Backbone& b);
- //! \return all loadded dictionaries with activity state flag
+ //! \return all loaded dictionaries with activity state flag
QHash<CommonDictInterface*, bool> getDictionaries();
- //! \return all loadded plugins
+ //! \return all loaded plugins
QList<CommonDictInterface*> getPlugins();
//! \return history of performed searches
//! \return return search fesult
QMultiHash<QString, Translation*> result();
- //! \return maximum number of word that plugin could find
+ //! \return maximum number of words that plugin could find
int searchLimit() const;
//! \return final translation (after searching for html)
QStringList htmls();
- /*! maximum number of translation that each plugin may return; it must be
- public static becouse of QtConcurent::mapped restrictions about
+ /*! maximum number of translations that each plugin may return; it must be
+ public static because of QtConcurent::mapped restrictions about
what kind of function may be used there see Qt docs */
static int _searchLimit;
public Q_SLOTS:
- //! stops all current searches and emiting searchCanceled signal
+ //! stops all current searches and emits searchCanceled signal
void stopSearching();
- /*! search for a word translation
+ /*! searches for a word translation
\param word to be translated
*/
void search(QString word);
/*! sets active dictionaries (searches are performed only in active dicts
- \param List of dictionaris to be activated
+ \param List of dictionaries to be activated
*/
void selectedDictionaries(QList<CommonDictInterface* >);
- /*! adds new dictionary and activate it
+ /*! adds new dictionary and activates it
\param dict dictionary to be added
\param active decides whether searches are perfomed in given dictionaries
*/
void addDictionary(CommonDictInterface* dict, bool active = 1);
- //! stops all current activity - emiting signal \see closeOk
+ //! stops all current activity - emitting signal \see closeOk
void quit();
*/
void removeDictionary(CommonDictInterface* dict);
- /*! saves plugins new state/configuration after each change */
+ /*! Saves plugins new state/configuration after each change */
void dictUpdated();
/*! Performs search for final translation (html/xml) form
void searchHtml(QList<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
+ /*! 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
*/
void addBookmark(QList<Translation*> translations) {
foreach(Translation* translation, translations)
}
- /*! Remove bookmarks to given translatios
+ /*! Removes bookmarks to given translations
\param translation remove bookmark to this translation
*/
void removeBookmark(QList<Translation*> translations) {
- /*! Remove all bookmarks
+ /*! Removes all bookmarks
*/
void removeAllBookmark(){
_bookmarks.clear();
}
- /*! Searching for list of bookmarks may take some time, so i moved it to
- new thread (to avoid gui blocking), futher its consistent with ordinary
- searching for list of word (\see search)
+ /*! Searching for list of bookmarks may take some time, so I moved it to
+ new thread (to avoid gui blocking), further it's consistent with ordinary
+ searching for list of words (\see search)
*/
void fetchBookmarks() {
_result.clear();
/*! Sets settings for backbone: history_size, search_limit,
searching backends (search_bookmarks, search_dictionaries)
- \param settings settings object with opitons set
+ \param settings settings object with options set
*/
void setSettings(Settings* settings);
- /*! \return coresponding settings object with history_size, search_limit,
+ /*! \return corresponding settings object with history_size, search_limit,
searching backends (search_bookmarks, search_dictionaries)
*/
Settings* settings();
Q_SIGNALS:
- /*! emmited when backbone is ready to close - after getting stop signal it
+ /*! emitted when backbone is ready to close - after getting stop signal it
should kill all threads and so on */
void closeOk();
- //! emitted when there are search result ready to fetch
+ //! emitted when there are search results ready to fetch
void ready();
//! emitted when html result is ready to fetch
void htmlReady();
- //! throwed when searches are stopped
+ //! thrown when searches are stopped
void searchCanceled();
- //! emmited when bookmark list is ready to fetch
+ //! emitted when bookmark list is ready to fetch
void bookmarksReady();
- /*! emited by direct connection to plugins notifying signals
- \param Notify::NotifyType gui my dacide to show different typet in
+ /*! 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
*/
QList<CommonDictInterface*> _plugins; // List of plugins
- QFuture<QList<Translation*> > _innerResult; //Res of concurent word search
+ QFuture<QList<Translation*> > _innerResult; //Res of concurrent word search
QFuture<QString> _innerHtmlResult; // Result of html search
QFuture<QList<Translation*> > _innerBookmarks; //Res of search in bookmarks
QFuture<QList<Translation*> > _innerListBookmarks; //Res of search in bookmarks
int _defaultSearchLimit;
int _historyLen, _defaultHistoryLen;
- bool dryRun; // mainly for testing - when true then dosent bother configs etc
+ bool dryRun; // mainly for testing - when true then doesn't bother configs etc
bool stopped; // true when user stops searching/fetching
- bool bookmarkFin, dictFin; // inform whether givent search type is ready
- bool _searchDicts, _searchBookmarks; // whether perform search in given source
+ bool bookmarkFin, dictFin; // inform whether given search type is ready
+ bool _searchDicts, _searchBookmarks; // whether search performed in given source
Bookmarks _bookmarks;