*******************************************************************************/
+/*! \file xdxfplugin.cpp
+*/
+
#include "xdxfplugin.h"
#include <QDebug>
-#include <QFile>
-#include <QXmlStreamReader>
-#include <QtPlugin>
-#include "TranslationXdxf.h"
-#include "../../../includes/settings.h"
XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
_langFrom(tr("")), _langTo(tr("")),_name(tr("")),
_icon = QIcon(":/icons/xdxf.png");
}
+XdxfPlugin::~XdxfPlugin()
+{
+// QString connection(db.connectionName());
+// db.close();
+// QSqlDatabase::removeDatabase(connection);
+
+ delete _settings;
+}
+
QString XdxfPlugin::langFrom() const {
return _langFrom;
}
_infoNote, this));
}
db.close();
- return translations.toList();
+ return translations.toList();
}
QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
}
QSqlQuery cur(db);
-// cur.prepare("select translation from dict where word like ? limit 1");
cur.prepare("select translation from dict where word like ?");
cur.addBindValue(key);
cur.exec();
-// if(cur.next())
while(cur.next())
-// result = cur.value(0).toString();
result += cur.value(0).toString();
+
db.close();
+
return result;
}
QFile dictionaryFile(path);
QString resultString("");
if(!dictionaryFile.open(QFile::ReadOnly | QFile::Text)) {
- qDebug()<<"Error: could not open file";
+ qDebug()<<"Error: could not open file when search";
return "";
}
QXmlStreamReader reader(&dictionaryFile);
-
-
-
QString a;
bool match =false;
}
if(temp.at(0)==QChar('\n'))
temp.remove(0,1);
- resultString+=tr("<t>") + temp + tr("</t>"); //.replace("\n","")
+ resultString+=tr("<key>") + a +tr("</key>");
+ resultString+=tr("<t>") + temp + tr("</t>");
match=false;
}
this->thread()->yieldCurrentThread();
XdxfPlugin *plugin = new XdxfPlugin();
if(settings){
plugin->setPath(settings->value("path"));
-
QStringList list = settings->keys();
foreach(QString key, list)
plugin->settings()->setValue(key, settings->value(key));
-
plugin->db_name = plugin->_settings->value("type")
- + plugin->_settings->value("path");
- // if(!plugin->db.connectionName().isEmpty() || settings->value("generateCache")=="true")
- plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);
+ + plugin->_settings->value("path");
+ plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);
if(settings->value("cached").isEmpty() &&
settings->value("generateCache") == "true") {
plugin->makeCache("");
}
+ delete settings;
}
-
plugin->getDictionaryInfo();
return plugin;
}
else {
_settings->setValue("cached", "false");
}
+ delete settings;
emit settingsChanged();
}
QString format = "png";
QString initialPath = QDir::currentPath() + tr("/xdxf.") + format;
-// qDebug()<<initialPath;
-// qDebug()<<QPixmap(":/icons/xdxf.png").save(initialPath,format.toAscii());
-
- _infoNote="<info path=\""+initialPath+"\">"+"\n" + _name + "(" + _type + ")" + "</info>";
-
+// qDebug()<<initialPath;
+// QPixmap test(":/icons/xdxf.png");
+// qDebug()<<QPixmap(test).save(initialPath,format.toAscii());
+// qDebug()<<QPixmap("/home/jakub/star.jpg").save(initialPath,format.toAscii());
+ _infoNote="path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")";
dictionaryFile.close();
}
}
if(temp.at(0)==QChar('\n'))
temp.remove(0,1);
- temp=tr("<t>") + temp+ tr("</t>"); //.replace("\n","")
+ temp=tr("<key>") + a + tr("</key>") + tr("<t>") + temp+ tr("</t>");
match=false;
cur.prepare("insert into dict values(?,?)");
cur.addBindValue(a);
_settings->setValue("cache_path", cachePathN);
_settings->setValue("cached", "true");
+
db.close();
return true;
}