add information about bookmark to translation (in toHtml())
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.cpp
index 49f9bf6..ae3549e 100644 (file)
 
 #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("")),
@@ -50,9 +45,11 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
 
 XdxfPlugin::~XdxfPlugin()
 {
-    qDebug()<<"/n /n destruktor";
-    if(!db.connectionName().isEmpty())
-        db.removeDatabase(_type+path);
+//  QString connection(db.connectionName());
+//   db.close();
+//  QSqlDatabase::removeDatabase(connection);
+
+    delete _settings;
 }
 
 QString XdxfPlugin::langFrom() const {   
@@ -125,7 +122,7 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
                         _infoNote, this));
         }
         db.close();
-       return translations.toList();
+    return translations.toList();
 }
 
 QList<Translation*> XdxfPlugin::searchWordListFile(QString word, int limit) {
@@ -201,7 +198,9 @@ QString XdxfPlugin::searchCache(QString key) {
     cur.exec();
     while(cur.next())
         result += cur.value(0).toString();
+
     db.close();
+
     return result;
 
 }
@@ -211,13 +210,10 @@ QString XdxfPlugin::searchFile(QString key) {
     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;
@@ -286,9 +282,8 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
 
         a=a+1;
         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") {
@@ -371,9 +366,7 @@ void XdxfPlugin::getDictionaryInfo() {
 //  qDebug()<<QPixmap(test).save(initialPath,format.toAscii());
 //  qDebug()<<QPixmap("/home/jakub/star.jpg").save(initialPath,format.toAscii());
 
-    _infoNote="<info path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")"  + "</info>";
-
-
+    _infoNote="path=\""+initialPath+"\">"+"\n" + _name + " [" + _langFrom + "-" + _langTo + "] "+ "(" + _type + ")";
 
     dictionaryFile.close();
 }
@@ -527,6 +520,7 @@ bool XdxfPlugin::makeCache(QString dir) {
     _settings->setValue("cache_path", cachePathN);
     _settings->setValue("cached", "true");
 
+
     db.close();
     return true;
 }