Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.cpp
index 42312e4..807937e 100644 (file)
@@ -217,17 +217,45 @@ QString XdxfPlugin::searchFile(QString key) {
         }
         else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters) {
             if(match) {
-                QString temp(dictionaryReader.text().toString());
+ /*             QString temp(dictionaryReader.text().toString());
+                if(temp=="\n")
+                    temp=dictionaryReader.readElementText();
                 temp.replace("\n","");
                 if(temp == ""){
+                    int i=0;
                     while(dictionaryReader.name()!="ar"&&
                                 !dictionaryReader.atEnd()){
                         dictionaryReader.readNext();
+                        if(dictionaryReader.name()!="" &&
+                                         dictionaryReader.name()!="ar") {
+                            if(dictionaryReader.tokenType()==QXmlStreamReader::EndElement)
+                                temp+=tr("</");
+                            if(dictionaryReader.tokenType()==QXmlStreamReader::StartElement)
+                                temp+=tr("<");
+                            qDebug()<<dictionaryReader.tokenType();
+                            temp=temp+dictionaryReader.name().toString() + tr(">");
+                            i++;
+                        }
                         temp+=dictionaryReader.text().toString();
                     }
                 }
                 resultString+=temp.replace("\n","")+"\n";
                 match=false;
+*/
+                QString temp("");
+                while(dictionaryReader.name()!="ar" && !dictionaryReader.atEnd()) {
+                    if(dictionaryReader.name()!="") {
+                        if(dictionaryReader.tokenType()==QXmlStreamReader::EndElement)
+                            temp+=tr("</");
+                        if(dictionaryReader.tokenType()==QXmlStreamReader::StartElement)
+                            temp+=tr("<");
+                        temp=temp+dictionaryReader.name().toString() + tr(">");
+                    }
+                    temp+= dictionaryReader.text().toString();
+                    dictionaryReader.readNext();
+                }
+                resultString+=tr("<t>") + temp.replace("\n","") + tr("</t>");
+                match=false;
             }
         }
         this->thread()->yieldCurrentThread();
@@ -448,15 +476,19 @@ bool XdxfPlugin::makeCache(QString dir) {
         }
         else if(reader.tokenType() == QXmlStreamReader::Characters) {
              if(match) {
-                QString temp(reader.text().toString());
-                temp.replace("\n","");
-                if(temp == ""){
-                    while(reader.name()!="ar"&&
-                                !reader.atEnd()){
-                        reader.readNext();
-                        temp+=reader.text().toString();
+                QString temp("");
+                while(reader.name()!="ar" && !reader.atEnd()) {
+                    if(reader.name()!="") {
+                        if(reader.tokenType()==QXmlStreamReader::EndElement)
+                            temp+=tr("</");
+                        if(reader.tokenType()==QXmlStreamReader::StartElement)
+                            temp+=tr("<");
+                        temp=temp+reader.name().toString() + tr(">");
                     }
+                    temp+= reader.text().toString();
+                    reader.readNext();
                 }
+                temp=tr("<t>") + temp.replace("\n","") + tr("</t>");
                 match = false;
                 cur.prepare("insert into dict values(?,?)");
                 cur.addBindValue(a);