X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fstardict%2FStarDictPlugin.cpp;h=f30dbc8f7d23d0c8add8caa0d35380ea9a2fbdff;hb=f86f31535d8c34e40a83e5a722b06a5a490af0da;hp=b12f8437d15250d7d08011445b44edebb8f1e4f7;hpb=f6932a2fbe05f2aa7a91c938479424bb7d87dc18;p=mdictionary diff --git a/src/plugins/stardict/StarDictPlugin.cpp b/src/plugins/stardict/StarDictPlugin.cpp index b12f843..f30dbc8 100644 --- a/src/plugins/stardict/StarDictPlugin.cpp +++ b/src/plugins/stardict/StarDictPlugin.cpp @@ -24,7 +24,7 @@ #include "StarDictPlugin.h" - +/**/ uint qHash(const TranslationStarDict &key) { return qHash(key.key()); } @@ -40,7 +40,6 @@ StarDictPlugin::StarDictPlugin(QObject *parent) : CommonDictInterface(parent), _settings->setValue("type","stardict"); _icon = QIcon("/usr/share/mdictionary/stardict.png"); - _wordsCount = -1; stopped = false; initAccents(); @@ -106,10 +105,10 @@ QList StarDictPlugin::searchWordList(QString word, int limit) { word.indexOf("_")==-1 && word.indexOf("%")==-1) word+="*"; - if((settings()->value("idxoffsetbits") == "32") || (settings()->value("idxoffsetbits") == "")) is32b = true; + if(!err) return QList(); @@ -150,10 +149,6 @@ QByteArray StarDictPlugin::read(QByteArray::iterator it, 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++) @@ -166,19 +161,22 @@ QString StarDictPlugin::interpret(QByteArray::iterator it, QByteArray::iterator end, QChar mode,QString key, bool last) { QString result; qDebug()<<"****** mode: "<"; - 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 + ""; - result += QString::fromUtf8(read(it++, end)); + result += "" + QString::fromUtf8(read(it++, end)) + ""; } - else if(mode == 'g'){ - result += "" + 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(""); while(indexOfSmall!=-1){ int indexOfEndSmall= result.indexOf(""); @@ -187,11 +185,7 @@ QString StarDictPlugin::interpret(QByteArray::iterator it, indexOfSmall=result.indexOf(""); } } - else if(mode == 't'){ - result += "" + key + ""; - result += QString::fromUtf8(read(it++, end)); - } - else if(mode == 'x'){ + if(mode == 'x'){ result += QString::fromUtf8(read(it++, end)); result.replace("",""); result.replace("",""); @@ -201,27 +195,6 @@ QString StarDictPlugin::interpret(QByteArray::iterator it, if(result.contains("")) result+=""; } - else if(mode == 'y') { - result += "" + key + ""; - result += QString::fromUtf8(read(it++, end)); - } - else if(mode == 'k'){ - result += "" + key + ""; - result += QString::fromUtf8(read(it++, end)); - } - else if(mode == 'w'){ - result += "" + key + ""; - result += QString::fromUtf8(read(it++, end)); - } - else if(mode == 'h'){ - result += "" + key + ""; - result += QString::fromUtf8(read(it++, end)); - } - else if(mode == 'r'){ - result += "" + 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) @@ -273,7 +246,6 @@ QString StarDictPlugin::format(QByteArray raw, QString mode,QString key) { } - QString StarDictPlugin::search(QString key, qint64 offset, qint32 len) { QString dictPath = settings()->value("dictFileName"); StarDictReader *reader = StarDictReaderFactory::createReader(dictPath); @@ -329,11 +301,6 @@ Settings* StarDictPlugin::settings() { } -bool StarDictPlugin::isCached() { - return false; -} - - bool StarDictPlugin::setSettings(const Settings *sett) { if(sett) { foreach(QString key, sett->keys()) @@ -378,7 +345,6 @@ int StarDictPlugin::countWords() { } - void StarDictPlugin::clean() { }