code clean
[mdictionary] / src / plugins / stardict / StarDictPlugin.cpp
index f30dbc8..a6b3c9f 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
+/*!
+     \file StarDictPlugin.cpp
+     \brief Implementation of stardict plugin's main class.
 
-/*! \file stardictplugin.cpp
+     \author Jakub Jaszczynski
 */
 
 #include "StarDictPlugin.h"
@@ -39,10 +42,14 @@ StarDictPlugin::StarDictPlugin(QObject *parent) : CommonDictInterface(parent),
             this, SIGNAL(notify(Notify::NotifyType,QString)));
 
     _settings->setValue("type","stardict");
-    _icon = QIcon("/usr/share/mdictionary/stardict.png");
+    _iconPath = "/usr/share/mdictionary/stardict.png";
+    _icon = QIcon(_iconPath);
     stopped = false;
 
+    _settings->setValue("strip_accents","true");
+
     initAccents();
+
 }
 
 
@@ -51,7 +58,7 @@ void StarDictPlugin::retranslate() {
     QTranslator *translator = new QTranslator(this);
 
     if(!translator->load(":/stardict/translations/" + locale)) {
-        translator->load(":/stardicts/translations/en_US");
+        translator->load(":/stardict/translations/en_US");
     }
     QCoreApplication::installTranslator(translator);
 }
@@ -98,12 +105,13 @@ QList<Translation*> StarDictPlugin::searchWordList(QString word, int limit) {
     QString idxPath = settings()->value("idxFileName");
     StarDictReader * reader = StarDictReaderFactory::createReader(idxPath);
     QString fkey;
-    qint64 offset = 0, len = 0;
-    QRegExp keyword(word, Qt::CaseInsensitive, QRegExp::Wildcard);
+    qint64 offset = 0,
+    len = 0;
 
     if( word.indexOf("*")==-1 && word.indexOf("?")==-1 &&
         word.indexOf("_")==-1 && word.indexOf("%")==-1)
         word+="*";
+    QRegExp keyword(word, Qt::CaseInsensitive, QRegExp::Wildcard);
 
     if((settings()->value("idxoffsetbits") == "32") ||
                          (settings()->value("idxoffsetbits") == ""))
@@ -122,9 +130,8 @@ QList<Translation*> StarDictPlugin::searchWordList(QString word, int limit) {
             offset = reader->readInt64BigEndian();
         len = reader->readInt32BigEndian();
 
-        if(keyword.exactMatch(fkey)) {
+        if(keyword.exactMatch(fkey) ) {
             TranslationStarDict tran(fkey, infoNote(), this);
-            qDebug() << "off/len" << offset << len;
             int id = translations.indexOf(tran);
             if(id == -1) {
                 tran.add(offset, len);
@@ -158,19 +165,17 @@ QByteArray StarDictPlugin::read(QByteArray::iterator it,
 
 
 QString StarDictPlugin::interpret(QByteArray::iterator it,
-        QByteArray::iterator end, QChar mode,QString key, bool last) {
+        QByteArray::iterator end, QChar mode,QString key, bool) {
     QString result;
-    qDebug()<<"****** mode:     "<<mode;
-
-    if(mode == 'm' ||
-            mode == 'l' ||
-            mode == 'g' ||
-            mode == 't' ||
-            mode == 'y' ||
-            mode == 'k' ||
-            mode == 'w' ||
-            mode == 'h' ||
-            mode == 'r' ){
+    if(mode == 'm'
+            || mode == 'l'
+            || mode == 'g'
+            || mode == 't'
+            || mode == 'y'
+            || mode == 'k'
+            || mode == 'w'
+            || mode == 'h'
+            || mode == 'r'){
         result += "<key>" + key + "</key>";
         result += "<t>" + QString::fromUtf8(read(it++, end)) + "</t>";
     }
@@ -196,7 +201,7 @@ QString StarDictPlugin::interpret(QByteArray::iterator it,
             result+="</t>";
     }
 
-// Dont know whether mDictionary would ever handle binary stardict format
+// W & P 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)
  /*
     }
@@ -223,8 +228,6 @@ QString StarDictPlugin::interpret(QByteArray::iterator it,
         } else
             result += read(it++, end);
     } */
-
-    qDebug()<<"wynik  "<<result;
     return result;
 }
 
@@ -339,15 +342,8 @@ QIcon* StarDictPlugin::icon() {
     return &_icon;
 }
 
-
-int StarDictPlugin::countWords() {
-    return 0;
+QString StarDictPlugin::iconPath(){
+    return _iconPath;
 }
 
-
-void StarDictPlugin::clean() {
-
-}
-
-
 Q_EXPORT_PLUGIN2(stardict, StarDictPlugin)