Fixed saving "cached" parameter
authorBartosz Szatkowski <bulislaw@linux.com>
Thu, 26 Aug 2010 13:05:22 +0000 (15:05 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Thu, 26 Aug 2010 13:05:22 +0000 (15:05 +0200)
trunk/src/plugins/xdxf/src/xdxfplugin.cpp

index d050450..0988ed1 100644 (file)
@@ -303,8 +303,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));
 
         a=a+1;
         plugin->db_name = plugin->_settings->value("type")
@@ -315,6 +313,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();
@@ -325,24 +326,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");
@@ -350,22 +361,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;
 
     emit settingsChanged();
 }
 
+
+
 void XdxfPlugin::getDictionaryInfo() {
     QFile dictionaryFile(path);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
@@ -521,7 +537,6 @@ bool XdxfPlugin::makeCache(QString dir) {
             cur.prepare("insert into dict values(?,?,?)");
             cur.addBindValue(a);
             cur.addBindValue(removeAccents(a));
-            qDebug() << removeAccents(a);
             cur.addBindValue(temp);
             cur.exec();
             counter++;