Merge branch 'master' into google
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.cpp
index a0f8d5e..64d5fce 100644 (file)
@@ -297,8 +297,6 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
     if(settings){
         plugin->setPath(settings->value("path"));
         QStringList list = settings->keys();
-        foreach(QString key, list)
-            plugin->settings()->setValue(key, settings->value(key));
 
         plugin->db_name = plugin->_settings->value("type")
                          + plugin->_settings->value("path");
@@ -308,6 +306,9 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
            settings->value("generateCache") == "true") {
             plugin->makeCache("");
         }
+        foreach(QString key, list)
+           if(key != "generateCache")
+                plugin->settings()->setValue(key, settings->value(key));
         delete settings;
     }
     plugin->getDictionaryInfo();
@@ -318,24 +319,34 @@ bool XdxfPlugin::isAvailable() const {
     return true;
 }
 
+
+
 void XdxfPlugin::setHash(uint _hash) {
     this->_hash=_hash;
 }
 
+
+
 uint XdxfPlugin::hash() const {
    return _hash;
 }
 
+
+
 Settings* XdxfPlugin::settings() {
     return _settings;
 }
 
+
+
 bool XdxfPlugin::isCached() {
     if(_settings->value("cached") == "true")
         return true;
     return false;
 }
 
+
+
 void XdxfPlugin::setSettings(Settings *settings) {
 
     QString oldPath = _settings->value("path");
@@ -343,22 +354,27 @@ void XdxfPlugin::setSettings(Settings *settings) {
         setPath(settings->value("path"));
     }
 
+   foreach(QString key, settings->keys())
+       if(key != "generateCache")
+           _settings->setValue(key, settings->value(key));
+
     if((_settings->value("cached") == "false" ||
-        _settings->value("cached").isEmpty()) &&
-       settings->value("generateCache") == "true") {
+            _settings->value("cached").isEmpty()) &&
+            settings->value("generateCache") == "true") {
         makeCache("");
     }
-    else {
+    else if (settings->value("generateCache") != "true") {
        _settings->setValue("cached", "false");
     }
-   foreach(QString key, settings->keys())
-       if(key != "generateCache")
-           _settings->setValue(key, settings->value(key));
+
+
     delete settings;
 
     Q_EMIT settingsChanged();
 }
 
+
+
 void XdxfPlugin::getDictionaryInfo() {
     QFile dictionaryFile(path);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
@@ -446,6 +462,7 @@ bool XdxfPlugin::makeCache(QString dir) {
     }
     QXmlStreamReader reader(&dictionaryFile);
 
+
     db.setDatabaseName(cachePathN);
     if(!db.open()) {
         qDebug() << "Database error" << db.lastError().text() << endl;
@@ -472,6 +489,9 @@ bool XdxfPlugin::makeCache(QString dir) {
 
     int lastProg = -1;
 
+    QString stripAcc = settings()->value("strip_accents");
+    settings()->setValue("strip_accents", "true");
+
 
     counter=0;
     while (!reader.atEnd() && !stopped) {
@@ -522,6 +542,7 @@ bool XdxfPlugin::makeCache(QString dir) {
 
     cur.exec("END;");
     cur.exec("select count(*) from dict");
+    settings()->setValue("strip_accents", stripAcc);
 
     countWords();
     cachingDialog->setVisible(false);