refaktoring
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 7 Sep 2010 06:28:54 +0000 (08:28 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 7 Sep 2010 06:28:54 +0000 (08:28 +0200)
25 files changed:
src/include/AccentsNormalizer.h
src/include/CommonDictInterface.h
src/include/DictDialog.h
src/include/GUIInterface.h
src/include/settings.h
src/include/translation.h
src/mdictionary/backbone/BookmarkTranslations.h
src/mdictionary/backbone/Bookmarks.cpp
src/plugins/google/GooglePlugin.cpp
src/plugins/google/GooglePlugin.h
src/plugins/google/GoogleSettingsDialog.h
src/plugins/google/TranslationGoogle.h
src/plugins/xdxf/TranslationXdxf.cpp
src/plugins/xdxf/XdxfCachingDialog.cpp
src/plugins/xdxf/XdxfCachingDialog.h
src/plugins/xdxf/XdxfLoadDialog.cpp
src/plugins/xdxf/XdxfLoadDialog.h
src/plugins/xdxf/XdxfSettingsDialog.h
src/plugins/xdxf/xdxfplugin.cpp
src/plugins/xdxf/xdxfplugin.h
tests/GooglePluginTests/test.cpp
tests/GooglePluginTests/test.h
tests/XdxfPluginTests/test.cpp
tests/XdxfPluginTests/test.h
tests/mDictionaryTests/CommonDictInterfaceMock.h

index 0343e88..9381313 100644 (file)
@@ -21,7 +21,6 @@
 
 /*! /file AccentsNormalizer.h
 \brief Common functionality for all classes that need to remove accents from strings
-
 \author Bartosz Szatkowski <bulislaw@linux.com>
 */
 
 #include <QString>
 #include <QRegExp>
 
-
+//! Common functionality for all classes that need to remove accents from strings
 class AccentsNormalizer {
   protected:
     QMap<QChar, QRegExp> letters;
     QRegExp noLetter;
 
+    //! removes accents from letters in searched word (e.g. ą -> a, ł -> l)
     QString removeAccents(QString string) {
        string = string.toLower();
        QString normalized = string.normalized(QString::NormalizationForm_KD);
@@ -48,6 +48,7 @@ class AccentsNormalizer {
        return normalized;
     }
 
+   //! initializes the list of pairs (letters, accents)
     void initAccents() {
         letters['a'] = QRegExp(QString::fromUtf8("[ÀàÁáÂÂâÃãÄäÅåæÆĀāĂ㥹ǠȀǡȁǢȂǣȃȦȧǺȺǻǼǍǽǎǞǟⱥ]"), Qt::CaseInsensitive);
         letters['b'] = QRegExp(QString::fromUtf8("[ƀƁƂƃɃƄƅ]"), Qt::CaseInsensitive);
index f09815d..a3c9790 100644 (file)
@@ -45,7 +45,6 @@ class CommonDictInterface : public QObject, public AccentsNormalizer {
   Q_OBJECT
   public:
     CommonDictInterface(QObject *parent = 0):QObject(parent) {}
-
     virtual ~CommonDictInterface() {}
 
     //! returns source language code iso 639-2
@@ -67,7 +66,6 @@ class CommonDictInterface : public QObject, public AccentsNormalizer {
         for adding new dictionary and changing plugin settings*/
     virtual DictDialog* dictDialog() = 0;
 
-
     //! returns new, clean copy of plugin with settings set as in Settings*
     virtual CommonDictInterface* getNew(const Settings*) const = 0;
 
@@ -78,10 +76,14 @@ class CommonDictInterface : public QObject, public AccentsNormalizer {
     virtual QString search(QString key) = 0;
 
     //! \returns unique value (unique for every dictionary, not plugin)
-    virtual uint hash() const = 0;
+    uint hash() const {
+        return _hash;
+    }
 
     //! sets unique value (unique for every dictionary, not plugin)
-    virtual void setHash(uint) = 0;
+    void setHash(uint) {
+        this->_hash=_hash;
+    }
 
     //! returns current plugin settings
     virtual Settings* settings() = 0;
@@ -112,13 +114,10 @@ class CommonDictInterface : public QObject, public AccentsNormalizer {
     //! stops current operation
     virtual void stop() = 0;
 
-    virtual void retranslate() = 0;
+    //! loads translations for each plugin only once
+    virtual void retranslate() {}
 
   Q_SIGNALS:
-
-    //! emitted when dictionary is ready to use afer being loaded
-    void loaded(CommonDictInterface*);
-
     //! emitted after change in dictionary settings
     void settingsChanged();
 
@@ -131,11 +130,16 @@ class CommonDictInterface : public QObject, public AccentsNormalizer {
     
 
 protected:
+//! removes accents from letters in searched word (e.g. ą -> a, ł -> l)
     QString removeAccents(QString string) {
         if(settings()->value("strip_accents") == "true")
             return AccentsNormalizer::removeAccents(string);
         return string;
     }
+
+private:
+    uint _hash;
+
 };
 
 Q_DECLARE_INTERFACE(CommonDictInterface, "CommonDictInterface/0.1");
index fc83744..1cfd403 100644 (file)
 
 *******************************************************************************/
 
+/*! \file DictDialog.h
+    \brief Interface for plugin dialog provider
+    \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
+
+
 //Created by Mateusz Półrola
 
 #ifndef DICTDIALOG_H
index 2f10cc1..6f94f06 100644 (file)
@@ -43,7 +43,6 @@ class GUIInterface : public QMainWindow {
 
 public:
     GUIInterface(QWidget *parent = 0) :QMainWindow(parent) {}
-
     virtual ~GUIInterface() {}
 
     //! Returns all loaded dictionaries with information about that they are
index 6843a79..9b338ae 100644 (file)
   It's important for plugin to store all information given to it in Settings.*/
 class Settings {
   public:
-    Settings(){}
+    Settings() {}
+    ~Settings() {}
     Settings(const Settings* set) {
         _settings = QHash<QString, QString>(set->_settings);
     }
-    ~Settings(){}
 
     /*! \returns value fo given key
-         \param key
+         \param key name of given setting
+         \return value of given setting
     */
     QString value(const QString key) const {
         if(!_settings.contains(key)) {
@@ -55,16 +56,21 @@ class Settings {
         return _settings[key];
     }
 
-    //! sets key to value
+    /*! sets key to value
+        \param key name of given setting
+        \param value of given setting
+    */
     void setValue(const QString key, const QString value) {
         _settings.insert(key, value);
     }
 
+    //! \returns list of keys (QList<QString>)
     QList<QString> keys() const {
         return _settings.keys();
     }
 
 private:
+    //! keeps the settings
     QHash<QString, QString> _settings;
 };
 
index a6a20a9..20e1453 100644 (file)
@@ -42,9 +42,11 @@ class Translation {
   public:
     Translation  () { _bookmark = 0;}
     virtual ~Translation () {}
+
     //! \return word to be translated
     virtual QString key() const = 0;
  
+    //! compares two translations by key
     bool operator==(Translation* translation) {
         return this->key()==translation->key();
     }
@@ -69,8 +71,9 @@ class Translation {
     //! returns coresponding dict object
    virtual uint dict() const {return 0;}
 
-   protected:
-       bool _bookmark;
+ protected:
+ //! indicates whether this translation is in bookmark
+    bool _bookmark;
 
 };
 
index 6dbd1b9..6931ce9 100644 (file)
@@ -73,7 +73,7 @@ public:
         \param word for which we want to find a translation */
     void setKey(QString key) {
         _key = key;
-    };
+    }
 
     //! sets information about dictionary
     void setDictionaryInfo(QString dictionaryInfo) {
index 32a3ab3..a3a0fca 100644 (file)
@@ -139,7 +139,6 @@ QList<Translation*> Bookmarks::searchWordList(QString word) {
 
 
 QStringList Bookmarks::search(QString word, QString dbName) {
-    checkAndCreateDb();
     QStringList result;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
index 5a9c13f..970ee39 100644 (file)
@@ -116,6 +116,7 @@ void GooglePlugin::setConnectionAccept(QString connectionAcepted) {
         _settings->setValue("connection_accepted","false");
 }
 
+
 bool GooglePlugin::isConnectionAccept() const {
     if(_settings->value("connection_accepted")=="true")
         return true;
@@ -124,23 +125,7 @@ bool GooglePlugin::isConnectionAccept() const {
 }
 
 
-uint GooglePlugin::hash() const {
-    return _hash;
-}
-
-
-void GooglePlugin::setHash(uint _hash) {
-    this->_hash=_hash;
-}
-
-
 Settings* GooglePlugin::settings() {
-/*    Settings *returnSettings=new Settings;
-    QStringList list = _settings->keys();
-    foreach(QString key, list)
-            returnSettings->setValue(key,_settings->value(key));
-    return returnSettings;
-*/
     return _settings;
 }
 
index 6e898b0..2d9d7ff 100644 (file)
@@ -65,8 +65,10 @@ public:
     //! returns information about dictionary in html (name, authors, etc)
     QString infoNote() const;
 
+    //! sets the language to which the translation is done
     void setLangTo(QString langTo);
 
+    //! sets the language from which the translation is done
     void setLangFrom(QString langFrom);
 
     /*! returns DictDialog object that creates dialogs
@@ -80,19 +82,15 @@ public:
     //! returns whether plugin can start searching
     bool isAvailable() const;
 
+    //! sets if connection with Internet is possible
     void setConnectionAccept(QString connectionAcepted);
 
+    //! returns the value of "connection_accepted" from settings
     bool isConnectionAccept() 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;
-
-    //! sets unique value (unique for every dictionary, not plugin)
-    void setHash(uint);
-
     //! returns current plugin settings
     Settings* settings();
 
@@ -102,8 +100,10 @@ public:
     //! returns plugin icon
     QIcon* icon();
 
+    //! returns empty translation object (to be fetched later) for given key
     Translation* getTranslationFor(QString key);
 
+    //! initializes the list of available languages in Google translator
     static QMap<QString, QString> initLanguages();
 
 public slots:
@@ -119,25 +119,37 @@ public slots:
     //! stop current operation
     void stop();
 
+    //! function called after the request from Google is returned
     void done();
 
+    //! transforms Google format to String with translation
     QString jsonParse(QString result);
+
+    //! sets information about dictionary
     void getDictionaryInfo();
 
+    //! loads translations for each plugin only once
     void retranslate();
 
 private:
+    //! maps languages full names to two-letter acronyms
     QMap<QString, QString> languages;
+
+    //! name of a dictionary
     QString _name;
     //! type of a dictionary
     QString _type;
     //! information about dictionary
     QString _infoNote;
+    //! unique number of a dictionary assigned to it by backbone
     uint _hash;
+    //! icon displayed during translations and when the dictionary is chosen
     QIcon _icon;
     Settings *_settings;
+    //! indicates if search is stopped
     bool stopped;
     bool _connectionAccept;
+    //! indicates if response from Google appeared
     volatile bool wait;
     QHttp *http;
     GoogleDictDialog *_dictDialog;
index 24d1857..991f65c 100644 (file)
@@ -65,8 +65,11 @@ public:
     QString langTo();
 
 private slots:
+    //! assigns the language chosen from a list(langFromComboBox) to _langFrom
     void activatedFrom(int);
+    //! assigns the language chosen from a list(langToComboBox) to _langTo
     void activatedTo(int);
+    //! handles the "swap languages" button
     void changeLangButtonClicked();
 
 
@@ -77,28 +80,15 @@ private:
     QLabel* connectInfoLabel;
     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
index 4068136..d1a0797 100644 (file)
@@ -68,10 +68,9 @@ private:
     QString _key;
     QString _dictionaryInfo;
     QString _trans;
-    GooglePlugin *googlePlugin;
     int _dictHash;
     bool error;
-
+    GooglePlugin *googlePlugin;
 };
 
 #endif // TRANSLATIONGOOGLE_H
index 7bb8d8d..7a622d4 100644 (file)
@@ -54,11 +54,12 @@ QString TranslationXdxf::toHtml() const {
     QString result("");
     if(!xdxfPlugin)
         return result;
-    result=result + "<dict>" + "<info";
+
+    result=result + "<dict> <info path=\"/usr/share/mdictionary/xdxf.png\" ";
     if(isBookmark())
-        result+= " bookmark=\"true\" ";
+        result+= " bookmark=\"true\" > \n";
     else
-        result+= " bookmark=\"false\" ";
+        result+= " bookmark=\"false\" > \n";
     result+= _dictionaryInfo + "</info>" + xdxfPlugin->search(_key) + "</dict>";
     return result.replace("&","&amp;");
 }
index 7ad2f59..8083ae6 100644 (file)
@@ -75,10 +75,6 @@ void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
 
 }
 
-void XdxfCachingDialog::reject() {
-    return;
-}
-
 void XdxfCachingDialog::cancelButtonClicked(){
     return;
 }
index 93eac93..8d638f7 100644 (file)
@@ -39,11 +39,9 @@ public:
     explicit XdxfCachingDialog(XdxfPlugin *parent = 0);
 
 Q_SIGNALS:
+    //! signal emitted when user cancels caching of a dictionary
     void cancelCaching();
 
-public Q_SLOTS:
-    void reject();
-
 private Q_SLOTS:
     void cancelButtonClicked();
     void updateCachingProgress(int, int);
@@ -53,6 +51,7 @@ private:
     QProgressBar* cachingProgressBar;
     QPushButton* cancelButton;
     QVBoxLayout* verticalLayout;
+    //! used to check the progress of dictionary caching
     QTime time;
 };
 
index 269bb87..d43175d 100644 (file)
@@ -102,9 +102,6 @@ void XdxfLoadDialog::addDictionary() {
     if(!_dicitonaryFilePath.isEmpty()) {
         accept();
     }
-    else {
-        reject();
-    }
 }
 
 QString XdxfLoadDialog::dicitonaryFilePath() {
index 97e79e5..8ce8df0 100644 (file)
@@ -47,10 +47,6 @@ public:
     //! Returns if user wants to cache dictionary
     bool generateCache();
 
-signals:
-
-public slots:
-
 private Q_SLOTS:
     void selectFile();
     void addDictionary();
index b7543f8..b36597b 100644 (file)
@@ -35,13 +35,13 @@ class XdxfSettingsDialog : public QDialog
     Q_OBJECT
 public:
     explicit XdxfSettingsDialog(XdxfPlugin* plugin, QWidget *parent = 0);
-
+    //! \returns settings of a given plugin
     static Settings* getSettings(XdxfPlugin* plugin, QWidget *parent);
 
-    //! Returns dictionary file path chosen by user
+    //! \returns dictionary file path chosen by user
     QString dicitonaryFilePath();
 
-    //! Returns if user wants to cache dictionary
+    //! \returns if user wants to cache dictionary
     bool generateCache();
 
 private Q_SLOTS:
index 626e300..330afa8 100644 (file)
@@ -87,7 +87,7 @@ QString XdxfPlugin::type() const {
 
 
 QString XdxfPlugin::infoNote() const {
-    return  _infoNote;
+    return _infoNote;
 }
 
 
@@ -146,7 +146,7 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
         if(ok) {  /*add key word to list*/
             translations.insert(new TranslationXdxf(
                     cur.value(0).toString().toLower(),
-                    _infoNote, this));
+                    _dictionaryInfo, this));
             i++;
         }
     }
@@ -197,7 +197,7 @@ QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
                 }
                 if(ok) {  /*add key word to list*/
                     translations<<(new TranslationXdxf(readKey.toLower(),
-                                    _infoNote,this));
+                                    _dictionaryInfo,this));
                     i++;
                 }
                 if(i>=limit && limit!=0)
@@ -338,24 +338,7 @@ bool XdxfPlugin::isAvailable() const {
 }
 
 
-void XdxfPlugin::setHash(uint _hash) {
-    this->_hash=_hash;
-}
-
-
-uint XdxfPlugin::hash() const {
-   return _hash;
-}
-
-
 Settings* XdxfPlugin::settings() {
-/*
-    Settings *returnSettings=new Settings;
-    QStringList list = _settings->keys();
-    foreach(QString key, list)
-            returnSettings->setValue(key,_settings->value(key));
-    return returnSettings;
-*/
     return _settings;
 }
 
@@ -453,10 +436,9 @@ bool XdxfPlugin::getDictionaryInfo() {
     if(reader.name()=="description")
         _infoNote=reader.readElementText();
 
-    QString initialPath = "/usr/share/mdictionary/xdxf.png";
-
-    _infoNote=" path=\""+initialPath+"\"> \n" + _name + " [" + _langFrom + "-"
+    _dictionaryInfo= _name + " [" + _langFrom + "-"
                 + _langTo + "]";
+
     dictionaryFile.close();
     if(okFormat)
         return true;
index fcaf34a..76ac714 100644 (file)
@@ -83,12 +83,6 @@ public:
     //! returns a description of a word given by a QString
     QString search(QString key);
 
-    //! returns a unique hash for a dictionary
-    uint hash() const;
-
-    //! sets unique value (unique for every dictionary, not plugin)
-    void setHash(uint);
-
     //! returns current plugin settings
     Settings* settings();
 
@@ -121,6 +115,7 @@ public Q_SLOTS:
     //! stop current operation
     void stop();
 
+    //! loads translations for each plugin only once
     void retranslate();
 
 
@@ -133,27 +128,43 @@ Q_SIGNALS:
 
 
 private:
-/*! returns true or false depending on whether the dictionary is cached
-    or not, not implemented yet
- */
-    bool isCached();
-
-//! sets the path to dictionary file and adds it to settings
- //   void setPath(QString);
 
+    /*! returns true or false depending on whether the dictionary is cached
+        or not, not implemented yet
+     */
+    bool isCached();
+    /*! searches for a list of words similar to a word in a database file
+    \param word key compared with keys in a database
+    \param limit limits the number of translations in returned list,
+           0 means unlimited
+    \returns list of translations
+    */
     QList<Translation*> searchWordListCache(QString word, int limit=0);
 
+    /*! searches for a list of words similar to a word in a xdxf file
+    \param word key compared with keys in a xdxf file
+    \param limit limits the number of translations in returned list,
+           0 means unlimited
+    \returns list of translations
+    */
     QList<Translation*> searchWordListFile(QString word, int limit=0);
 
+    /*! searches for a translation of a word which is exactly like a key
+        in xdxf file */
     QString searchFile(QString key);
 
+    /*! searches for a translation of a word which is exactly like a key
+        in database file */
     QString searchCache(QString key);
 
     //! scans dictionary file to get information about it
     bool getDictionaryInfo();
 
+    //! counts the keys in xdxf file
     int countWords();
 
+    /*! transforms xdxf files to database files (caching operation)
+        \returns true on success, false on failure */
     bool makeCache(QString dir);
 
     //! language from which we translate
@@ -164,14 +175,18 @@ private:
     QString _name;
     //! information about dictionary
     QString _infoNote;
-    //! path to dictionary file
- //   QString path;
+
+    QString _dictionaryInfo;
+
+    //! unique number of a dictionary assigned to it by backbone
     uint _hash;
+    //! icon displayed during translations and when the dictionary is chosen
     QIcon _icon;
     QSqlDatabase db;
     QString db_name;
     //! number of words in dictionary
     long _wordsCount;
+    //! indicates if search is stopped
     volatile bool stopped;
     Settings *_settings;
     XdxfDictDialog* _dictDialog;
index c803afd..cca9ba3 100644 (file)
@@ -45,4 +45,32 @@ void GoogleTest::getDictionaryInfo() {
     QCOMPARE(plugin.infoNote(),QString(" [Polish-English] " ));
 }
 
+void GoogleTest::langFrom() {
+    GooglePlugin plugin;
+    Settings *settings=new Settings;
+    settings->setValue("lang_to","pl");
+    settings->setValue("lang_from","en");
+    plugin.setSettings(settings);
+    delete settings;
+
+    QCOMPARE(plugin.langFrom(),QString("English"));
+    QCOMPARE(plugin.langTo(),QString("Polish"));
+    QCOMPARE(plugin.type(),QString("google"));
+}
+
+void GoogleTest::getNew() {
+    GooglePlugin plugin;
+    Settings *settings=new Settings;
+    settings->setValue("lang_to","pl");
+    settings->setValue("lang_from","en");
+    CommonDictInterface *test=plugin.getNew(settings);
+    delete settings;
+
+    QCOMPARE(test->langFrom(),QString("English"));
+    QCOMPARE(test->langTo(),QString("Polish"));
+    QCOMPARE(test->type(),QString("google"));
+
+    delete test;
+}
+
 QTEST_MAIN(GoogleTest)
index b3fe336..20a518e 100644 (file)
@@ -34,6 +34,8 @@
  private slots:
      void jsonParse();
      void getDictionaryInfo();
+     void langFrom();
+     void getNew();
  };
 
 
index 8cb0a2e..b6f4b70 100644 (file)
@@ -134,6 +134,9 @@ void XdxfTest::searchWordListCache(){
         QCOMPARE(te11.at(0)->key(), QString("house"));
 
     xdxfPlugin->clean();
+    QList<Translation*> te12 = xdxfPlugin->searchWordList("1",10);
+        QCOMPARE(te2.size(), 5);
+
     delete xdxfPlugin;
 
 }
@@ -211,11 +214,46 @@ void XdxfTest::langFrom() {
     delete settings;
 
     QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
+    QCOMPARE(xdxfPlugin->langTo(), QString("POL"));
+    QCOMPARE(xdxfPlugin->name(), QString("English-Polish dictionary"));
+    QCOMPARE(xdxfPlugin->infoNote(), QString("Copyright: http://www.freelang.net/dictionary/; Version: 1.0"));
+    QCOMPARE(xdxfPlugin->type(), QString("xdxf"));
 
     xdxfPlugin->clean();
     delete xdxfPlugin;
 }
 
+void XdxfTest::isAvailable() {
+    XdxfPlugin xdxfPluginB(this);
+    Settings *settings=new Settings;
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
+    CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+    delete settings;
+
+    QCOMPARE(xdxfPlugin->isAvailable(), true);
+
+    xdxfPlugin->clean();
+    delete xdxfPlugin;
+}
+
+void  XdxfTest::removeAccents() {
+    qDebug()<<"\n";
+    XdxfPluginSub xdxf;
+    xdxf.settings()->setValue(QString("strip_accents"), QString("true"));
+
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nóżka")), QString("nozka"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("motor")), QString("motor"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nÓżKa")), QString("nozka"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("ławka")), QString("lawka"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("éàèùâêîôûëïüÿäöüç")), QString("eaeuaeioueiuyaouc"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("íőűúó")), QString("iouuo"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("-ę")), QString("-e"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\"e\"")), QString("\"e\""));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("'e'")), QString("'e'"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\e")), QString("e"));
+    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\")), QString(""));
+}
+
 void XdxfTest::timeCache() {
     qDebug()<<"\n";
     QTime timer;
@@ -225,7 +263,7 @@ void XdxfTest::timeCache() {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -236,7 +274,7 @@ void XdxfTest::timeCache() {
     timer.start();
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
@@ -274,13 +312,12 @@ void XdxfTest::timeCache() {
 void XdxfTest::timeFile() {
     qDebug()<<"\n";
     QTime timer;
-    QDate date;
     QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -290,9 +327,9 @@ void XdxfTest::timeFile() {
 
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    if(!QFile::exists("../../../../../../dict.xdxf"))
+    if(!QFile::exists("../../../dict.xdxf"))
         return;
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -324,13 +361,12 @@ void XdxfTest::timeFile() {
 void  XdxfTest::timeCacheNormalize() {
     qDebug()<<"\n";
     QTime timer;
-    QDate date;
     QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -342,7 +378,7 @@ void  XdxfTest::timeCacheNormalize() {
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
 
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     settings->setValue("generateCache", "true");
     settings->setValue("strip_accents", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
@@ -376,34 +412,15 @@ void  XdxfTest::timeCacheNormalize() {
     delete xdxfPlugin;
 }
 
-void  XdxfTest::removeAccents() {
-    qDebug()<<"\n";
-    XdxfPluginSub xdxf;
-    xdxf.settings()->setValue(QString("strip_accents"), QString("true"));
-
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nóżka")), QString("nozka"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("motor")), QString("motor"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nÓżKa")), QString("nozka"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("ławka")), QString("lawka"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("éàèùâêîôûëïüÿäöüç")), QString("eaeuaeioueiuyaouc"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("íőűúó")), QString("iouuo"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("-ę")), QString("-e"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\"e\"")), QString("\"e\""));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("'e'")), QString("'e'"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\e")), QString("e"));
-    QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\")), QString(""));
-}
-
 void XdxfTest::timeFileNormalize(){
     qDebug()<<"\n";
     QTime timer;
-    QDate date;
     QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -413,7 +430,7 @@ void XdxfTest::timeFileNormalize(){
 
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     settings->setValue("strip_accents", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
index e75db70..d1b37a3 100644 (file)
@@ -47,6 +47,7 @@
      void searchCache();
      void searchWordListCache();
      void removeAccents();
+     void isAvailable();
      void timeCache();
      void timeFile();
      void timeCacheNormalize();
index 7d67498..268ad3b 100644 (file)
@@ -54,8 +54,6 @@ public:
     QDialog* settingsDialog() {return 0;}
     CommonDictInterface* getNew(const Settings *) const { return 0;}
     bool isAvailable() const {return available;}
-    uint hash() const { return _hash;}
-    void setHash(uint h) {_hash = h;}
     void stop() {stopped = 1;}
     QIcon* icon(){return 0;}
     QString search(QString key) {return "";}