Fixed caching from settings widget
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 16 Aug 2010 06:40:42 +0000 (08:40 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 16 Aug 2010 06:40:42 +0000 (08:40 +0200)
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.h

index 8d11d6f..d46960f 100644 (file)
@@ -22,6 +22,7 @@
 //Created by Mateusz Półrola
 
 #include "XdxfSettingsDialog.h"
+#include <QDebug>
 
 XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
     QDialog(parent)
@@ -122,6 +123,7 @@ Settings* XdxfSettingsDialog::getSettings(XdxfPlugin *plugin,
             settings->setValue(key, plugin->settings()->value(key));
         settings->setValue("path", settingsDialog.dicitonaryFilePath());
 
+        qDebug()<<settingsDialog.generateCache();
         if(settingsDialog.generateCache()) {
             settings->setValue("generateCache", "true");
         }
index d3af1ea..d59c673 100644 (file)
@@ -301,6 +301,9 @@ void XdxfPlugin::setSettings(Settings *settings) {
        settings->value("generateCache") == "true") {
         makeCache("");
     }
+    else {
+       _settings->setValue("cached", "false");
+    }
 
     emit settingsChanged();
 }
@@ -419,6 +422,8 @@ bool XdxfPlugin::makeCache(QString dir) {
     timer.start();
     countWords();
 
+    int lastProg = -1;
+
 
     counter=0;
     while (!reader.atEnd() && !stopped) {
@@ -451,8 +456,11 @@ bool XdxfPlugin::makeCache(QString dir) {
                 cur.exec();
                 counter++;
                 int prog = counter*100/_wordsCount;
-                if(prog % 5 == 0)
-                    Q_EMIT updateCachingProgress(prog);
+                if(prog % 5 == 0 && lastProg != prog) {
+                    Q_EMIT updateCachingProgress(prog,
+                                                 timer.restart());
+                    lastProg = prog;
+                }
             }
 
         }
index c1b7580..38cd88a 100644 (file)
@@ -104,8 +104,9 @@ public Q_SLOTS:
     void stop();
 
 Q_SIGNALS:
-    //! emited with percent count of caching progress
-    void updateCachingProgress(int);
+    //! emited with percent count of caching progress, and time elapsed from
+    //! last signal emit
+    void updateCachingProgress(int, int);
 
 
 protected: