fix bug (make cache when path was change)
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 31 Aug 2010 11:47:28 +0000 (13:47 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 31 Aug 2010 11:47:28 +0000 (13:47 +0200)
trunk/src/includes/translation.h
trunk/src/plugins/google/src/TranslationGoogle.cpp
trunk/src/plugins/google/src/TranslationGoogle.h
trunk/src/plugins/xdxf/src/TranslationXdxf.cpp
trunk/src/plugins/xdxf/src/TranslationXdxf.h
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.cpp

index 11da8f0..6fca57c 100644 (file)
@@ -39,6 +39,7 @@ class CommonDictInterface;
 class Translation {
   public:
     Translation  () { _bookmark = 0; }
+    virtual ~Translation () {}
     //! \return word to be translated
     virtual QString key() const = 0;
  
index c2cdc1e..4425691 100644 (file)
@@ -38,6 +38,11 @@ TranslationGoogle::TranslationGoogle(QString _key,QString _trans,
     _bookmark=0;
 }
 
+TranslationGoogle::~TranslationGoogle(){
+    //qDebug()<<"\n\n delete translation:: Google\n\n";
+}
+
+
 QString TranslationGoogle::key() const{
     return _key;
 }
index 08b5530..9ebc15a 100644 (file)
@@ -35,8 +35,8 @@ class TranslationGoogle : public Translation
 {
 public:
     TranslationGoogle();
-
     TranslationGoogle(QString _key,QString _trans,QString _dictionaryInfo, GooglePlugin *googlePlugin);
+    ~TranslationGoogle();
 
     //! \return word to be translated
     QString key() const;
index b220398..c214a7b 100644 (file)
@@ -38,6 +38,10 @@ TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
     _bookmark=0;
 }
 
+TranslationXdxf::~TranslationXdxf() {
+   // qDebug()<<"\n\n delete translation:: Xdxf\n\n";
+}
+
 QString TranslationXdxf::key() const {
     return _key;
 }
index f01acaa..283236c 100644 (file)
@@ -32,6 +32,7 @@ class TranslationXdxf : public Translation
 public:
     TranslationXdxf();
     TranslationXdxf(QString _key,QString _dictionaryInfo, XdxfPlugin *xdxfPlugin);
+    ~TranslationXdxf();
 
     //! \return word to be translated
     QString key() const;
index c45f180..f0c7e38 100644 (file)
@@ -115,7 +115,7 @@ void XdxfSettingsDialog::selectFile() {
     if (!fileName.isEmpty()) {
         browseLabel->setText(tr("Dictionary file: ") + fileName);
         _dicitonaryFilePath = fileName;
-    }
+    }    
 }
 
 QString XdxfSettingsDialog::dicitonaryFilePath() {
index 5573a56..ae1ba35 100644 (file)
@@ -293,7 +293,6 @@ void XdxfPlugin::setPath(QString path){
         clean();
     this->path=path;
     _settings->setValue("path",path);
-    //getDictionaryInfo();
 }
 
 CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
@@ -324,25 +323,21 @@ bool XdxfPlugin::isAvailable() const {
 }
 
 
-
 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;
@@ -350,26 +345,35 @@ bool XdxfPlugin::isCached() {
 }
 
 
-
 void XdxfPlugin::setSettings(Settings *settings) {
     if(settings)
     {
+        qDebug()<<"\n\n ustawienie ustawien";
+
+        bool isPathChange=false;
         QString oldPath = _settings->value("path");
         if(oldPath != settings->value("path")) {
             setPath(settings->value("path"));
+            isPathChange=true;
         }
 
-       foreach(QString key, settings->keys())
+        foreach(QString key, settings->keys()) {
            if(key != "generateCache")
                _settings->setValue(key, settings->value(key));
+        }
+
+        if(isPathChange) {
+            _settings->setValue("cached","false");
+            _wordsCount=0;
+        }
 
         if((_settings->value("cached") == "false" ||
-                _settings->value("cached").isEmpty()) &&
-                settings->value("generateCache") == "true") {
+            _settings->value("cached").isEmpty()) &&
+            settings->value("generateCache") == "true") {
             makeCache("");
         }
         else if (settings->value("generateCache") != "true") {
-           _settings->setValue("cached", "false");
+            _settings->setValue("cached", "false");
         }
 
         getDictionaryInfo();
@@ -379,7 +383,6 @@ void XdxfPlugin::setSettings(Settings *settings) {
 }
 
 
-
 void XdxfPlugin::getDictionaryInfo() {
     QFile dictionaryFile(path);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
@@ -418,9 +421,8 @@ QIcon* XdxfPlugin::icon() {
 }
 
 int XdxfPlugin::countWords() {
-    if(_wordsCount > 0)
+    if(_wordsCount>0)
         return _wordsCount;
-
     QFile dictionaryFile(path);
     if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
         Q_EMIT notify(Notify::Warning,
@@ -546,13 +548,13 @@ bool XdxfPlugin::makeCache(QString) {
 
     cur.exec("END;");
     cur.exec("select count(*) from dict");
-//    settings()->setValue("strip_accents", stripAcc);
 
     countWords();
     cachingDialog->setVisible(false);
 
     if(!cur.next() || countWords() != cur.value(0).toInt())
     {
+        qDebug()<<"tu??";
         Q_EMIT updateCachingProgress(100, timer.restart());
         Q_EMIT notify(Notify::Warning,
                 QString(tr("Database caching error, please try againg.")));