XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
_langFrom(tr("")), _langTo(tr("")),_name(tr("")),
- _type("xdxf"), _infoNote(tr("")) {
+ _type(tr("xdxf")), _infoNote(tr("")) {
_wordsCount = -1;
_settings = new Settings();
_dictDialog = new XdxfDictDialog(this);
- cachingDialog = new XdxfCachingDialog();
+ cachingDialog = new XdxfCachingDialog(this);
+
connect(cachingDialog, SIGNAL(cancelCaching()),
this, SLOT(stop()));
-
connect(this, SIGNAL(updateCachingProgress(int,int)),
cachingDialog, SLOT(updateCachingProgress(int,int)));
}
-
XdxfPlugin::~XdxfPlugin() {
delete _settings;
+ delete cachingDialog;
}
-
QString XdxfPlugin::langFrom() const {
return _langFrom;
}
QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
QTime time;
- time.start();
QSet<Translation*> translations;
QFile dictionaryFile(path);
}
stopped=false;
dictionaryFile.close();
- qDebug() << time.elapsed();
return translations.toList();
}
}
void XdxfPlugin::setPath(QString path){
+ if(this->path!=path && this->path!="" && _settings->value("cache_path")!="");
+ clean();
this->path=path;
_settings->setValue("path",path);
//getDictionaryInfo();
void XdxfPlugin::setSettings(Settings *settings) {
+ if(settings)
+ {
+ QString oldPath = _settings->value("path");
+ if(oldPath != settings->value("path")) {
+ setPath(settings->value("path"));
+ }
- QString oldPath = _settings->value("path");
- if(oldPath != settings->value("path")) {
- setPath(settings->value("path"));
- }
+ foreach(QString key, settings->keys())
+ if(key != "generateCache")
+ _settings->setValue(key, settings->value(key));
- foreach(QString key, settings->keys())
- if(key != "generateCache")
- _settings->setValue(key, settings->value(key));
+ if((_settings->value("cached") == "false" ||
+ _settings->value("cached").isEmpty()) &&
+ settings->value("generateCache") == "true") {
+ makeCache("");
+ }
+ else if (settings->value("generateCache") != "true") {
+ _settings->setValue("cached", "false");
+ }
- if((_settings->value("cached") == "false" ||
- _settings->value("cached").isEmpty()) &&
- settings->value("generateCache") == "true") {
- makeCache("");
- }
- else if (settings->value("generateCache") != "true") {
- _settings->setValue("cached", "false");
+ getDictionaryInfo();
+ delete settings;
}
-
-
- delete settings;
-
Q_EMIT settingsChanged();
}
return wordsCount;
}
-bool XdxfPlugin::makeCache(QString dir) {
+bool XdxfPlugin::makeCache(QString) {
cachingDialog->setVisible(true);
QCoreApplication::processEvents();
stopped = false;
QFile dictionaryFile(dictFileN.filePath());
-
if (!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
Q_EMIT updateCachingProgress(100, 0);
Q_EMIT notify(Notify::Warning,
return true;
}
+
+
+void XdxfPlugin::clean() {
+ if(settings()->value("cached") == "true")
+ QFile(settings()->value("cache_path")).remove();
+}
+
Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)