fix bugs -'stop stardict when user click stop' and 'nacional char in words list'
authorjakub <jakub.jaszczynski@comarch.com>
Tue, 9 Nov 2010 11:01:02 +0000 (12:01 +0100)
committerjakub <jakub.jaszczynski@comarch.com>
Tue, 9 Nov 2010 11:01:02 +0000 (12:01 +0100)
src/plugins/stardict/CompressedReader.cpp
src/plugins/stardict/StarDictPlugin.cpp
src/plugins/stardict/UncompressedReader.cpp

index 1e11c82..d142934 100644 (file)
@@ -53,9 +53,14 @@ void CompressedReader::close() {
 
 
 QChar CompressedReader::readChar() {
-    char c[1];
+    char c[2]={0};
     gzread(_file, c, 1);
-    return QChar(c[0]);
+    QString cha(QString::fromUtf8(c));
+    if(!cha.at(0).isLetter() && c[0]!=0){
+        gzread(_file, c, 1);
+        cha=QString::fromUtf8(c);
+    }
+    return cha.at(0);
 }
 
 qint32 CompressedReader::readInt32BigEndian() {
index d6df778..bf75e6a 100644 (file)
@@ -109,7 +109,8 @@ QList<Translation*> StarDictPlugin::searchWordList(QString word, int limit) {
 
     int counter = 0;
     int counterLimit = 0;
-    while(counter < wordcount && (counterLimit<limit || limit==0)) {
+    stopped=false;
+    while(counter < wordcount && (counterLimit<limit || limit==0) && !stopped) {
         counter++;
         fkey = reader->readKeyword();
         if(is32b)
@@ -161,6 +162,7 @@ QByteArray StarDictPlugin::read(QByteArray::iterator it,
 QString StarDictPlugin::interpret(QByteArray::iterator it,
         QByteArray::iterator end, QChar mode,QString key, bool last) {
     QString result;
+    qDebug()<<"****** mode:     "<<mode;
     if(mode == 'm'){
         result += "<key>" + key + "</key>";
         result += QString::fromUtf8(read(it++, end));
@@ -176,12 +178,10 @@ QString StarDictPlugin::interpret(QByteArray::iterator it,
         /* delete "small" tag  from translation*/
         int indexOfSmall=result.indexOf("<small>");
         while(indexOfSmall!=-1){
-            qDebug()<<"przed"<<result;
             int indexOfEndSmall= result.indexOf("</small>");
             if(indexOfEndSmall!=-1)
                 result.remove(indexOfSmall,indexOfEndSmall-indexOfSmall+8);
             indexOfSmall=result.indexOf("<small>");
-            qDebug()<<"po"<<result;
         }
     }
     else if(mode == 't'){
@@ -283,6 +283,7 @@ QString StarDictPlugin::search(QString key, qint64 offset, qint32 len) {
 
 
 void StarDictPlugin::stop() {
+    qDebug()<<"zatrzymanie programu";
     stopped=true;
 }
 
index 6129e6a..d4370c5 100644 (file)
@@ -1,5 +1,5 @@
 #include "UncompressedReader.h"
-
+#include "QDebug"
 
 UncompressedReader::UncompressedReader(QObject *parent) :
         StarDictReader(parent) {
@@ -27,10 +27,14 @@ void UncompressedReader::close() {
 }
 
 QChar UncompressedReader::readChar() {
-    char c[1];
-
-    _stream.readRawData(c, 1);
-    return QChar(c[0]);
+    char c[2]={0};
+    _stream.readRawData(c,1);
+    QString cha(QString::fromUtf8(c));
+    if(!cha.at(0).isLetter() && c[0]!=0){
+        _stream.readRawData(c+1,1);
+        cha=QString::fromUtf8(c);
+    }
+    return cha.at(0);
 }
 
 QString UncompressedReader::readKeyword() {