fix a bug in xdxfPlugin
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 17 Aug 2010 10:09:56 +0000 (12:09 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Tue, 17 Aug 2010 10:09:56 +0000 (12:09 +0200)
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/tests/dict.xdxf
trunk/src/plugins/xdxf/tests/test.cpp

index 85379c6..bb7929c 100644 (file)
@@ -213,11 +213,22 @@ QString XdxfPlugin::searchFile(QString key) {
         else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters) {
             if(match) {
                 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(i%2)
+                                temp+=tr("</");
+                            else
+                                temp+=tr("<");
+                            temp=temp+dictionaryReader.name().toString() + tr(">");
+                            i++;
+                        }
                         temp+=dictionaryReader.text().toString();
                     }
                 }
index d217c26..06a1952 100644 (file)
@@ -19,4 +19,6 @@ sto</ar>
 tysišc</ar>
 <ar><k>house</k>
 dom</ar>
+<ar><k>test</k>
+<opt>krowa</opt>test01</ar>
 </xdxf>
index b06adf7..f3fd301 100644 (file)
@@ -45,6 +45,8 @@ void XdxfTest::search() {
     xdxfPlugin->search("wino");
     QCOMPARE(xdxfPlugin->search("."), QString("kropka\n"));
     QCOMPARE(xdxfPlugin->search("1"), QString("one\n"));
+
+    QCOMPARE(xdxfPlugin->search("test"), QString("test1\n"));
 }
 
 void XdxfTest::searchWordList() {
@@ -56,7 +58,7 @@ void XdxfTest::searchWordList() {
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
     if(te.size()>0)
-        QCOMPARE(te.size(), 8);
+        QCOMPARE(te.size(), 9);
     QList<Translation*> te2 = xdxfPlugin->searchWordList("1",10);
     QCOMPARE(te2.size(), 5);
 
@@ -67,7 +69,7 @@ void XdxfTest::searchWordList() {
         QCOMPARE(te4.at(0)->key(), QString("house"));
 
     QList<Translation*> te5 = xdxfPlugin->searchWordList("*");
-        QCOMPARE(te5.size(), 8);
+        QCOMPARE(te5.size(), 9);
 
     QList<Translation*> te6 = xdxfPlugin->searchWordList("*", 8);
         QCOMPARE(te6.size(), 8);
@@ -103,7 +105,7 @@ void XdxfTest::stop() {
     QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
     QList<Translation*> te5 = future.result();
 
-    QCOMPARE(te5.size(), 8);
+    QCOMPARE(te5.size(), 9);
 }