}
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();
}
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);
CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
xdxfPlugin->search("wino");
- QCOMPARE(xdxfPlugin->search("."), QString("kropka\n"));
- QCOMPARE(xdxfPlugin->search("1"), QString("one\n"));
+ QCOMPARE(xdxfPlugin->search("."), QString("<t>kropka</t>"));
+ QCOMPARE(xdxfPlugin->search("1"), QString("<t>one</t>"));
+
+ QCOMPARE(xdxfPlugin->search("test"), QString("<t><pos>krowa</pos>test01</t>"));
}
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);
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);
QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
QList<Translation*> te5 = future.result();
- QCOMPARE(te5.size(), 8);
+ QCOMPARE(te5.size(), 9);
}