Merge branch 'master' into google
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Thu, 26 Aug 2010 06:47:46 +0000 (08:47 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Thu, 26 Aug 2010 06:47:46 +0000 (08:47 +0200)
Conflicts:
trunk/src/base/backbone/backbone.cpp
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/SearchBarWidget.cpp

57 files changed:
styles.css [new file with mode: 0644]
trunk/src/base/backbone/BookmarkTranslations.h
trunk/src/base/backbone/Bookmarks.h
trunk/src/base/backbone/History.cpp
trunk/src/base/backbone/backbone.cpp
trunk/src/base/backbone/backbone.h
trunk/src/base/gui/BookmarksWidget.h
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictManagerWidget.h
trunk/src/base/gui/DictTypeSelectDialog.h
trunk/src/base/gui/HistoryListDialog.h
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MainWindow.h
trunk/src/base/gui/MenuTabWidget.cpp
trunk/src/base/gui/MenuTabWidget.h
trunk/src/base/gui/MenuWidget.cpp
trunk/src/base/gui/MenuWidget.h
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/gui/SearchBarWidget.h
trunk/src/base/gui/SettingsWidget.cpp
trunk/src/base/gui/SettingsWidget.h
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/gui/TranslationWidget.h
trunk/src/base/gui/WelcomeScreenWidget.h
trunk/src/base/gui/WordListProxyStyle.h
trunk/src/base/gui/WordListWidget.cpp
trunk/src/base/gui/WordListWidget.h
trunk/src/base/xsl.xsl
trunk/src/includes/CommonDictInterface.h
trunk/src/includes/DictDialog.h
trunk/src/includes/GUIInterface.h
trunk/src/includes/settings.h
trunk/src/includes/translation.h
trunk/src/plugins/google/google.pro [new file with mode: 0644]
trunk/src/plugins/google/src/GoogleDictDialog.cpp [new file with mode: 0644]
trunk/src/plugins/google/src/GoogleDictDialog.h [new file with mode: 0644]
trunk/src/plugins/google/src/GooglePlugin.cpp [new file with mode: 0644]
trunk/src/plugins/google/src/GooglePlugin.h [new file with mode: 0644]
trunk/src/plugins/google/src/GoogleSettingsDialog.cpp [new file with mode: 0644]
trunk/src/plugins/google/src/GoogleSettingsDialog.h [new file with mode: 0644]
trunk/src/plugins/google/src/TranslationGoogle.cpp [new file with mode: 0644]
trunk/src/plugins/google/src/TranslationGoogle.h [new file with mode: 0644]
trunk/src/plugins/google/src/icons.qrc [new file with mode: 0644]
trunk/src/plugins/google/src/src.pro [new file with mode: 0644]
trunk/src/plugins/google/tests/test.cpp [new file with mode: 0644]
trunk/src/plugins/google/tests/test.h [new file with mode: 0644]
trunk/src/plugins/google/tests/tests.pro [new file with mode: 0644]
trunk/src/plugins/plugins.pro
trunk/src/plugins/xdxf/src/TranslationXdxf.cpp
trunk/src/plugins/xdxf/src/TranslationXdxf.h
trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp
trunk/src/plugins/xdxf/src/XdxfDictDialog.h
trunk/src/plugins/xdxf/src/XdxfLoadDialog.h
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.h
trunk/tests/mDictionaryTests/tst_Backbone.cpp

diff --git a/styles.css b/styles.css
new file mode 100644 (file)
index 0000000..d606bf3
--- /dev/null
@@ -0,0 +1,8 @@
+table,th,td{border-style:solid;border-color:black;}
+th.info{background-color:#99FF99;}
+th.key{background-color:#99CCFF;}
+/*p{margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;font-style:italic}*/
+p{display:inline;font-style:italic;}
+
+
index 7f2dd6a..ab7ecf3 100644 (file)
@@ -19,9 +19,9 @@
 
 *******************************************************************************/
 
-/*! /file BookmarkTranslation.h
-\brief Bookmarks functionality needs its own translation  object - becouse
-    Translation object should use slighty different api of Bookmarks objects
+/*! \file BookmarkTranslation.h
+\brief Bookmarks functionality needs its own translation  object - because
+    Translation object should use slightly different api of Bookmarks objects
 
 \author Bartosz Szatkowski <bulislaw@linux.com>
 */
index 3726415..700b8da 100644 (file)
@@ -19,9 +19,9 @@
 
 *******************************************************************************/
 
-/*! /file Bookmarks.h
+/*! \file Bookmarks.h
 \brief Bookmarks functionality - marking words as favorite, managing marked
-    words, searching in marked words (witch cached translations)
+    words, searching in marked words (with cached translations)
 
 
 \author Bartosz Szatkowski <bulislaw@linux.com>
@@ -48,9 +48,9 @@ class BookmarkTranslation;
 /*! Bookmarks are way to store words that You think You will need to search
   for often.
 
-  When You add bookmark (by clickin on "star" in words list) You adds it to
+  When You add bookmark (by clickin on "star" in words list) You add it to
   special list with cached translations from all available dictionaries so
-  You can search for them quickly even when You delete coresponding dict.
+  You can search for them quickly even when You delete corresponding dict.
   */
 class Bookmarks
 {
@@ -62,31 +62,31 @@ public:
     */
     void add(Translation* translation);
 
-    /*! Removes word and coresponding translation cache from bookmark list
+    /*! Removes word and corresponding translation cache from bookmark list
         \param translation translation to be removed
     */
     void remove(Translation* translation);
 
     /*! \return all bookmarks (word and translation as a translation object
-     as a list
+     as a list)
      */
     QList<Translation*> list();
 
-    /*! search in bookmarks for given word (wildcards may apply '*' and '?')
+    /*! Searches in bookmarks for given word (wildcards may apply '*' and '?')
       \param word to search for
       \return list of matching Translation objects
       */
     QList<Translation*> searchWordList(QString word);
 
-    /*! Search for final translation of given word
-      \return word translation list in text format xml or html to be formated
+    /*! Searches for final translation of given word
+      \return word translation list in text format xml or html to be formatted
         and displayed
       \param word word to search for
       */
     QStringList search(QString word, QString dbname);
 
 
-    /*! clars bookmarks database */
+    /*! Clears bookmarks database */
     void clear();
 
 
index f4bd934..4693149 100644 (file)
@@ -65,7 +65,7 @@ void History::add(QString word) {
             return;
     }
 
-    //if we are not in head, we deleted everything ahed us
+    //if we are not in head, we deleted everything ahead of us
     if(currentElement > 0) {
         _history.remove(0, currentElement);
     }
@@ -96,7 +96,7 @@ void History::add(QString word) {
         _listAvailable = true;
     }
 
-    emit historyChanged(_prevAvailable,
+    Q_EMIT historyChanged(_prevAvailable,
                         _nextAvailable,
                         _listAvailable);
 }
@@ -111,7 +111,7 @@ QString History::previous() {
             _prevAvailable = false;
         }
 
-        emit historyChanged(_prevAvailable,
+        Q_EMIT historyChanged(_prevAvailable,
                             _nextAvailable,
                             _listAvailable);
 
@@ -130,7 +130,7 @@ QString History::next() {
            _nextAvailable = false;
         }
 
-        emit historyChanged(_prevAvailable,
+        Q_EMIT historyChanged(_prevAvailable,
                             _nextAvailable,
                             _listAvailable);
 
@@ -181,13 +181,13 @@ void History::setCurrentElement(int element) {
         _prevAvailable = false;
     }
 
-    emit historyChanged(_prevAvailable,
+    Q_EMIT historyChanged(_prevAvailable,
                         _nextAvailable,
                         _listAvailable);
 }
 
 void History::refreshStatus() {
-    emit historyChanged(_prevAvailable,
+    Q_EMIT historyChanged(_prevAvailable,
                         _nextAvailable,
                         _listAvailable);
 }
index 451ca9f..fe99eec 100644 (file)
@@ -305,9 +305,9 @@ void Backbone::translationReady() {
 QStringList Backbone::getFilesFromDir(QString dir, QStringList nameFilter) {
     QDir plug(QDir::toNativeSeparators(dir));
     if(!plug.exists()) {
-        qDebug() << plug.absolutePath() << " folder dosen't exists";
+        qDebug() << plug.absolutePath() << " folder doesn't exist";
         Q_EMIT notify(Notify::Warning,
-                QString("%1 folder dosen't exists.").arg(plug.path()));
+                QString("%1 folder doesn't exist.").arg(plug.path()));
         return QStringList();
     }
     plug.setFilter(QDir::Files);
@@ -359,10 +359,10 @@ void Backbone::loadPrefs(QString fileName) {
     QFileInfo file(QDir::toNativeSeparators(fileName));
     QDir confDir(file.dir());
     if(!confDir.exists()){
-        qDebug() << "Configuration file dosn't exists ("
+        qDebug() << "Configuration file doesn't exist ("
                 << file.filePath() << ")";
         Q_EMIT notify(Notify::Warning,
-                QString("%1 configurationfile dosen't exists.")
+                QString("%1 configuration file doesn't exist.")
                 .arg(file.filePath()));
         return;
     }
@@ -405,10 +405,10 @@ void Backbone::loadDicts(QString fileName, bool _default) {
     QFileInfo file(QDir::toNativeSeparators(fileName));
     QDir confDir(file.dir());
     if(!confDir.exists()){
-        qDebug() << "Configuration file dosn't exists ("
+        qDebug() << "Configuration file doesn't exist ("
                 << file.filePath() << ")";
         Q_EMIT notify(Notify::Warning,
-                QString("%1 configurationfile dosen't exists.")
+                QString("%1 configurationfile doesn't exist.")
                 .arg(file.filePath()));
         return;
     }
@@ -423,9 +423,9 @@ void Backbone::loadDicts(QString fileName, bool _default) {
         if(!plug) {
             qDebug() << "Config file error: "
                     << set.value(dict + "/type", "").toString()
-                    << " dosen't exists";
+                    << " doesn't exist";
             Q_EMIT notify(Notify::Warning,
-                    QString("Configuration file error. %2 plugin dosen't exists.")
+                    QString("Configuration file error. %2 plugin doesn't exist.")
                     .arg(set.value(dict + "/type", "").toString()));
             continue;
         }
index 6ca7ff2..d19bc70 100644 (file)
@@ -19,7 +19,7 @@
 
 *******************************************************************************/
 
-/*! /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
@@ -113,10 +113,10 @@ public:
     ~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
@@ -125,41 +125,41 @@ public:
     //! \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();
 
 
@@ -178,7 +178,7 @@ public Q_SLOTS:
       */
     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
@@ -187,9 +187,9 @@ public Q_SLOTS:
     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)
@@ -198,7 +198,7 @@ public Q_SLOTS:
     }
 
 
-    /*! Remove bookmarks to given translatios
+    /*! Removes bookmarks to given translations
       \param translation remove bookmark to this translation
       */
     void removeBookmark(QList<Translation*> translations) {
@@ -208,16 +208,16 @@ public Q_SLOTS:
 
 
 
-    /*! Remove all bookmarks
+    /*! Removes all bookmarks
       */
     void removeAllBookmarks(){
         _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();
@@ -237,12 +237,12 @@ public Q_SLOTS:
 
    /*! 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();
@@ -253,24 +253,24 @@ public Q_SLOTS:
 
 
 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
     */
@@ -285,7 +285,7 @@ private:
     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
@@ -309,10 +309,10 @@ private:
     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;
 
index a095f3e..288b7e2 100644 (file)
@@ -32,7 +32,7 @@
 
 //! Implements bookmarks management widget
 /*!
-  Allow user to show all or remove all bookmarks
+  Allows user to show all or remove all bookmarks
   */
 class BookmarksWidget : public QDialog
 {
index b34f7c1..157aa2f 100644 (file)
@@ -152,7 +152,6 @@ void DictManagerWidget::saveChanges() {
         }
         emit selectedDictionaries(checkedDicts);
     }
-
     _changed = false;
 }
 
@@ -172,7 +171,7 @@ void DictManagerWidget::addNewDictButtonClicked() {
 
         if(settings != NULL) {
             CommonDictInterface* newDict = selectedPlugin->getNew(settings);
-            emit addDictionary(newDict);
+            Q_EMIT addDictionary(newDict);
             refreshDictsList();
         }
     }
index ab5547b..56abbd5 100644 (file)
@@ -34,7 +34,7 @@
 //! Implements dictionaries management widget
 /*!
   Shows list of loaded dictionaries and their states (active/inactive).
-  It allow to change dicts states, add new dict, remove selected one or
+  It allows to change dicts states, add new dict, remove selected one or
   change settings of selected dict. All changes are saved automatically after
   hiding of this widget.
   */
@@ -54,17 +54,17 @@ protected:
     void hideEvent(QHideEvent *e);
 
 Q_SIGNALS:
-    //! Emited when hiding widget, it will save states of dictionaries
+    //! Emitted when hiding widget, it will save states of dictionaries
     /*! \param list of only active dictionaries
       */
     void selectedDictionaries(QList<CommonDictInterface*>);
 
-    //! Emited when user wants to add new dictionary
-    /*! \param new dictionary returned by specyfic plugin dialog
+    //! Emitted when user wants to add new dictionary
+    /*! \param new dictionary returned by specific plugin dialog
       */
     void addDictionary(CommonDictInterface*);
 
-    //! Emited when user wants to remove dictionary
+    //! Emitted when user wants to remove dictionary
     /*! \param dictionary which will be removed
       */
     void removeDictionary(CommonDictInterface*);
@@ -77,7 +77,7 @@ private Q_SLOTS:
         later passed as parameter of addDictionary signal*/
     void addNewDictButtonClicked();
 
-    /*! Pass selected dictionary from list as parameter of removeDictionary
+    /*! Passes selected dictionary from list as parameter of removeDictionary
         signal */
     void removeButtonClicked();
     void itemSelected(QListWidgetItem*);
index cb805db..6b0537e 100644 (file)
@@ -32,7 +32,7 @@
 #define PLUGIN_ROW_ROLE 99      //TODO remove this
 
 
-//! Implements pluigin selection dialog
+//! Implements plugin selection dialog
 /*!
   Shows list of loaded dictionaries plugins.
   Static function addNewdict will return selected plugin.
@@ -44,13 +44,13 @@ public:
     /*!
       \param plugins list of loaded plugins
       \param parent widget
-      \return selected plugin, if user cancel dialog it returns NULL
+      \return selected plugin, if user cancels dialog it returns NULL
       */
     static CommonDictInterface* addNewDict(
             QList<CommonDictInterface* > plugins,
             QWidget *parent = 0);
 
-    //! Returns selected by user plugin
+    //! Returns plugin selected by user
     CommonDictInterface* selectedPlugin();
 
 protected:
index 84d7cfe..b9aea76 100644 (file)
@@ -33,7 +33,7 @@
 
 //! Implements history list dialog
 /*!
-  Shows history list and allow user to select one word of it.
+  Shows history list and allows user to select one word of it.
   */
 class HistoryListDialog : public QDialog
 {
index bd58ab0..42b1b2f 100644 (file)
@@ -62,7 +62,7 @@ void MainWindow::initializeUI() {
         setAttribute(Qt::WA_Maemo5StackedWindow);
     #endif
 
-    //translationWidget is antoher stacked window, so we don't add it to layout
+    //translationWidget is another stacked window, so we don't add it to layout
     //only create it with this widget as parent
     translationWidget = new TranslationWidget(this);
 
@@ -142,8 +142,8 @@ void MainWindow::initializeUI() {
 }
 
 void MainWindow::closeEvent(QCloseEvent *event) {
-    //reqest to stop all searches and close app
-        emit quit();
+    //request to stop all searches and close app
+        Q_EMIT quit();
         event->accept();
 }
 
@@ -180,7 +180,7 @@ void MainWindow::wordListReady() {
         showNotify(Notify::Info, tr("Can't find any matching words"));
 
         //show empty list to remove results of old search
-        emit showWordList(searchResult);
+        Q_EMIT showWordList(searchResult);
     }
     else {
         //find translations of the same key word
@@ -191,19 +191,19 @@ void MainWindow::wordListReady() {
 
 
         if(!exactSearch()) {
-            emit showWordList(searchResult);
+            Q_EMIT showWordList(searchResult);
         }
         else {
             #ifndef Q_WS_MAEMO_5
             //on desktop we show word list in exact search
-                emit showWordList(searchResult);
+                Q_EMIT showWordList(searchResult);
             #endif
             bool foundExactMatch = false;
             QHash<QString, QList<Translation*> >::iterator j;
             for(j = searchResult.begin(); j != searchResult.end(); j++) {
                 if(j.key() == searchString && !foundExactMatch) {
                     foundExactMatch = true;
-                    emit searchTranslations(j.value());
+                    Q_EMIT searchTranslations(j.value());
                     break;
                 }
             }
@@ -212,7 +212,7 @@ void MainWindow::wordListReady() {
                 showNotify(Notify::Info,
                            tr("Can't find exactly matching word"));
 
-                emit showWordList(searchResult);
+                Q_EMIT showWordList(searchResult);
             }
 
         }
@@ -232,7 +232,7 @@ void MainWindow::translationsReady() {
     }
     #endif
 
-    emit showTranslation(backbone->htmls());
+    Q_EMIT showTranslation(backbone->htmls());
 }
 
 QList<CommonDictInterface*> MainWindow::getPlugins() {
@@ -251,7 +251,7 @@ void MainWindow::search(QString word) {
 
 void MainWindow::searchExact(QString word) {
     setExactSearch(true);
-    //searching with searchBar, not directly by emiting searchWordList(),
+    //searching with searchBar, not directly by emitting searchWordList(),
     //because it will set search word in searchBar's edit line
     //this function is only used by history and when searching from attributes
     searchBarWidget->search(word);
index 2a5ae66..e65769b 100644 (file)
@@ -43,9 +43,9 @@
 
 //! Implements interface for GUI
 /*!
-  Create all of GUI subcomponents, and connects all GUI interface signals with
+  Creates all of GUI subcomponents, and connects all GUI interface signals with
   suitable backbone signals and slots. Only this class has direct access to
-  backbone object. It manages all request of subcomponents e. g. searching of
+  backbone object. It manages all requests of subcomponents e. g. searching of
   given word, displaying history, removing dictionary.
   It also provide data from backbone to subcomponents e. g. result of search.
 */
@@ -56,7 +56,7 @@ class MainWindow : public GUIInterface
 public:
     //! Constructor
     /*!
-      \param backbone object which will doing all searches and returns data
+      \param backbone object which will be doing all searches and returning data
       \param parent parent widget of this window
       */
 
@@ -78,19 +78,19 @@ public:
     QList<CommonDictInterface*> getPlugins();
 
     //! Indicates if GUI is in exact search mode.
-    /*! When GUI is in exact search mode it search for word, and
-        if find exacly matching translation it directly displays it, whithout
+    /*! When GUI is in exact search mode it searches for word, and
+        if it finds exactly matching translation it directly displays it, without
         displaying matching word list. This mode is used for browsing search
-        history and search words from application arguments.
+        history and searching words from application arguments.
         \returns flag indicating if GUI is in exact search mode
     */
     bool exactSearch();
 
     //! Sets GUI exact search mode.
-    /*! When GUI is in exact search mode it search for word, and
-        if find exacly matching translation it directly displays it, whithout
+    /*! When GUI is in exact search mode it searches for word, and
+        if it finds exactly matching translation it directly displays it, without
         displaying matching word list. This mode is used for browsing search
-        history and search words from application arguments.
+        history and searching words from application arguments.
         \param exactSearch flag indicating if GUI will be in exact search mode
         \sa exactSearch()
     */
@@ -99,7 +99,7 @@ public:
 
     //! Returns current settings.
     /*!
-       \returns Settings object containing curren application settings
+       \returns Settings object containing current application settings
       */
     Settings* settings();
 
@@ -112,9 +112,9 @@ public:
 
 
  public Q_SLOTS:
-    //! Search in exact mode for given word
+    //! Searches in exact mode for given word
     /*!
-      GUI will be automaticaly set into exact search mode, and after search or
+      GUI will be automatically set into exact search mode, and after search or
       break will be unset from exact search mode.
       \param word which will be searched in dictionaries
       */
@@ -134,20 +134,20 @@ public:
       Checks if received list is empty, in that case displays suitable
       information. If GUI is in exact search mode it will search for exact
       word in received list, and if word is found it will emit signal to
-      display it's translation. Otherwise it will display list of matching
+      display its translation. Otherwise it will display list of matching
       words and show suitable information.
       \sa exactSearch()
       \sa showTranslation()
      */
     void wordListReady();
 
-    //! Gets translation strings from backbone and emit signal to display them
+    //! Gets translation strings from backbone and emits signal to display them
     void translationsReady();
 
     //! Adds to history key words from given translations
     /*!
-      By default this slot is connected to signal searchTranslations, and
-      passed translation list contains only translation with the same key, so
+      By default this slot is connected to searchTranslations signal, and
+      passed translation list contains only translations with the same key, so
       only one word is added to history.
       \param list of translations with key words
       \sa searchTranslations()
@@ -187,7 +187,7 @@ private Q_SLOTS:
     //! Enables menu
     void enableMenu();
 
-    //! When user break searching it make sure that exact search mode will be
+    //! When user breaks searching it makes sure that exact search mode will be
     //! disabled
     void breakSearching();
 
@@ -196,7 +196,7 @@ private Q_SLOTS:
 
 
 protected:
-    /*! When user wants to close application, we first sends signal to stop all
+    /*! When user wants to close application, we first send signal to stop all
         ongoing searches.
     */
     void closeEvent(QCloseEvent *);
index 0b52973..f2585bb 100644 (file)
@@ -31,7 +31,7 @@ MenuTabWidget::MenuTabWidget(QWidget *parent) :
 
 
 void MenuTabWidget::hideEvent(QHideEvent *e) {
-    //just set parent to null, and allow event to by handled by default handler
+    //just set parent to null, and allow event to be handled by default handler
     setParent(NULL);
 
 
index b78e909..cb7c915 100644 (file)
@@ -38,8 +38,8 @@ public:
 protected:
     /*!
       Reimplemented default hideEvent function.
-      Right before hide widget it sets it's parent to NULL, which prevent
-      widget to be deleted by menu bar.
+      Right before hiding widget it sets its parent to NULL, which prevents
+      widget from being deleted by menu bar.
     */
     void hideEvent(QHideEvent *);
 };
index fa6210b..0df9e24 100644 (file)
@@ -35,7 +35,7 @@ MenuWidget::MenuWidget(QWidget *parent) :
 }
 
 MenuWidget::~MenuWidget() {
-    //because tabWidget have no parent we must destroy it
+    //because tabWidget has no parent we must destroy it
    delete tabWidget;
 }
 
@@ -58,9 +58,9 @@ void MenuWidget::removeSubMenu(QString title) {
 }
 
 QWidget* MenuWidget::createWidget(QWidget *) {
-    /*When we have request to create new widget we returns tabWidget.
+    /*When we have request to create new widget we return tabWidget.
     When the menu is closing, tabWidget will receive hideEvent which will set
-    it parent to NULL and prevent it from delete, so we can still use this
+    its parent to NULL and prevent it from delete, so we can still use this
     widget*/
     return tabWidget;
 
index 37ec77b..1b23106 100644 (file)
@@ -46,8 +46,8 @@ public:
     void addSubMenu(QString title, QWidget* widget);
 
     /*!
-        Remove submenu from menu. It will remove first menu with passed title.
-        /param title Name of submeny which will be removed.
+        Removes submenu from menu. It will remove first menu with passed title.
+        /param title Name of submenu which will be removed.
     */
     void removeSubMenu(QString title);
 
index b9f674c..6921e26 100644 (file)
@@ -187,7 +187,6 @@ void SearchBarWidget::initializeUI() {
                 fullScreenToolButton->sizeHint().height()*2);
     #endif*/
 
-
     searchingProgressBar = new QProgressBar();
     //progress bar have minimum and maximum values set to 0, which will effect
     //with "I'm alive" bar
@@ -221,7 +220,7 @@ void SearchBarWidget::initializeUI() {
 
 void SearchBarWidget::searchPushButtonClicked() {
     if(_isSearching) {
-        emit stopSearching();
+        Q_EMIT stopSearching();
     }
     else {
         search(searchWordLineEdit->text());
@@ -232,7 +231,7 @@ void SearchBarWidget::searchPushButtonClicked() {
 void SearchBarWidget::search(QString word) {
     if(!_isSearching && !word.isEmpty()) {
         searchWordLineEdit->setText(word);
-        emit searchForTranslations(word);
+        Q_EMIT searchForTranslations(word);
     }
 }
 
@@ -253,7 +252,7 @@ void SearchBarWidget::searchDelay(QString word) {
 void SearchBarWidget::delaySearchTimeout() {
     delayTimer.stop();
     if(!_isSearching) {
-        emit searchForTranslations(delayString);
+        Q_EMIT searchForTranslations(delayString);
     }
 }
 
@@ -281,7 +280,7 @@ void SearchBarWidget::setIdle() {
     searchPushButton->setText(tr("Search"));
     setEnabled(true);
     _isSearching = false;
-    emit refreshHistoryButtons();
+    Q_EMIT refreshHistoryButtons();
 }
 
 
index 1172d7b..6fed28f 100644 (file)
@@ -37,7 +37,7 @@
     and buttons to start/stop search and browse search history.
     Line edit and history buttons are disabled when search is ongoing,
     only start/stop button stays active. When searching it also displays
-    progress bar
+    progress bar.
 */
 class SearchBarWidget : public QWidget {
     Q_OBJECT
@@ -46,30 +46,30 @@ public:
     ~SearchBarWidget();
 
 Q_SIGNALS:
-    //! Requests to search for list of matching words to word passed as
+    //! Requests to search for list of words matching word passed as
     //! parameter
     void searchForTranslations(QString);
 
-    //! Request to stop all active searchings
+    //! Requests to stop all active searchings
     void stopSearching();
 
-    //! Request to show previous translation in history
+    //! Requests to show previous translation in history
     void historyPrev();
 
-    //! Request to show next translation in history
+    //! Requests to show next translation in history
     void historyNext();
 
-    //! Request to show history list
+    //! Requests to show history list
     void historyShow();
 
-    //! Request to refresh state of history buttons
+    //! Requests to refresh state of history buttons
     void refreshHistoryButtons();
 
 public Q_SLOTS:
-    //! Enable or disable search word line edit and history buttons
+    //! Enables or disables search word line edit and history buttons
     /*!
       While searching it disables only history button and line edit.
-      Search/Stop button is always enabled
+      Search/Stop button is always enabled.
     */
     void setEnabled(bool);
 
@@ -82,20 +82,20 @@ public Q_SLOTS:
 
     //! Sets search bar in idle state
     /*!
-      Hides "busy" bar and enables all widgets, refresh state of history buttons
-      by emmiting refreshHistoryButtons signal
+      Hides "busy" bar and enables all widgets, refreshes state of history buttons
+      by emitting refreshHistoryButtons signal
       */
     void setIdle();
 
-    //! Search for given word
+    //! Searches for given word
     /*!
       Sets word as text in search word line edit
       */
     void search(QString word);
 
-    //! Start to search for given word after 500 ms
+    //! Starts to search for given word after 500 ms
     /*!
-      Sets word as text in search word line edit, and wait 500 ms to start
+      Sets word as text in search word line edit, and waits 500 ms to start
       search. If in meanwhile this slot is called again it will stop previous
       timers.
       */
index 494466a..156f271 100644 (file)
@@ -144,7 +144,7 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
         else
             newSettings->setValue("search_bookmarks", "false");
 
-        //setting new settings only if their are different that old ones
+        //setting new settings only if they are different that old ones
         QString key;
         foreach(key, newSettings->keys()) {
             if(settings->value(key) != newSettings->value(key)) {
index a4cde9c..5c248d0 100644 (file)
@@ -35,8 +35,8 @@
 //! Implements applications settings widget
 /*!
   Shows settings that user can change.
-  It allow to change limit of searches and limit of history.
-  Also it allow to select if application have to search in dictionaries or in
+  It allows to change limit of searches and limit of history.
+  It also allows to select if application has to search in dictionaries or in
   bookmarks or in both of them. All changes are saved automatically after
   hiding of this widget.
   */
@@ -48,7 +48,7 @@ public:
     /*!
       \param parent parent of this widget, which must be subclass of
       GUIInterface, because it will use it to get current settings and
-      sets new ones.
+      set new ones.
       */
     explicit SettingsWidget(GUIInterface *parent = 0);
 
index 54f5fb2..91ba5b2 100644 (file)
@@ -46,6 +46,11 @@ TranslationWidget::TranslationWidget(QWidget *parent):
     connect(textEdit, SIGNAL(search()),
            this, SLOT(searchSelected()));
 
+    QFile file(":/xsl/xsl.xsl");
+    if(!file.open(QFile::ReadOnly))
+        qDebug()<<"error can't open a xslt file";
+    else
+        xslt=file.readAll();
 }
 
 
@@ -82,26 +87,16 @@ void TranslationWidget::show(QStringList translations) {
 
     textEdit->insertHtml(trans);
 
-//  textEdit->setPlainText(trans);
-
     textEdit->repaint(this->rect());
     update(this->rect());
 
-    emit updateSize();
+    Q_EMIT updateSize();
 }
 
 QString TranslationWidget::XslConversion(QString translation)
 {
     QXmlQuery myQuery(QXmlQuery::XSLT20);
     myQuery.setFocus(translation);
-
-    QFile file(":/xsl/xsl.xsl");
-    if(!file.open(QFile::ReadOnly)){
-        qDebug()<<"can't open a xslt file";
-        return translation;
-    }
-    QString xslt;
-    xslt=file.readAll();
     myQuery.setQuery(xslt);
     QString result("");
     myQuery.evaluateTo(&result);
@@ -277,7 +272,7 @@ void TranslationWidget::searchSelected() {
     #ifdef Q_WS_MAEMO_5
         hide();
     #endif
-    emit search(textEdit->textCursor().selectedText());
+    Q_EMIT search(textEdit->textCursor().selectedText());
 }
 
 #ifdef Q_WS_MAEMO_5
index 46ac8c1..c172d04 100644 (file)
@@ -37,7 +37,7 @@
 
 //! Displays translation of word found in dictionaries
 /*!
-    Display many translation of word, formatted as html.
+    Displays many translations of word, formatted as html.
 */
 class TranslationWidget : public QScrollArea {
     Q_OBJECT
@@ -53,7 +53,7 @@ public Q_SLOTS:
     //! Show widget.
     void show();
 
-    //! Request to show translation of word list passed as parameter.
+    //! Requests to show translation of word list passed as parameter.
     void show(QStringList);
 
 protected:
@@ -73,6 +73,7 @@ private:
     QToolButton* zoomInToolButton;
     QToolButton* zoomOutToolButton;
     TranslationTextEdit *textEdit;
+    QString xslt;
     #ifdef Q_WS_MAEMO_5
         QToolButton* zoomInButton;
         QToolButton* zoomOutButton;
index 463d979..aedc0e3 100644 (file)
@@ -29,7 +29,7 @@
 #include <QScrollArea>
 #include <QtGui>
 
-//! Displays wlecome screen with logo and name of application
+//! Displays welcome screen with logo and name of application
 class WelcomeScreenWidget : public QScrollArea
 {
     Q_OBJECT
index 4a1647c..6843298 100644 (file)
@@ -20,7 +20,7 @@
 
 *******************************************************************************/
 //! \file WordListProxyStyle.h
-//! \brief Implements custom style which draw checkboxes as stars
+//! \brief Implements custom style which draws checkboxes as stars
 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef WORDLISTPROXYSTYLE_H
 #include <QProxyStyle>
 #include <QtGui>
 
-//! Custom proxy style that draw checkboxes as stars.
-//! It will automatically wrap setted style and change only
+//! Custom proxy style that draws checkboxes as stars.
+//! It will automatically wrap set style and change only
 //! checkboxes drawing.
 class WordListProxyStyle : public QProxyStyle
 {
 public:
     WordListProxyStyle();
-    //! Reimplemented drawPrimitive method which only draw different
+    //! Reimplemented drawPrimitive method which only draws different
     //! PE_IndicatorCheckBox elements
     //! \sa QProxyStyle::drawPrimitive()
     void drawPrimitive(PrimitiveElement element,
index a753588..59f4724 100644 (file)
@@ -66,7 +66,7 @@ void WordListWidget::addWord(QString word, int row) {
                            Qt::ItemIsUserCheckable);
 
     /*checking if word is already in bookmarks, information about that is
-    stored in it's translation object (not all translation have to be in
+    stored in its translation object (not all translations have to be in
     bookmarks)*/
     bool bookmark = false;
     Translation* t;
@@ -111,8 +111,8 @@ void WordListWidget::showSearchResults(
 
 void WordListWidget::wordClicked(QModelIndex index) {
     //we're getting translation based on data in index
-    qDebug()<<searchResult[index.data().toString()].at(0)->dictionaryInfo();
-    emit showTranslation(
+    //qDebug()<<searchResult[index.data().toString()].at(0)->dictionaryInfo();
+    Q_EMIT showTranslation(
             searchResult[index.data().toString()]);
 }
 
@@ -129,15 +129,15 @@ void WordListWidget::wordChecked(QModelIndex index) {
     QModelIndex item = selectedIndexes().at(0);
     if(!item.isValid()) return;
 
-    //to shorten lag between clicking on star and it's change
+    //to shorten lag between clicking on star and its change
     repaint();
 
     //depending on new state emit suitable signal
     if(state == Qt::Checked) {
-        emit addBookmark(searchResult[item.data().toString()]);
+        Q_EMIT addBookmark(searchResult[item.data().toString()]);
     }
     else {
-        emit removeBookmark(searchResult[item.data().toString()]);
+        Q_EMIT removeBookmark(searchResult[item.data().toString()]);
     }
 }
 
@@ -147,16 +147,16 @@ void WordListWidget::mouseReleaseEvent(QMouseEvent *event) {
     //firstly we normally handle this event
     QTreeView::mouseReleaseEvent(event);
 
-    //then we checking at which item user clicked
+    //then we check at which item user clicked
     QModelIndex index = indexAt(event->pos());
     if(!index.isValid()) return;
 
     /*if there are no selected items we return, that occurs sometimes
-    on maemo, when user is scrolling list and click to stop the scroll,
-    system don't select item but emitting mouseReleaseEvent*/
+    on maemo, when user is scrolling list and clicks to stop the scroll,
+    system doesn't select item but emits mouseReleaseEvent*/
     if(selectedIndexes().count() == 0) return;
 
-    //if user don't click on word either on star return
+    //if user doesn't click either on word or on star, return
     if(selectedIndexes().at(0) != index && selectedIndexes().at(1) != index)
         return;
 
index 1ff0c12..877be76 100644 (file)
@@ -33,9 +33,9 @@
 
 //! Displays list of words found in dictionaries
 /*!
-    It allow user to select word to see it's translation or to mark or unmark
-    it as "star" (add/remove from bookmarks). It inherit from QTreeView
-    to allow display two columns, one with words and second with stars.
+    It allows user to select word to see its translation or to mark or unmark
+    it as "star" (add/remove from bookmarks). It inherits from QTreeView
+    to allow to display two columns, one with words and second with stars.
     Star is normal checkable item. To get effect of star we need to set
     style (WordListProxyStyle) for this widget.
   */
@@ -46,26 +46,26 @@ public:
 
 
 Q_SIGNALS:
-    //! Request to show translation which is described by passed translations
+    //! Requests to show translation which is described by passed translations
     //! objects
     void showTranslation(QList<Translation*>);
 
 
-    //! Request to add selected word to bookmarks
+    //! Requests to add selected word to bookmarks
     void addBookmark(QList<Translation*>);
 
-    //! Request to remove selected word from bookmarks
+    //! Requests to remove selected word from bookmarks
     void removeBookmark(QList<Translation*>);
 
 
 public Q_SLOTS:
     //! Shows search results
     /*!
-      \param hash of found words and it's translations objects
+      \param hash of found words and its translations objects
     */
     void showSearchResults(QHash<QString, QList<Translation*> >);
 
-    //! Lock words list, while backbone is doing somethig in background
+    //! Locks words list, while backbone is doing something in background
     void lockList();
 
     //! Unlocks words list
@@ -73,10 +73,10 @@ public Q_SLOTS:
 
 protected:
     //! Reimplemented standard mouseReleaseEvent to check if user clicked on
-    //! word on it's star to emit suitable signal
+    //! word or on its star to emit suitable signal
     void mouseReleaseEvent(QMouseEvent *event);
 
-    //! Resize the size of columns to assure that stars are always on right
+    //! Resizes the size of columns to assure that stars are always on right
     //! side next to scroll bar
     void resizeEvent(QResizeEvent *event);
 
@@ -102,7 +102,7 @@ private:
     //! Resizes sizes of colums after adding new words or after resize event.
     void resizeColumns();
 
-    //! Association between words and their's translations
+    //! Association between words and their translations
     QHash<QString, QList<Translation*> > searchResult;
 };
 
index e966813..1fefc09 100644 (file)
@@ -3,8 +3,11 @@
 
 <xsl:template match="/">
        <html>
-       <body bgcolor="#FF0000">
-               <table border="1" WIDTH="100%">
+        <head>
+        <link rel="stylesheet" type="text/css" href="styles.css" />  
+        </head>
+       <body>
+               <table>
                <xsl:for-each select="ar/dict"> 
                        <xsl:apply-templates/>
                </xsl:for-each>
@@ -15,8 +18,8 @@
 
 <xsl:template match="info">
        <!-- <xsl:variable name="path" select="info/@path"/>-->
-       <tr bgcolor="#99FF99">
-               <th>            
+       <tr>
+               <th class="info">               
                <xsl:if test="@bookmark = 'true'">
                        <img src="mydata://image.png"/>   
                </xsl:if>
@@ -26,8 +29,8 @@
 </xsl:template>
 
 <xsl:template match="key">
-       <tr bgcolor="#99CCFF">
-       <th><xsl:value-of select="."/></th>                     
+       <tr>
+       <th class="key"><xsl:value-of select="."/></th>                 
        </tr>
 </xsl:template> 
 
 </xsl:template>
 
 <xsl:template match="tr">
-       [<i><xsl:apply-templates/></i>]
+       [<p><xsl:apply-templates/></p>]
 </xsl:template> 
 
+<xsl:template match="pos">
+       (<p><xsl:apply-templates/></p>)
+</xsl:template>
+
 <xsl:template match="pot">
-       ,<i><xsl:apply-templates/></i>
+       ,<p><xsl:apply-templates/></p>
 </xsl:template>
 
 <xsl:template match="tence">
-       ,<i><xsl:apply-templates/></i>
+       ,<p><xsl:apply-templates/></p>
 </xsl:template>
 
 <xsl:template match="def">
 
 <xsl:template match="c">
        <xsl:variable name="atr" select="@c"/>
-       <font color="{$atr}"> <xsl:apply-templates/> </font>
+       <font color="{$atr}"> <xsl:apply-templates/></font>
+</xsl:template>
+<!--
+<xsl:template match="table">
+       <table>
+       <xsl:apply-templates/>
+       </table>
 </xsl:template>
 
+<xsl:template match="tr">
+       <tr>
+       <xsl:apply-templates/>
+       </tr>
+</xsl:template>
+
+<xsl:template match="td">
+       <td>
+       <xsl:apply-templates/>
+       </td>
+</xsl:template>        -->
+
 </xsl:stylesheet> 
index 6c2b46f..9034317 100644 (file)
@@ -19,7 +19,7 @@
 
 *******************************************************************************/
 
-/*! /file CommonDictInterface.h
+/*! \file CommonDictInterface.h
 \brief Common interface for all dicts and plugins \see CommonDictInterface
 
 \author Bartosz Szatkowski <bulislaw@linux.com>
@@ -53,7 +53,7 @@ class CommonDictInterface : public QObject {
     //! returns destination language code iso 639-2
     virtual QString langTo() const = 0;
 
-    //! returns dictionary name (like "old english" or so
+    //! returns dictionary name (like "old English" or so
     virtual QString name() const = 0;
 
     //! returns dictionary type (xdxf, google translate, etc)
@@ -63,7 +63,7 @@ class CommonDictInterface : public QObject {
     virtual QString infoNote() const = 0;
 
     /*! returns DictDialog object that creates dialogs
-        for adding new dictionary and change plugin settings*/
+        for adding new dictionary and changing plugin settings*/
     virtual DictDialog* dictDialog() = 0;
 
 
@@ -76,7 +76,7 @@ class CommonDictInterface : public QObject {
     //! returns the actual translation of a word given in key
     virtual QString search(QString key) = 0;
 
-    //! \returns unique value (unique for every dictionary not plugin
+    //! \returns unique value (unique for every dictionary not plugin)
     virtual uint hash() const = 0;
 
     //! sets unique value (unique for every dictionary not plugin)
@@ -88,13 +88,15 @@ class CommonDictInterface : public QObject {
     //! returns plugin icon
     virtual QIcon* icon() = 0;
 
+    virtual Translation* getTranslationFor(QString key) {return 0;}
+
  public Q_SLOTS:
     /*! performs search in dictionary
         \param  word word to search in dictionary
         \param  limit limit on number of results,
                 if limit=0 all matching words are returned
 
-        After finishing search it have to emit
+        After finishing search it has to emit
         \see CommonDictInterface:finalTranslation  finalTranslation
     */
     virtual QList<Translation*> searchWordList(QString word, int limit=0) = 0;
@@ -110,7 +112,7 @@ class CommonDictInterface : public QObject {
     //! emited after change dictionary settings
     void settingsChanged();
 
-    /*! emmited to backbone when needed to inform user about something
+    /*! emitted to backbone when needed to inform user about something
         \param Backbone::NotifyType gui my dacide to show different typet in
             different ways
         \param QString text of the notification
index 7932404..30e9457 100644 (file)
@@ -37,13 +37,13 @@ public:
 
     /*!
       Shows add new dictionary dialog and returns settings of new dict
-      \param parent parent widget on which will be displayed dialog
+      \param parent parent widget on which dialog will be displayed
       */
     virtual Settings* addNewDictionary(QWidget*parent=0)=0;
 
     /*!
       Shows settings dialog and save new settings in plugin
-      \param parent parent widget on which will be displayed dialog
+      \param parent parent widget on which dialog will be displayed
       */
     virtual void changeSettings(QWidget*parent=0)=0;
 };
index 17aa8ee..8eb4934 100644 (file)
@@ -62,10 +62,10 @@ public:
     virtual QList<CommonDictInterface*> getPlugins() = 0;
 
     //! Indicates if GUI is in exact search mode.
-    /*! When GUI is in exact search mode it search for word, and
-        if find exacly matching translation it directly displays it, whithout
+    /*! When GUI is in exact search mode it searches for word, and
+        if it finds exactly matching translation it directly displays it, without
         displaying matching word list. This mode should be
-        used for browsing search history and search words from application
+        used for browsing search history and searching words from application
         arguments.
         \returns flag indicating if GUI is in exact search mode
     */
@@ -81,9 +81,9 @@ public:
 
 
 public Q_SLOTS:
-    //! Search in exact mode for given word
+    //! Searches in exact mode for given word
     /*!
-      GUI will be automaticaly set into exact search mode, and after search or
+      GUI will be automatically set into exact search mode, and after search or
       break will be unset from exact search mode.
       \param word which will be searched in dictionaries
       */
@@ -123,68 +123,68 @@ public Q_SLOTS:
       Checks if received list is empty, in that case displays suitable
       information. If GUI is in exact search mode it will search for exact
       word in received list, and if word is found it will emit signal to
-      display it's translation. Otherwise it will display list of matching
+      display its translation. Otherwise it will display list of matching
       words and show suitable information.
       \sa exactSearch()
       \sa showTranslation()
      */
     virtual void wordListReady() = 0;
 
-    //! Gets translation strings from backbone and emit signal to display them
+    //! Gets translation strings from backbone and emits signal to display them
     virtual void translationsReady() = 0;
 
 Q_SIGNALS:
-    //! Should be emited when user wants to close application to stop
+    //! Should be emitted when user wants to close application to stop
     //! all ongoing searches
     void quit();
 
-    //! Emited when user want to search for list of words matching given word
-    /*! \param word word which will be matched, it can contains wildcards
+    //! Emitted when user wants to search for list of words matching given word
+    /*! \param word word which will be matched, it can contain wildcards
     */
     void searchWordList(QString word);
 
-    //! Emited when user wants to see translation of words.
+    //! Emitted when user wants to see translation of words.
     /*! \param list of translations for given word which will be received
         in wordListReady() slot
         \sa wordListReady()
     */
     void searchTranslations(QList<Translation*>);
 
-    //! Emited when starting search, will disable GUI components
+    //! Emitted when starting search, will disable GUI components
     //! and shows progress bars
     void setBusy();
 
-    //! Emited when searching ends, will enable GUI components
+    //! Emitted when searching ends, will enable GUI components
     void setIdle();
 
-    //! Emited when user want to break search
+    //! Emitted when user wants to break search
     void stopSearching();
 
-    //! Emited after received word list in wordListReady() slot, will display
+    //! Emitted after receiving word list in wordListReady() slot, will display
     //! list of matched words
     /*! \param hash of word and list of translation of this word found
          in dictionaries
      */
     void showWordList(QHash<QString, QList<Translation*> >);
 
-    //! Emited after received translation strings in translationsReady() slot,
+    //! Emitted after receiving translation strings in translationsReady() slot,
     //! will display translation of given word
     /*! \param list of translations from different dictionaries
          in dictionaries
      */
     void showTranslation(QStringList);
 
-    //! Emited when user wants to add new dictionary
-    /*! \param new dictionary returned by specyfic plugin dialog
+    //! Emitted when user wants to add new dictionary
+    /*! \param new dictionary returned by specific plugin dialog
       */
     void addNewDictionary(CommonDictInterface*);
 
-    //! Emited when user wants to remove dictionary
+    //! Emitted when user wants to remove dictionary
     /*! \param dictionary which will be removed
       */
     void removeDictionary(CommonDictInterface*);
 
-    //! Emited when user changes dictionaries active/inactive states
+    //! Emitted when user changes dictionaries active/inactive states
     /*! \param list of only active dictionaries
       */
     void selectedDictionaries(QList<CommonDictInterface* >);
index c50136a..bc8c35b 100644 (file)
@@ -19,8 +19,8 @@
 
 *******************************************************************************/
 
-/*! /file settings.h
-\brief Settings object for pluggins \see Settings
+/*! \file settings.h
+\brief Settings object for plugins \see Settings
 
 \author Bartosz Szatkowski <bulislaw@linux.com>
 */
 class CommonDictInterface;
 
 /*! Plugins or dictionaries may need to keep some of configuration between
-  sessions, moreover Backbone or GUI may want store some additional info in
+  sessions, moreover Backbone or GUI may want to store some additional info in
   plugin Settings.
 
-  Its important for plugin to store all information given it in Settings.*/
+  It's important for plugin to store all information given to it in Settings.*/
 class Settings {
   public:
     Settings(){}
index 3940f60..11da8f0 100644 (file)
@@ -19,7 +19,7 @@
 
 *******************************************************************************/
 
-/*! /file translation.h
+/*! \file translation.h
 \brief Interface for translation instances \see Translation
 
 \author Bartosz Szatkowski <bulislaw@linux.com>
@@ -34,7 +34,7 @@ class CommonDictInterface;
 
 
 /*! Translation is kind of GoF proxy, it stores key:translation pair and
-  provide it in lazy way -> key is available always, but translation is fetched
+  provides it in lazy way -> key is available always, but translation is fetched
   as late as possible*/
 class Translation {
   public:
@@ -53,7 +53,7 @@ class Translation {
     //! \return parsed raw format into html
     virtual QString toHtml() const = 0;
 
-    //! \retrun whether given translation is taken from bookmarks
+    //! \return whether given translation is taken from bookmarks
     virtual bool isBookmark() const {
         return _bookmark;
    }
diff --git a/trunk/src/plugins/google/google.pro b/trunk/src/plugins/google/google.pro
new file mode 100644 (file)
index 0000000..70fcdea
--- /dev/null
@@ -0,0 +1,7 @@
+TEMPLATE=subdirs
+SUBDIRS=src
+
+check.target = check
+check.CONFIG = recursive
+check.recurse = tests
+QMAKE_EXTRA_TARGETS += check
diff --git a/trunk/src/plugins/google/src/GoogleDictDialog.cpp b/trunk/src/plugins/google/src/GoogleDictDialog.cpp
new file mode 100644 (file)
index 0000000..a4125c4
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GoogleDictDialog.cpp
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#include "GoogleDictDialog.h"
+
+GoogleDictDialog::GoogleDictDialog(GooglePlugin *plugin, QObject *parent) :
+    DictDialog(parent) {
+    this->plugin = plugin;
+}
+
+Settings* GoogleDictDialog::addNewDictionary(QWidget *parent) {
+   return GoogleSettingsDialog::getSettings(parent);
+}
+
+void GoogleDictDialog::changeSettings(QWidget * parent) {
+    GoogleSettingsDialog::changeSettings(plugin,parent);
+}
+
diff --git a/trunk/src/plugins/google/src/GoogleDictDialog.h b/trunk/src/plugins/google/src/GoogleDictDialog.h
new file mode 100644 (file)
index 0000000..d62e1f1
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GoogleDictDialog.h
+    \brief Class launch a dialogs witch generete new dictionary, or change
+    settings
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#ifndef GOOGLEDICTDIALOG_H
+#define GOOGLEDICTDIALOG_H
+
+#include "../../../includes/DictDialog.h"
+#include "../../../includes/settings.h"
+#include "GooglePlugin.h"
+#include "GoogleSettingsDialog.h"
+
+class GooglePlugin;
+
+class GoogleDictDialog : public DictDialog
+{
+     Q_OBJECT
+public:
+    explicit GoogleDictDialog(GooglePlugin* plugin, QObject *parent = 0);
+    /*!
+      Shows add new google dictionary dialog and returns settings of new dict
+      \param parent parent widget on which will be displayed dialog
+      */
+    Settings* addNewDictionary(QWidget *parent);
+
+    /*!
+      Shows settings dialog and save new settings in plugin
+      \param parent parent widget on which will be displayed dialog
+      */
+    void changeSettings(QWidget *parent);
+
+private:
+    GooglePlugin* plugin;
+};
+
+#endif // GOOGLEDICTDIALOG_H
diff --git a/trunk/src/plugins/google/src/GooglePlugin.cpp b/trunk/src/plugins/google/src/GooglePlugin.cpp
new file mode 100644 (file)
index 0000000..bc6995c
--- /dev/null
@@ -0,0 +1,369 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GooglePlugin.cpp
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#include "GooglePlugin.h"
+#include <QDebug>
+#include "GoogleDictDialog.h"
+
+
+GooglePlugin::GooglePlugin(QObject *parent): CommonDictInterface(parent),
+                    _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
+                    _type(tr("google")), _infoNote(tr("")) {
+
+    stopped = false;
+    _settings = new Settings();
+    _dictDialog = new GoogleDictDialog(this,this);
+
+    //_icon = QIcon(":/icon/google.png");
+    languages=initLanguages();
+    _settings->setValue("type","google");
+
+    http = new QHttp(this);
+    connect(http, SIGNAL(done(bool)), this, SLOT(done()));
+}
+
+GooglePlugin::~GooglePlugin() {
+    delete _settings;
+}
+
+QString GooglePlugin::langFrom() const {
+    return languages.key(_langFrom);
+}
+QString GooglePlugin::langTo() const {
+    return languages.key(_langTo);
+}
+
+QString GooglePlugin::name() const {
+    return QString("dictionary");
+}
+
+QString GooglePlugin::type() const {
+    return _type;
+}
+
+QString GooglePlugin::infoNote() const {
+    return _infoNote;
+}
+
+void GooglePlugin::setLangTo(QString langTo){
+    _langTo=langTo;
+}
+
+void GooglePlugin::setLangFrom(QString langFrom){
+    _langFrom=langFrom;
+}
+
+DictDialog* GooglePlugin::dictDialog() {
+    return _dictDialog;
+}
+
+bool GooglePlugin::isAvailable() const {
+   return true;
+}
+
+QString GooglePlugin::search(QString key) {
+    /*function is not used on this plagin */
+    return QString("");
+}
+
+uint GooglePlugin::hash() const {
+    return _hash;
+}
+
+void GooglePlugin::setHash(uint) {
+    this->_hash=_hash;
+}
+
+Settings* GooglePlugin::settings() {
+    return _settings;
+}
+
+QIcon* GooglePlugin::icon() {
+    return &_icon;
+}
+
+CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const
+{
+    GooglePlugin *plugin = new GooglePlugin();
+    if(settings)   {
+        plugin->setLangFrom(settings->value("langFrom"));
+        plugin->setLangTo(settings->value("langTo"));
+        QStringList list = settings->keys();
+        foreach(QString key, list)
+            plugin->settings()->setValue(key, settings->value(key));
+    }
+    delete settings;
+    plugin->getDictionaryInfo();
+    return plugin;
+}
+
+void GooglePlugin::setSettings(Settings* settings) {
+    if(settings){
+        _langFrom=settings->value("langFrom");
+        _langTo=settings->value("langTo");
+        QStringList list = settings->keys();
+        foreach(QString key, list)
+            _settings->setValue(key, settings->value(key));
+        delete settings;
+    }
+}
+
+Translation* GooglePlugin::getTranslationFor(QString key) {
+    QList<Translation*> translations = searchWordList(key);
+    if(translations.size()>0)
+        return translations.at(0);
+    else
+        return new TranslationGoogle();
+}
+
+QList<Translation*> GooglePlugin::searchWordList(QString word, int limit) {
+    QList<Translation*> translations;
+    word.replace("*","");
+    word.replace("?","");
+    QString url = QString("/translate_a/t?client=t&sl=%1&tl=%2").arg(_langFrom,
+                                                                     _langTo);
+    QHttpRequestHeader head = QHttpRequestHeader("POST", url, 1,1);
+    head.setValue("Host", "www.google.pl");
+    head.setValue("User-Agent", "Mozilla/5.0");
+    head.setValue("Accept-Encoding", "deflate");
+    head.setContentLength(word.length());
+    head.setValue("Connection", "Close");
+
+    QByteArray data("text=");
+    data.append(word.toUtf8());
+    http->setHost("www.google.pl");
+    wait=true;
+    http->request(head, data);
+    QString error("");
+    while(wait && (error=="" || error=="Unknown error"))
+        error=http->errorString();
+    if(error!="" && error!="Unknown error")
+        qDebug()<<error;
+
+    QString text = QString::fromUtf8(http->readAll());
+    text=jsonParse(text);
+    if(text!="") {
+        text=tr("<key>") + word + tr("</key>") + tr("<t>") + text + tr("</t>");
+        translations<<(new TranslationGoogle(word,text,_infoNote,this));
+    }
+    return translations;
+}
+
+QString GooglePlugin::jsonParse(QString result) {
+    int pos=0,pos2=0;
+    int index=0;
+    int size=0;
+    QString returnLang;
+    QString translation;
+    QString original;
+    QList<QString> partOfSpeach;
+    QList<QList<QString>* > words;
+
+    QStringList list1 = result.split("\"");
+    size=(list1.size()-1)/2;
+    if(size<=2)
+        return QString("");
+    translation=list1.at(1);
+    original=list1.at(3);
+    pos=result.indexOf("]");
+    pos=result.indexOf("]",pos+1);
+    pos++;
+    index=3;
+    if(result.at(pos+1)==QChar(','))
+        returnLang=list1.at(index*2+1);
+    while(result.indexOf("[",pos+1)!=-1){
+        partOfSpeach.append(list1.at(index*2+1));
+        pos2=result.indexOf("]",pos+1);
+        pos=result.indexOf("\"",pos+1);
+        pos=result.indexOf("\"",pos+1);
+        pos=result.indexOf("\"",pos+1);
+        pos=result.indexOf("\"",pos+1);
+        QList<QString> *list=new QList<QString>;
+        while(pos2>pos && pos2!=-1 && pos!= -1) {
+            index++;
+            if(size==index)
+                return QString("");
+            list->append(list1.at(index*2+1));
+            pos=result.indexOf("\"",pos+1);
+            pos=result.indexOf("\"",pos+1);
+        }
+        words.append(list);
+        index++;
+        if(size==index)
+            return QString("");
+        pos=pos2+2;
+    }
+    if(words.size()!=partOfSpeach.size()) {
+        qDebug()<<"Error in Google Plugin (JsonParse)";
+        return QString("");
+    }
+    returnLang=list1.at(index*2+1);
+    if(partOfSpeach.size()==0){
+        if(translation==original){
+ //           qDebug()<<"This word don't exist";
+            return QString("");
+        }
+        else
+            return "\""+translation+"\"";
+    }
+    result=translation;
+    for(int i=0; i<words.size();i++) {
+        result+="<pos>"+partOfSpeach.at(i)+"</pos>:";
+        for(int j=0; j<words.at(i)->size();j++)
+            result+=words.at(i)->at(j)+", ";
+    }
+    return result;
+}
+
+void GooglePlugin::done() {
+    wait=false;
+}
+
+void GooglePlugin::stop() {
+    stopped=true;
+}
+
+QMap<QString, QString> GooglePlugin::initLanguages() {
+    QMap<QString, QString> languages;
+    languages["AFRIKAANS"] = "af";
+    languages["ALBANIAN"] = "sq";
+    languages["AMHARIC"] = "am";
+    languages["ARABIC"] = "ar";
+    languages["ARMENIAN"] = "hy";
+    languages["AZERBAIJANI"] = "az";
+    languages["BASQUE"] = "eu";
+    languages["BELARUSIAN"] = "be";
+    languages["BENGALI"] = "bn";
+    languages["BIHARI"] = "bh";
+    languages["BRETON"] = "br";
+    languages["BULGARIAN"] = "bg";
+    languages["BURMESE"] = "my";
+    languages["CATALAN"] = "ca";
+    languages["CHEROKEE"] = "chr";
+    languages["CHINESE"] = "zh";
+    languages["CHINESE_SIMPLIFIED"] = "zh-CN";
+    languages["CHINESE_TRADITIONAL"] = "zh-TW";
+    languages["CORSICAN"] = "co";
+    languages["CROATIAN"] = "hr";
+    languages["CZECH"] = "cs";
+    languages["DANISH"] = "da";
+    languages["DHIVEHI"] = "dv";
+    languages["DUTCH"] = "nl";
+    languages["ENGLISH"] = "en";
+    languages["ESPERANTO"] = "eo";
+    languages["ESTONIAN"] = "et";
+    languages["FAROESE"] = "fo";
+    languages["FILIPINO"] = "tl";
+    languages["FINNISH"] = "fi";
+    languages["FRENCH"] = "fr";
+    languages["FRISIAN"] = "fy";
+    languages["GALICIAN"] = "gl";
+    languages["GEORGIAN"] = "ka";
+    languages["GERMAN"] = "de";
+    languages["GREEK"] = "el";
+    languages["GUJARATI"] = "gu";
+    languages["HAITIAN_CREOLE"] = "ht";
+    languages["HEBREW"] = "iw";
+    languages["HINDI"] = "hi";
+    languages["HUNGARIAN"] = "hu";
+    languages["ICELANDIC"] = "is";
+    languages["INDONESIAN"] = "id";
+    languages["INUKTITUT"] = "iu";
+    languages["IRISH"] = "ga";
+    languages["ITALIAN"] = "it";
+    languages["JAPANESE"] = "ja";
+    languages["JAVANESE"] = "jw";
+    languages["KANNADA"] = "kn";
+    languages["KAZAKH"] = "kk";
+    languages["KHMER"] = "km";
+    languages["KOREAN"] = "ko";
+    languages["KURDISH"] = "ku";
+    languages["KYRGYZ"] = "ky";
+    languages["LAO"] = "lo";
+    languages["LATIN"] = "la";
+    languages["LATVIAN"] = "lv";
+    languages["LITHUANIAN"] = "lt";
+    languages["LUXEMBOURGISH"] = "lb";
+    languages["MACEDONIAN"] = "mk";
+    languages["MALAY"] = "ms";
+    languages["MALAYALAM"] = "ml";
+    languages["MALTESE"] = "mt";
+    languages["MAORI"] = "mi";
+    languages["MARATHI"] = "mr";
+    languages["MONGOLIAN"] = "mn";
+    languages["NEPALI"] = "ne";
+    languages["NORWEGIAN"] = "no";
+    languages["OCCITAN"] = "oc";
+    languages["ORIYA"] = "or";
+    languages["PASHTO"] = "ps";
+    languages["PERSIAN"] = "fa";
+    languages["POLISH"] = "pl";
+    languages["PORTUGUESE"] = "pt";
+    languages["PORTUGUESE_PORTUGAL"] = "pt-PT";
+    languages["PUNJABI"] = "pa";
+    languages["QUECHUA"] = "qu";
+    languages["ROMANIAN"] = "ro";
+    languages["RUSSIAN"] = "ru";
+    languages["SANSKRIT"] = "sa";
+    languages["SCOTS_GAELIC"] = "gd";
+    languages["SERBIAN"] = "sr";
+    languages["SINDHI"] = "sd";
+    languages["SINHALESE"] = "si";
+    languages["SLOVAK"] = "sk";
+    languages["SLOVENIAN"] = "sl";
+    languages["SPANISH"] = "es";
+    languages["SUNDANESE"] = "su";
+    languages["SWAHILI"] = "sw";
+    languages["SWEDISH"] = "sv";
+    languages["SYRIAC"] = "syr";
+    languages["TAJIK"] = "tg";
+    languages["TAMIL"] = "ta";
+    languages["TATAR"] = "tt";
+    languages["TELUGU"] = "te";
+    languages["THAI"] = "th";
+    languages["TIBETAN"] = "bo";
+    languages["TONGA"] = "to";
+    languages["TURKISH"] = "tr";
+    languages["UKRAINIAN"] = "uk";
+    languages["URDU"] = "ur";
+    languages["UZBEK"] = "uz";
+    languages["UIGHUR"] = "ug";
+    languages["VIETNAMESE"] = "vi";
+    languages["WELSH"] = "cy";
+    languages["YIDDISH"] = "yi";
+    languages["YORUBA"] = "yo";
+    languages["UNKNOWN"] = "";
+    return languages;
+}
+
+void GooglePlugin::getDictionaryInfo() {
+    QString fullLangFrom=languages.key(_langFrom);
+    QString fullLangTo=languages.key(_langTo);
+    _infoNote=" [" + fullLangFrom + "-";
+    _infoNote+= fullLangTo + "] (" + _type + ")";
+}
+
+
+Q_EXPORT_PLUGIN2(google, GooglePlugin)
diff --git a/trunk/src/plugins/google/src/GooglePlugin.h b/trunk/src/plugins/google/src/GooglePlugin.h
new file mode 100644 (file)
index 0000000..bb74daf
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GooglePlugin.h
+
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#ifndef GOOGLEPLUGIN_H
+#define GOOGLEPLUGIN_H
+
+
+#include <QObject>
+#include <QDialog>
+#include <QtPlugin>
+#include <QIcon>
+#include <QtNetwork>
+
+#include "../../../includes/CommonDictInterface.h"
+#include "../../../includes/settings.h"
+#include "../../../includes/DictDialog.h"
+#include "TranslationGoogle.h"
+#include "GoogleDictDialog.h"
+
+class GoogleDictDialog;
+
+class GooglePlugin : public CommonDictInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(CommonDictInterface)
+public:
+    GooglePlugin(QObject *parent=0);
+    ~GooglePlugin();
+
+    //! returns source language code iso 639-2
+    QString langFrom() const;
+
+    //! returns destination language code iso 639-2
+    QString langTo() const;
+
+    //! returns dictionary name (like "old english" or so)
+    QString name() const;
+
+    //! returns dictionary type (xdxf, google translate, etc)
+    QString type() const;
+
+    //! returns information about dictionary in html (name, authors, etc)
+    QString infoNote() const;
+
+    void setLangTo(QString langTo);
+
+    void setLangFrom(QString langFrom);
+
+    /*! returns DictDialog object that creates dialogs
+        for adding new dictionary and change plugin tings
+      */
+    DictDialog* dictDialog();
+
+    //! returns new, clean copy of plugin with setting set as in Settings*
+    CommonDictInterface* getNew(const Settings*) const;
+
+    //! returns whether plugin can start searching
+    bool isAvailable() const;
+
+    //! returns a description of a word given by a QString
+    QString search(QString key);
+
+    //! returns a unique hash for a dictionary
+    uint hash() const;
+
+    //! set unique value (unique for every dictionary not plugin)
+    void setHash(uint);
+
+    //! returns current plugin settings
+    Settings* settings();
+
+    //! Sets new settings
+    void setSettings(Settings*);
+
+    //! returns plugin icon
+    QIcon* icon();
+
+    Translation* getTranslationFor(QString key);
+
+    static QMap<QString, QString> initLanguages();
+
+public slots:
+    /*! performs search in dictionary
+      \param  word word to search in dictionary
+      \param limit limit on number of results
+
+      After finishing search it has to emit
+      \see CommonDictInterface:finalTranslation  finalTranslation
+    */
+    QList<Translation*> searchWordList(QString word, int limit=0);
+
+    //! stop current operation
+    void stop();
+
+    void done();
+
+private:
+    QString jsonParse(QString result);
+    void getDictionaryInfo();
+
+    QMap<QString, QString> languages;
+    //! language from which we translate
+    QString _langFrom;
+    //! language to which we translate
+    QString _langTo;
+    //! name of a dictionary
+    QString _name;
+    //! type of a dictionary
+    QString _type;
+    //! information about dictionary
+    QString _infoNote;
+    //! path to dictionary file
+    QString path;
+    uint _hash;
+    QIcon _icon;
+    Settings *_settings;
+    bool stopped;
+    volatile bool wait;
+    QHttp *http;
+    GoogleDictDialog *_dictDialog;
+};
+
+#endif // GOOGLEPLUGIN_H
+
+
diff --git a/trunk/src/plugins/google/src/GoogleSettingsDialog.cpp b/trunk/src/plugins/google/src/GoogleSettingsDialog.cpp
new file mode 100644 (file)
index 0000000..2ec2a14
--- /dev/null
@@ -0,0 +1,163 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GoogleSettingsDialog.cpp
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#include "GoogleSettingsDialog.h"
+#include <QDebug>
+
+GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,QString langTo,QString langFrom) :
+    QDialog(parent)
+{
+    QMap<QString, QString> languages;
+    languages=GooglePlugin::initLanguages();
+
+    int actualLangTo=1;
+    int actualLangFrom=1;
+
+    if(langTo=="")
+        langTo="pl";
+    if(langFrom=="")
+        langFrom="en";
+
+    _langTo=languages.key(langTo);
+    _langFrom=languages.key(langFrom);
+
+
+    changeLangButton=new QPushButton(QIcon(":/icons/staron.png"),tr(""));
+    langFromLabel = new QLabel("From:");
+    langToLabel = new QLabel(" To: ");
+
+    setWindowTitle(tr("Google Settings"));
+
+    verticalLayout = new QVBoxLayout(this);
+    langLayout = new QVBoxLayout(this);
+    langFromLayout = new QHBoxLayout(this);
+    langToLayout = new QHBoxLayout(this);
+    changelangLayout = new QHBoxLayout(this);
+
+    setLayout(verticalLayout);
+
+    infoLabel = new QLabel(this);
+    infoLabel->setText(tr("Plugin:GoogleTranslator \n")+
+                   tr("From: ") + languages.key(langFrom) + "\n" +
+                   tr("To: ") + languages.key(langTo));
+    verticalLayout->addWidget(infoLabel);
+
+    langFromComboBox = new QComboBox(this);
+    langToComboBox = new QComboBox(this);
+    int i=0;
+    foreach(QString langs,languages.keys()){
+        if(langs==languages.key(langTo))
+            actualLangTo=i;
+        if(langs==languages.key(langFrom))
+            actualLangFrom=i;
+        langToComboBox->addItem(langs);
+        langFromComboBox->addItem(langs);
+        i++;
+    }
+
+    langFromLayout->addWidget(langFromLabel);
+    langFromLayout->addWidget(langFromComboBox);
+    langToLayout->addWidget(langToLabel);
+    langToLayout->addWidget(langToComboBox);
+    langLayout->addLayout(langFromLayout);
+    langLayout->addLayout(langToLayout);
+    changelangLayout->addLayout(langLayout);
+    changelangLayout->addWidget(changeLangButton);
+    verticalLayout->addLayout(changelangLayout);
+
+    //langToComboBox->setMaximumWidth(120);
+    langToComboBox->setCurrentIndex(actualLangTo);
+    //langFromComboBox->setMaximumWidth(120);
+    langFromComboBox->setCurrentIndex(actualLangFrom);
+
+    //comboBoxLayout->addWidget(langFromComboBox);
+    //comboBoxLayout->addWidget(langToComboBox);
+
+
+    //infoLayout->addWidget(infoLabel);
+    //infoLayout->addLayout(comboBoxLayout);
+
+    //verticalLayout->addLayout(infoLayout);
+
+    saveButton = new QPushButton(tr("Save settings"),this);
+
+//    verticalLayout->addWidget(langFromComboBox);
+//    verticalLayout->addWidget(langToComboBox);
+    verticalLayout->addWidget(saveButton);
+
+    setModal(true);
+
+    connect(saveButton, SIGNAL(clicked()),this, SLOT(accept()));
+    connect(langFromComboBox, SIGNAL(activated(int)),this, SLOT(activatedFrom(int)));
+    connect(langToComboBox, SIGNAL(activated(int)),this, SLOT(activatedTo(int)));
+    connect(changeLangButton, SIGNAL(clicked()),this, SLOT(changeLangButtonClicked()));
+}
+
+void GoogleSettingsDialog::activatedFrom(int index) {
+    _langFrom=langFromComboBox->itemText(index);
+}
+
+void GoogleSettingsDialog::activatedTo(int index) {
+     _langTo=langToComboBox->itemText(index);
+}
+
+void GoogleSettingsDialog::changeLangButtonClicked() {
+    int tempIndexTo=langToComboBox->currentIndex();
+    QString tempLangTo=_langTo;
+
+    langToComboBox->setCurrentIndex(langFromComboBox->currentIndex());
+    langFromComboBox->setCurrentIndex(tempIndexTo);
+
+    _langTo=_langFrom;
+    _langFrom=tempLangTo;
+}
+
+QString GoogleSettingsDialog::langFrom() {
+    return _langFrom;
+}
+
+QString GoogleSettingsDialog::langTo() {
+    return _langTo;
+}
+
+Settings* GoogleSettingsDialog::getSettings(QWidget *parent,QString langTo,QString langFrom) {
+    GoogleSettingsDialog settingsDialog(parent,langTo,langFrom);
+    QMap<QString, QString> languages;
+    languages=GooglePlugin::initLanguages();
+    if(settingsDialog.exec()==QDialog::Accepted) {
+        Settings *settings = new Settings();
+        settings->setValue("langTo",languages.value(settingsDialog.langTo()));
+        settings->setValue("langFrom",languages.value(settingsDialog.langFrom()));
+        return settings;
+    }
+    return 0;
+}
+
+void GoogleSettingsDialog::changeSettings(GooglePlugin* plugin, QWidget *parent) {
+    Settings *settings = new Settings();
+    settings=getSettings(parent,plugin->settings()->value("langTo"),plugin->settings()->value("langFrom"));
+    if(settings)
+        plugin->setSettings(settings);
+}
diff --git a/trunk/src/plugins/google/src/GoogleSettingsDialog.h b/trunk/src/plugins/google/src/GoogleSettingsDialog.h
new file mode 100644 (file)
index 0000000..1113904
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file GoogleSettingsDialog.h
+    \brief Class create dialog to get or change settings for Google Plagin
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#ifndef GOOGLESETTINGSDIALOG_H
+#define GOOGLESETTINGSDIALOG_H
+
+#include <QDialog>
+#include "../../../includes/settings.h"
+#include <QtGui>
+#include "GooglePlugin.h"
+
+class GooglePlugin;
+
+class GoogleSettingsDialog : public QDialog
+{
+    Q_OBJECT
+public:
+    explicit GoogleSettingsDialog(QWidget *parent = 0,QString langTo ="",QString langFrom ="");
+
+    /*!
+        \param parent parent widget on which will be displayed dialog
+        \param langTo language witch is display in the comboBox as a startup item
+        \param langFrom language witch is display in the comboBox as a startup item
+        \returns function return settings to GooglePlugin
+    */
+    static Settings* getSettings(QWidget *parent,QString langTo ="",QString langFrom ="");
+
+    /*!
+        function set a new settings in plugin;
+        \param plugin plugin whose settings you will change
+        \param parent parent widget on which will be displayed dialog
+    */
+    static void changeSettings(GooglePlugin* plugin, QWidget *parent);
+
+    //! \return source language code iso 639-2
+    QString langFrom();
+
+    //! \return destination language code iso 639-2
+    QString langTo();
+
+public slots:
+    void activatedFrom(int);
+    void activatedTo(int);
+    void changeLangButtonClicked();
+
+private:
+    QLabel* infoLabel;
+    QLabel* langFromLabel;
+    QLabel* langToLabel;
+    QPushButton* saveButton;
+    QPushButton* changeLangButton;
+    QComboBox *langFromComboBox;
+    QComboBox *langToComboBox;
+
+    QVBoxLayout* verticalLayout;
+    QVBoxLayout* langLayout;
+    QHBoxLayout* langFromLayout;
+    QHBoxLayout* langToLayout;
+    QHBoxLayout* changelangLayout;
+
+    QString _langFrom;
+    QString _langTo;
+
+
+/*    QPushButton* browseButton;
+    QLabel* browseLabel;
+    QCheckBox* cacheCheckBox;
+
+    QHBoxLayout* browseLayout;
+    QHBoxLayout* cacheLayout;
+*/
+};
+
+#endif // GOOGLESETTINGSDIALOG_H
diff --git a/trunk/src/plugins/google/src/TranslationGoogle.cpp b/trunk/src/plugins/google/src/TranslationGoogle.cpp
new file mode 100644 (file)
index 0000000..2ee8a63
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file TranslationGoogle.cpp
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#include "TranslationGoogle.h"
+
+TranslationGoogle::TranslationGoogle():_key(""),_trans(""),_dictionaryInfo("") {
+    googlePlugin=0;
+}
+
+TranslationGoogle::TranslationGoogle(QString _key,QString _trans,
+                    QString _dictionaryInfo,GooglePlugin *googlePlugin):
+                    _key(_key),_trans(_trans),_dictionaryInfo(_dictionaryInfo) {
+    this->googlePlugin=googlePlugin;
+    if(googlePlugin)
+        _dictHash = googlePlugin->hash();
+    _bookmark=0;
+}
+
+QString TranslationGoogle::key() const{
+    return _key;
+}
+
+QString TranslationGoogle::dictionaryInfo() const {
+    return _dictionaryInfo;
+}
+
+QString TranslationGoogle::toHtml() const {
+    QString result("");
+    if(!googlePlugin)
+        return result;
+    result="<dict> <info path=\"\" ";
+    if(isBookmark())
+        result+="bookmark=\"true\" >";
+    else
+        result+="bookmark=\"false\" >";
+    result+=_dictionaryInfo+ "</info>"+_trans +"</dict>";
+}
+
+void TranslationGoogle::setKey(QString) {
+    this->_key=_key;
+}
+
+void TranslationGoogle::setDictionaryInfo(QString){
+    this->_dictionaryInfo=_dictionaryInfo;
+}
diff --git a/trunk/src/plugins/google/src/TranslationGoogle.h b/trunk/src/plugins/google/src/TranslationGoogle.h
new file mode 100644 (file)
index 0000000..08b5530
--- /dev/null
@@ -0,0 +1,76 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*! \file TranslationGoogle.h
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
+
+#ifndef TRANSLATIONGOOGLE_H
+#define TRANSLATIONGOOGLE_H
+
+#include "../../../includes/translation.h"
+#include "GooglePlugin.h"
+
+class GooglePlugin;
+
+class TranslationGoogle : public Translation
+{
+public:
+    TranslationGoogle();
+
+    TranslationGoogle(QString _key,QString _trans,QString _dictionaryInfo, GooglePlugin *googlePlugin);
+
+    //! \return word to be translated
+    QString key() const;
+
+    /*! \returns dictionary information (plugin name, languages, <logo> etc)\
+        to be displayed in translation table header*/
+    QString dictionaryInfo() const;
+
+    //! \return parsed raw format into html
+    QString toHtml() const;
+
+    /*! sets the word for which we want to find a translation
+        \param word for which we want to find a translation */
+    void setKey(QString);
+
+    //! sets information about dictionary
+    void setDictionaryInfo(QString);
+
+    //! \retrun whether given translation is taken from bookmarks
+    bool isBookmark() const {
+        return _bookmark;
+   }
+
+    //! returns coresponding dict object
+    uint dict() const {return _dictHash;}
+
+private:
+    QString _key;
+    QString _dictionaryInfo;
+    QString _trans;
+    GooglePlugin *googlePlugin;
+    int _dictHash;
+    bool error;
+
+};
+
+#endif // TRANSLATIONGOOGLE_H
diff --git a/trunk/src/plugins/google/src/icons.qrc b/trunk/src/plugins/google/src/icons.qrc
new file mode 100644 (file)
index 0000000..e201426
--- /dev/null
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/icons">
+        <file>staron.png</file>
+    </qresource>
+</RCC>
diff --git a/trunk/src/plugins/google/src/src.pro b/trunk/src/plugins/google/src/src.pro
new file mode 100644 (file)
index 0000000..8d862e0
--- /dev/null
@@ -0,0 +1,72 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-08-03T09:33:52
+#
+#-------------------------------------------------
+
+QT       += core xml gui network
+
+
+TARGET = GooglePlugin
+TEMPLATE = lib
+
+MDICT_PLUGINSDIR = $$[MDICT_PLUGINSDIR]
+
+isEmpty(MDICT_PLUGINSDIR) {
+  MDICT_PLUGINSDIR = .
+}
+
+MDICT_APPNAME = $$[MDICT_APPNAME]
+
+isEmpty(MDICT_APPNAME) {
+  MDICT_APPNAME = mdictionary
+}
+
+
+DESTDIR = $${MDICT_PLUGINSDIR}/$${MDICT_APPNAME}
+
+
+
+SOURCES +=  \
+    GooglePlugin.cpp \
+    TranslationGoogle.cpp \
+    GoogleDictDialog.cpp \
+    GoogleSettingsDialog.cpp
+
+HEADERS += \
+    GooglePlugin.h \
+    ../../../includes/DictDialog.h \
+    ../../../includes/translation.h \
+    ../../../includes/settings.h \
+    ../../../includes/CommonDictInterface.h \
+    TranslationGoogle.h \
+    GoogleDictDialog.h \
+    GoogleSettingsDialog.h
+
+
+
+    
+unix {
+  #VARIABLES
+  isEmpty(PREFIX) {
+    PREFIX = /usr
+  }
+  
+  BINDIR = $$PREFIX/bin
+  LIBDIR = $$PREFIX/lib/$${MDICT_APPNAME}
+  DATADIR =$$PREFIX/share
+
+  DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
+
+  #MAKE INSTALL
+
+  INSTALLS += target dicts
+
+  target.path = $$LIBDIR
+
+  dicts.path = $$LIBDIR
+
+}
+
+RESOURCES += \
+    icons.qrc
diff --git a/trunk/src/plugins/google/tests/test.cpp b/trunk/src/plugins/google/tests/test.cpp
new file mode 100644 (file)
index 0000000..09924e0
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+#include "test.h"
+#include <QSignalSpy>
+
+void GoogleTest::getNew() {
+
+    GooglePlugin googlePlugin(this);
+    Settings *settings=new Settings;
+    settings->setValue("langFrom","pl");
+    settings->setValue("langTo","en");
+}
+
+QTEST_MAIN(GoogleTest)
diff --git a/trunk/src/plugins/google/tests/test.h b/trunk/src/plugins/google/tests/test.h
new file mode 100644 (file)
index 0000000..70a8bcf
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+#ifndef TEST_H
+#define TEST_H
+
+#include <QtTest/QtTest>
+#include "../src/GooglePlugin.h"
+
+
+ class GoogleTest: public QObject
+ {
+     Q_OBJECT
+
+
+ private slots:
+     void getNew();
+
+ };
+
+
+#endif // TEST_H
diff --git a/trunk/src/plugins/google/tests/tests.pro b/trunk/src/plugins/google/tests/tests.pro
new file mode 100644 (file)
index 0000000..22afa83
--- /dev/null
@@ -0,0 +1,26 @@
+######################################################################
+# Automatically generated by qmake (1.07a) Wed Aug 4 11:35:12 2010
+######################################################################
+
+CONFIG += qtestlib
+QT += core gui network
+TARGET = GooglrPluginTests
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+HEADERS += test.h \
+    ../src/GooglePlugin.h \
+    ../../../includes/translation.h \
+    ../../../includes/settings.h \
+    ../../../includes/DictDialog.h \
+    ../../../includes/CommonDictInterface.h \
+    ../src/TranslationGoogle.h
+
+SOURCES += test.cpp \
+    ../src/GooglePlugin.cpp \
+    ../src/TranslationGoogle.cpp
+
+check.target = check
+check.commands = ./GooglePluginTests
+QMAKE_EXTRA_TARGETS += check
index 512061a..d465f5f 100644 (file)
@@ -1,5 +1,5 @@
 TEMPLATE = subdirs
-SUBDIRS = xdxf
+SUBDIRS = xdxf google
 
 check.target = check
 check.CONFIG = recursive
index 0a1246b..b220398 100644 (file)
 
 *******************************************************************************/
 /*! \file TranslationXdxf.cpp
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
 */
 
 
 #include "TranslationXdxf.h"
 #include <QDebug>
 
-TranslationXdxf::TranslationXdxf() {
+TranslationXdxf::TranslationXdxf():_key(""),_dictionaryInfo("") {
+    xdxfPlugin=0;
 }
 
 TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
@@ -33,6 +35,7 @@ TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
     this->xdxfPlugin=xdxfPlugin;
     if(xdxfPlugin)
         _dictHash = xdxfPlugin->hash();
+    _bookmark=0;
 }
 
 QString TranslationXdxf::key() const {
index 8236e39..f01acaa 100644 (file)
@@ -63,7 +63,6 @@ private:
     QString _dictionaryInfo;
     XdxfPlugin *xdxfPlugin;
     int _dictHash;
-
 };
 
 #endif // TRANSLATIONXDXF_H
index 1d00913..2deb306 100644 (file)
 
 XdxfDictDialog::XdxfDictDialog(XdxfPlugin *plugin, QObject *parent) :
     DictDialog(parent) {
-
     this->plugin = plugin;
 }
 
-
 Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
     return XdxfLoadDialog::getSettings(parent);
 }
index ac83859..e0b2ba8 100644 (file)
@@ -38,13 +38,13 @@ public:
     explicit XdxfDictDialog(XdxfPlugin* plugin, QObject *parent = 0);
     /*!
       Shows add new xdxf dictionary dialog and returns settings of new dict
-      \param parent parent widget on which will be displayed dialog
+      \param parent parent widget on which dialog will be displayed
       */
     Settings* addNewDictionary(QWidget *parent);
 
     /*!
       Shows settings dialog and save new settings in plugin
-      \param parent parent widget on which will be displayed dialog
+      \param parent parent widget on which dialog will be displayed
       */
     void changeSettings(QWidget *parent);
 
index ff8e43f..9311429 100644 (file)
@@ -29,7 +29,7 @@
 #include <QtGui>
 #include "../../../includes/settings.h"
 
-//! Displays dialog which allow user to add new xdxf dictionary
+//! Displays dialog which allows user to add new xdxf dictionary
 class XdxfLoadDialog : public QDialog {
     Q_OBJECT
 public:
@@ -37,14 +37,14 @@ public:
 
     /*! Displays dialog and returns settings of new dictionary
         \return Setting object containing new dictionary settings or NULL in
-        case which user cancel dialog
+        case user cancels dialog
     */
     static Settings* getSettings(QWidget *parent);
 
-    //! Returns choosen by user dictionary file path
+    //! Returns dictionary file path chosen by user
     QString dicitonaryFilePath();
 
-    //! Returns if user want to cache dictionary
+    //! Returns if user wants to cache dictionary
     bool generateCache();
 
 signals:
index da1cc5e..abcf16c 100644 (file)
@@ -38,10 +38,10 @@ public:
 
     static Settings* getSettings(XdxfPlugin* plugin, QWidget *parent);
 
-    //! Returns choosen by user dictionary file path
+    //! Returns dictionary file path chosen by user
     QString dicitonaryFilePath();
 
-    //! Returns if user want to cache dictionary
+    //! Returns if user wants to cache dictionary
     bool generateCache();
 
 private Q_SLOTS:
index e99f6ba..eb111dc 100644 (file)
@@ -20,6 +20,7 @@
 *******************************************************************************/
 
 /*! \file xdxfplugin.cpp
+\author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
 */
 
 #include "xdxfplugin.h"
@@ -282,14 +283,12 @@ void XdxfPlugin::setPath(QString path){
 
 CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
     XdxfPlugin *plugin = new XdxfPlugin();
-    static int a=0;
     if(settings){
         plugin->setPath(settings->value("path"));
         QStringList list = settings->keys();
         foreach(QString key, list)
             plugin->settings()->setValue(key, settings->value(key));
 
-        a=a+1;
         plugin->db_name = plugin->_settings->value("type")
                          + plugin->_settings->value("path");
         plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);
@@ -343,7 +342,7 @@ void XdxfPlugin::setSettings(Settings *settings) {
     }
     delete settings;
 
-    emit settingsChanged();
+    Q_EMIT settingsChanged();
 }
 
 void XdxfPlugin::getDictionaryInfo() {
@@ -373,7 +372,7 @@ void XdxfPlugin::getDictionaryInfo() {
     QString format = "png";
     QString initialPath = QDir::currentPath() + tr("/xdxf.") + format;
 
-    _infoNote="path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")";
+    _infoNote="path=\""+initialPath+"\"> \n" + _name + " [" + _langFrom + "-" + _langTo + "] (" + _type + ")";
 
     dictionaryFile.close();
 }
index e413e2c..f844971 100644 (file)
@@ -59,7 +59,7 @@ public:
     //! returns destination language code iso 639-2
     QString langTo() const;
 
-    //! returns dictionary name (like "old english" or so)
+    //! returns dictionary name (like "old English" or so)
     QString name() const;
 
     //! returns dictionary type (xdxf, google translate, etc)
@@ -69,7 +69,7 @@ public:
     QString infoNote() const;
 
     /*! returns DictDialog object that creates dialogs
-        for adding new dictionary and change plugin tings
+        for adding new dictionary and changing plugin things
       */
     DictDialog* dictDialog();
 
@@ -85,7 +85,7 @@ public:
     //! returns a unique hash for a dictionary
     uint hash() const;
 
-    //! set unique value (unique for every dictionary not plugin)
+    //! sets unique value (unique for every dictionary not plugin)
     void setHash(uint);
 
     //! returns current plugin settings
@@ -114,7 +114,7 @@ public Q_SLOTS:
     void stop();
 
 Q_SIGNALS:
-    //! emited with percent count of caching progress, and time elapsed from
+    //! emitted with percent count of caching progress, and time elapsed from
     //! last signal emit
     void updateCachingProgress(int, int);
 
@@ -158,10 +158,9 @@ private:
     QSqlDatabase db;
     QString db_name;
 
-    //! number of words in dicrionary
+    //! number of words in dictionary
     long _wordsCount;
 
-
     volatile bool stopped;
     Settings *_settings;
     XdxfDictDialog* _dictDialog;
index a29199c..300984a 100644 (file)
@@ -18,7 +18,7 @@
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-/*! /file tst_backbone.cpp
+/*! \file tst_backbone.cpp
 \brief Backbone tests
 
 \author Bartosz Szatkowski <bulislaw@linux.com>