Added caching dialog with casching progress
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.cpp
index 2cc11cb..84a9879 100644 (file)
@@ -33,6 +33,8 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
     _wordsCount = -1;
     _settings = new Settings();
     _dictDialog = new XdxfDictDialog(this, this);
+    cachingDialog = new XdxfCachingDialog(this);
+
     _settings->setValue("type","xdxf");
     if(isCached())
         _settings->setValue("cached","true");
@@ -304,6 +306,7 @@ int XdxfPlugin::countWords() {
 
 
 bool XdxfPlugin::makeCache(QString dir) {
+    cachingDialog->setVisible(true);
     QFileInfo dictFileN(_settings->value("path"));
     QString cachePathN;
     cachePathN = dictFileN.dir().absolutePath() + "/"
@@ -344,6 +347,8 @@ bool XdxfPlugin::makeCache(QString dir) {
     counter=0;
     while (!reader.atEnd()) {
 
+        QCoreApplication::processEvents();
+        //usleep(50);
         reader.readNext();
 
         if(reader.tokenType() == QXmlStreamReader::StartElement) {
@@ -371,12 +376,14 @@ bool XdxfPlugin::makeCache(QString dir) {
                 counter++;
                 int prog = counter*100/_wordsCount;
                 if(prog % 5 == 0)
-                    Q_EMIT update(prog);
+                    Q_EMIT updateCachingProgress(prog);
             }
 
         }
     }
 
+    cachingDialog->setVisible(false);
+
     qDebug()<<counter;
     cur.exec("END;");
     cur.exec("select count(*) from dict");