Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-/*! \file xdxfplugin.cpp
-\author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+/*!
+ \file xdxfplugin.cpp
+ \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
*/
#include "xdxfplugin.h"
#include <QDebug>
#include "../../include/Notify.h"
#include "DownloadDict.h"
+#include "XdxfDictDownloader.h"
-XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
- _langFrom(""), _langTo(""),_name(""), _infoNote("") {
+XdxfDictDownloader XdxfPlugin::dictDownloader;
- //DownloadDict a("<tr><td><img src=\"buf/comn_sdict05_bulg_comp/icon16.png\" alt=\"icon\" /></td><td align=\"center\">English-Bulgarian computer dictionary</td><td align=\"center\"><a href=\"http://downloads.sourceforge.net/xdxf/comn_sdict05_bulg_comp.tar.bz2\" target=\"_blank\">comn_sdict05_bulg_comp.tar.bz2</a></td><td align=\"right\">13,889</td><td align=\"right\">55,094</td><td align=\"right\">523</td><td align=\"center\">English</td><td align=\"center\">Bulgarian</td><td align=\"center\"><a href=\"http://xdxf.revdanica.com/\">Common XDXF</a></td><td align=\"center\">2006-04-23 23:34:40</td></tr>");
+bool XdxfPlugin::dictDownloaderInitialized = false;
+
+XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
+ _langFrom(""), _langTo(""),_name(""), _infoNote("") {
_settings = new Settings();
_dictDialog = new XdxfDictDialog(this, this);
connect(_dictDialog, SIGNAL(notify(Notify::NotifyType,QString)),
this, SIGNAL(notify(Notify::NotifyType,QString)));
+ if(!dictDownloaderInitialized) {
+ connect(&dictDownloader, SIGNAL(notify(Notify::NotifyType,QString)),
+ this, SIGNAL(notify(Notify::NotifyType,QString)));
+ dictDownloaderInitialized = true;
+ }
_settings->setValue("type","xdxf");
_icon = QIcon("/usr/share/mdictionary/xdxf.png");
initAccents();
}
+
void XdxfPlugin::retranslate() {
QString locale = QLocale::system().name();
-
QTranslator *translator = new QTranslator(this);
if(!translator->load(":/xdxf/translations/" + locale)) {
_settings->setValue("cached","false");
return searchWordListFile(word, limit);
}
+
stopped = false;
word = word.toLower();
word = word.replace("*", "%");
if((regWord.exactMatch(readKey)
|| regWord.exactMatch(removeAccents(readKey)))
&& (i<limit || limit==0) && !reader.atEnd()) {
- // qDebug()<<readKey;
translations<<(new TranslationXdxf(readKey.toLower(),
_dictionaryInfo,this));
if(translations.size()==limit && limit!=0)
cur.exec();
while(cur.next())
result += cur.value(0).toString();
-
db.close();
return result;
-
}
void XdxfPlugin::stop() {
- //qDebug()<<"stop";
stopped=true;
}
((XdxfDictDialog*)plugin->dictDialog())->setLastDialogParent(_dictDialog->lastDialogParent());
-
-
if(settings && plugin->setSettings(settings)) {
-
disconnect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
this, SIGNAL(notify(Notify::NotifyType,QString)));
return plugin;
foreach(QString key, _settings->keys())
oldSettings->setValue(key, _settings->value(key));
- foreach(QString key, settings->keys()) {
+ foreach(QString key, settings->keys())
if(key != "generateCache")
_settings->setValue(key, settings->value(key));
- }
if(!getDictionaryInfo()) {
Q_EMIT notify(Notify::Warning,
}
dictionaryFile.seek(0);
-
long wordsCount = 0;
QString line;
bool XdxfPlugin::makeCache(QString) {
-
XdxfCachingDialog d(_dictDialog->lastDialogParent());
-// qDebug()<<_dictDialog->lastDialogParent();
-
connect(&d, SIGNAL(cancelCaching()),
this, SLOT(stop()));
connect(this, SIGNAL(updateCachingProgress(int,int)),
&d, SLOT(updateCachingProgress(int,int)));
d.show();
-
QCoreApplication::processEvents();
QFileInfo dictFileN(_settings->value("path"));
QString cachePathN;
/*add all words to db*/
while (!reader.atEnd() && !stopped) {
-
QCoreApplication::processEvents();
reader.readNext();
if(reader.tokenType() == QXmlStreamReader::StartElement) {
return true;
}
+
void XdxfPlugin::clean() {
if(QFile::exists(_settings->value("cache_path"))) {
QFile(_settings->value("cache_path")).remove();