From: Bartosz Szatkowski Date: Thu, 12 Aug 2010 14:51:34 +0000 (+0200) Subject: Added word counting function in xdxf plugin X-Git-Tag: 0.4~20^2~34 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=2efa0f462d59f8b0a33ca553bd1a9c9e094010c2;p=mdictionary Added word counting function in xdxf plugin --- diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp index 8dcff29..1e753d0 100644 --- a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp +++ b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp @@ -252,18 +252,6 @@ void XdxfPlugin::getDictionaryInfo() { if(dictionaryReader.name()=="description") _infoNote=dictionaryReader.readElementText(); - /*dictionaryFile.seek(0); - - long wordsCount = 0; - - QString line; - while(!dictionaryFile.atEnd()) { - line = dictionaryFile.readLine(); - if(line.contains("")) { - wordsCount++; - } - }*/ - dictionaryFile.close(); } @@ -286,4 +274,28 @@ QIcon* XdxfPlugin::icon() { return &_icon; } +int XdxfPlugin::countWords() { + + QFile dictionaryFile(path); + if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) { + qDebug()<<"Error: could not open file"; + return -1; + } + + dictionaryFile.seek(0); + + long wordsCount = 0; + + QString line; + while(!dictionaryFile.atEnd()) { + line = dictionaryFile.readLine(); + if(line.contains("")) { + wordsCount++; + } + } + _wordsCount = wordsCount; + dictionaryFile.close(); + return wordsCount; +} + Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin) diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.h b/trunk/src/plugins/xdxf/src/xdxfplugin.h index ca1cb4a..b0722cb 100644 --- a/trunk/src/plugins/xdxf/src/xdxfplugin.h +++ b/trunk/src/plugins/xdxf/src/xdxfplugin.h @@ -114,6 +114,7 @@ private: QList searchWordListCache(QString word, int limit=0); QList searchWordListFile(QString word, int limit=0); + int countWords(); //! language from which we translate QString _langFrom;