#include "StarDictPlugin.h"
-
+/**/
uint qHash(const TranslationStarDict &key) {
return qHash(key.key());
}
_settings->setValue("type","stardict");
_icon = QIcon("/usr/share/mdictionary/stardict.png");
- _wordsCount = -1;
stopped = false;
initAccents();
word.indexOf("_")==-1 && word.indexOf("%")==-1)
word+="*";
-
if((settings()->value("idxoffsetbits") == "32") ||
(settings()->value("idxoffsetbits") == ""))
is32b = true;
+
if(!err)
return QList<Translation*>();
if(bytes == 0 && it != end){
while(*it != '\0' && it != end)
ret.append(*it++);
- if(it == end)
- qDebug()<<"end";
- else
- qDebug()<<"000";
}
else
for(int i = 0; i < bytes && it != end; i++)
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));
- }
- else if(mode == 'l'){
+
+ if(mode == 'm' ||
+ mode == 'l' ||
+ mode == 'g' ||
+ mode == 't' ||
+ mode == 'y' ||
+ mode == 'k' ||
+ mode == 'w' ||
+ mode == 'h' ||
+ mode == 'r' ){
result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
+ result += "<t>" + QString::fromUtf8(read(it++, end)) + "</t>";
}
- else if(mode == 'g'){
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- /* delete "small" tag from translation*/
+ if(mode == 'g'){
+ /* delete "small" tag from g translation*/
int indexOfSmall=result.indexOf("<small>");
while(indexOfSmall!=-1){
int indexOfEndSmall= result.indexOf("</small>");
indexOfSmall=result.indexOf("<small>");
}
}
- else if(mode == 't'){
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- }
- else if(mode == 'x'){
+ if(mode == 'x'){
result += QString::fromUtf8(read(it++, end));
result.replace("</k>","</key><t>");
result.replace("<k>","</t><key>");
if(result.contains("<t>"))
result+="</t>";
}
- else if(mode == 'y') {
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- }
- else if(mode == 'k'){
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- }
- else if(mode == 'w'){
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- }
- else if(mode == 'h'){
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- }
- else if(mode == 'r'){
- result += "<key>" + key + "</key>";
- result += QString::fromUtf8(read(it++, end));
- }
-
// Dont know whether mDictionary would ever handle binary stardict format
// to be honest dont see any kind of adventages (can't find any binary dict)
}
-
QString StarDictPlugin::search(QString key, qint64 offset, qint32 len) {
QString dictPath = settings()->value("dictFileName");
StarDictReader *reader = StarDictReaderFactory::createReader(dictPath);
}
-bool StarDictPlugin::isCached() {
- return false;
-}
-
-
bool StarDictPlugin::setSettings(const Settings *sett) {
if(sett) {
foreach(QString key, sett->keys())
}
-
void StarDictPlugin::clean() {
}