Merge branch 'master' into google
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.cpp
index ae9f35e..09af5e7 100644 (file)
 
 XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                     _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
-                    _type("xdxf"), _infoNote(tr("")) {
+                    _type(tr("xdxf")), _infoNote(tr("")) {
     _wordsCount = -1;
     _settings = new Settings();
     _dictDialog = new XdxfDictDialog(this);
-    cachingDialog = new XdxfCachingDialog();
+    cachingDialog = new XdxfCachingDialog(this);
+
 
     connect(cachingDialog, SIGNAL(cancelCaching()),
             this, SLOT(stop()));
-
     connect(this, SIGNAL(updateCachingProgress(int,int)),
             cachingDialog, SLOT(updateCachingProgress(int,int)));
 
+
     _settings->setValue("type","xdxf");
 
     stopped = false;
@@ -53,6 +54,7 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
 
 XdxfPlugin::~XdxfPlugin() {
     delete _settings;
+    delete cachingDialog;
 }
 
 
@@ -136,7 +138,6 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
 
 QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
     QTime time;
-    time.start();
     QSet<Translation*> translations;
     QFile dictionaryFile(path);
 
@@ -187,7 +188,6 @@ QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
     }
     stopped=false;
     dictionaryFile.close();
-    qDebug() << time.elapsed();
     return translations.toList();
 }
 
@@ -352,28 +352,29 @@ bool XdxfPlugin::isCached() {
 
 
 void XdxfPlugin::setSettings(Settings *settings) {
+    if(settings)
+    {
+        QString oldPath = _settings->value("path");
+        if(oldPath != settings->value("path")) {
+            setPath(settings->value("path"));
+        }
 
-    QString oldPath = _settings->value("path");
-    if(oldPath != settings->value("path")) {
-        setPath(settings->value("path"));
-    }
+       foreach(QString key, settings->keys())
+           if(key != "generateCache")
+               _settings->setValue(key, settings->value(key));
 
-   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") {
+            makeCache("");
+        }
+        else if (settings->value("generateCache") != "true") {
+           _settings->setValue("cached", "false");
+        }
 
-    if((_settings->value("cached") == "false" ||
-            _settings->value("cached").isEmpty()) &&
-            settings->value("generateCache") == "true") {
-        makeCache("");
-    }
-    else if (settings->value("generateCache") != "true") {
-       _settings->setValue("cached", "false");
+        getDictionaryInfo();
+        delete settings;
     }
-
-
-    delete settings;
-
     Q_EMIT settingsChanged();
 }
 
@@ -445,7 +446,7 @@ int XdxfPlugin::countWords() {
     return wordsCount;
 }
 
-bool XdxfPlugin::makeCache(QString dir) {
+bool XdxfPlugin::makeCache(QString) {
     cachingDialog->setVisible(true);
     QCoreApplication::processEvents();
     stopped = false;
@@ -456,7 +457,6 @@ bool XdxfPlugin::makeCache(QString dir) {
 
     QFile dictionaryFile(dictFileN.filePath());
 
-
     if (!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
         Q_EMIT updateCachingProgress(100, 0);
         Q_EMIT notify(Notify::Warning,