stopped = false;
if(word.indexOf("*")==-1 && word.indexOf("?")== 0)
word+="%";
+ word = word.toLower();
word = word.replace("*", "%");
word = word.replace("?", "_");
word = removeAccents(word);
cur.addBindValue(limit);
cur.exec();
while(cur.next())
- translations.insert(new TranslationXdxf(cur.value(0).toString(),
- _infoNote, this));
+ translations.insert(new TranslationXdxf(
+ cur.value(0).toString().toLower(),
+ _infoNote, this));
return translations.toList();
}
QSet<Translation*> translations;
QFile dictionaryFile(path);
+ word = word.toLower();
word = removeAccents(word);
stopped = false;
ok=false; /*if key word is in the dictionary more that one */
}
if(ok) /*add key word to list*/
- translations<<(new TranslationXdxf(a,_infoNote,this));
+ translations<<(new TranslationXdxf(a.toLower(),
+ _infoNote,this));
i++;
if(i>=limit && limit!=0)
break;
QString result;
QString cacheFilePath = _settings->value("cache_path");
db.setDatabaseName(cacheFilePath);
+ key = key.toLower();
if(!db.open()) {
qDebug() << "Database error" << db.lastError().text() << endl;
QString XdxfPlugin::searchFile(QString key) {
+ key = key.toLower();
QFile dictionaryFile(path);
QString resultString("");
if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
}
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();
}
QString XdxfPlugin::removeAccents(QString string) {
-
string = string.replace(QString::fromUtf8("ł"), "l", Qt::CaseInsensitive);
QString normalized = string.normalized(QString::NormalizationForm_D);
normalized = normalized;
}
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);