Added possibility of stopping cache process
authorBartosz Szatkowski <bulislaw@linux.com>
Fri, 13 Aug 2010 10:44:25 +0000 (12:44 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Fri, 13 Aug 2010 10:44:25 +0000 (12:44 +0200)
trunk/src/plugins/xdxf/src/xdxfplugin.cpp

index af2dd46..b33c512 100644 (file)
@@ -69,7 +69,6 @@ QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
 
 QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
 
-    qDebug() << "search cache";
     QSet<Translation*> translations;
     QString cacheFilePath = _settings->value("cache_path");
         db.setDatabaseName(cacheFilePath);
@@ -81,11 +80,8 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
         stopped = false;
         if(word.indexOf("*")==-1)
             word+="%";
-        qDebug() << word;
         word = word.replace("*", "%");
-        qDebug() << word;
         word = removeAccents(word);
-        qDebug() << word;
 
         QSqlQuery cur(db);
         cur.prepare("select word from dict where word like ? limit ?");
@@ -101,7 +97,6 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
 
 
 QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
-    qDebug() << "search file";
     QSet<Translation*> translations;
     QFile dictionaryFile(path);
 
@@ -160,7 +155,6 @@ QString XdxfPlugin::search(QString key) {
 
 
 QString XdxfPlugin::searchCache(QString key) {
-    qDebug() << "search cache";
     QString result;
     QString cacheFilePath = _settings->value("cache_path");
     db.setDatabaseName(cacheFilePath);
@@ -363,6 +357,7 @@ int XdxfPlugin::countWords() {
 
 
 bool XdxfPlugin::makeCache(QString dir) {
+    stopped = false;
     QFileInfo dictFileN(_settings->value("path"));
     QString cachePathN;
     cachePathN = QDir::homePath() + "/.mdictionary/"
@@ -371,11 +366,9 @@ bool XdxfPlugin::makeCache(QString dir) {
     QFile dictionaryFile(dictFileN.filePath());
 
 
-    qDebug() << dictFileN.path();
     if (!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
         return 0;
     }
-    qDebug() << "OLE";
 
     QXmlStreamReader reader(&dictionaryFile);
 
@@ -400,7 +393,7 @@ bool XdxfPlugin::makeCache(QString dir) {
 
 
     counter=0;
-    while (!reader.atEnd()) {
+    while (!reader.atEnd() && !stopped) {
 
         reader.readNext();
 
@@ -435,7 +428,6 @@ bool XdxfPlugin::makeCache(QString dir) {
         }
     }
 
-    qDebug()<<counter;
     cur.exec("END;");
     cur.exec("select count(*) from dict");
     if(!cur.next() || countWords() != cur.value(0).toInt())