Merge branch 'master' into google
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 10 Sep 2010 12:34:42 +0000 (14:34 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 10 Sep 2010 12:34:42 +0000 (14:34 +0200)
1  2 
src/mdictionary/backbone/History.cpp
src/mdictionary/backbone/backbone.cpp
src/plugins/xdxf/xdxfplugin.cpp

@@@ -34,6 -34,7 +34,6 @@@ History::History(int maxSize, QObject *
      _listAvailable = false;
  }
  
 -
  void History::setMaxSize(int size) {
      if(maxSize() <= 0) return;
      if(size > _maxSize) {
@@@ -59,7 -60,7 +59,7 @@@ int History::maxSize() 
  
  void History::add(QString word) {
      if(currentElement != -1) {
-         //we search the same word so we don't add it again
+         //we search for the same word so we don't add it again
          if(_history[currentElement] == word)
              return;
      }
@@@ -81,7 -81,7 +81,7 @@@ void Backbone::init() 
  
     //Install default config files
     ConfigGenerator confGen;
-    confGen.generateCss(_dir + "style.css");
+    ///confGen.generateCss(_dir + "style.css");
     confGen.generateDefaultConfig(_configPath);
  
     loadPrefs(_configPath);
@@@ -470,7 -470,7 +470,7 @@@ void Backbone::dictUpdated() 
  
      // For convienence this function is called for each change in dictionaries
      // and each call dumps configuration for all dictionaries into file.
-     // Maybe better way would be to store new/changed configuration but
+     // Maybe a better way would be to store new/changed configuration but
      // parsing settings file and figuring out what was changed, in my opinion,
      // would take more time
      _history->setMaxSize(_historyLen);
@@@ -523,6 -523,11 +523,6 @@@ void Backbone::searchHtml(QList<Transla
      foreach(Translation* tr, translations) {
           if(containsDict(tr->dict()) || !tr->dict())
              dummy.append(TranslationPtr(tr));
 -  /*      foreach(CommonDictInterface* dict, activeDicts()) {
 -            Translation* trans = dict->getTranslationFor(tr->key());
 -            if(trans)
 -                dummy.append(TranslationPtr(trans));
 -        } */
      }
      if(translations.size()>0) {
          Translation *tr = translations.at(0);
@@@ -35,18 -35,12 +35,12 @@@ XdxfPlugin::XdxfPlugin(QObject *parent
      connect(_dictDialog, SIGNAL(notify(Notify::NotifyType,QString)),
              this, SIGNAL(notify(Notify::NotifyType,QString)));
  
-     cachingDialog = new XdxfCachingDialog(this);
  
      _settings->setValue("type","xdxf");
      _icon = QIcon("/usr/share/mdictionary/xdxf.png");
      _wordsCount = -1;
      stopped = false;
  
-     connect(cachingDialog, SIGNAL(cancelCaching()),
-             this, SLOT(stop()));
-     connect(this, SIGNAL(updateCachingProgress(int,int)),
-             cachingDialog, SLOT(updateCachingProgress(int,int)));
      initAccents();
  }
  
@@@ -64,7 -58,6 +58,6 @@@ void XdxfPlugin::retranslate() 
  
  XdxfPlugin::~XdxfPlugin() {
      delete _settings;
-     delete cachingDialog;
      delete _dictDialog;
  }
  
@@@ -436,13 -429,9 +429,13 @@@ bool XdxfPlugin::getDictionaryInfo() 
      reader.readNextStartElement();
      if(reader.name()=="full_name")
          _name=reader.readElementText();
 +    else
 +        qDebug()<<"no full_name";
      reader.readNextStartElement();
      if(reader.name()=="description")
          _infoNote=reader.readElementText();
 +    else
 +        qDebug()<<"no description";
  
      _dictionaryInfo= _name + " [" + _langFrom + "-"
                  + _langTo + "]";
@@@ -490,7 -479,17 +483,17 @@@ int XdxfPlugin::countWords() 
  
  
  bool XdxfPlugin::makeCache(QString) {
-     cachingDialog->setVisible(true);
+     XdxfCachingDialog d(_dictDialog->lastDialogParent());
+     connect(&d, SIGNAL(cancelCaching()),
+             this, SLOT(stop()));
+     connect(this, SIGNAL(updateCachingProgress(int,int)),
+             &d, SLOT(updateCachingProgress(int,int)));
+     d.show();
      QCoreApplication::processEvents();
      QFileInfo dictFileN(_settings->value("path"));
      QString cachePathN;
  
      /*add all words to db*/
      while (!reader.atEnd() && !stopped) {
          QCoreApplication::processEvents();
          reader.readNext();
          if(reader.tokenType() == QXmlStreamReader::StartElement) {
              cur.exec();
              counter++;
              int prog = counter*100/_wordsCount;
-             if(prog % 5 == 0 && lastProg != prog) {
+             if(prog % 2 == 0 && lastProg != prog) {
                  Q_EMIT updateCachingProgress(prog,timer.restart());
                  lastProg = prog;
              }
      }
      cur.exec("END;");
      cur.exec("select count(*) from dict");
-     cachingDialog->setVisible(false);
  
      /*checke errors (wrong number of added words)*/
      countWords();
      _settings->setValue("cache_path", cachePathN);
      _settings->setValue("cached", "true");
  
+     disconnect(&d, SIGNAL(cancelCaching()),
+             this, SLOT(stop()));
+     disconnect(this, SIGNAL(updateCachingProgress(int,int)),
+             &d, SLOT(updateCachingProgress(int,int)));
      db.close();
      return true;
  }