detect a disconect error in GooglePlugin
[mdictionary] / trunk / src / plugins / xdxf / src / TranslationXdxf.cpp
index 0c3fcfb..b220398 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
+/*! \file TranslationXdxf.cpp
+    \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
+*/
 
-#include "TranslationXdxf.h"
 
+#include "TranslationXdxf.h"
+#include <QDebug>
 
-TranslationXdxf::TranslationXdxf() {
+TranslationXdxf::TranslationXdxf():_key(""),_dictionaryInfo("") {
+    xdxfPlugin=0;
 }
 
-TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo, XdxfPlugin *xdxfPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
+TranslationXdxf::TranslationXdxf(QString _key, QString _dictionaryInfo,
+         XdxfPlugin *xdxfPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
     this->xdxfPlugin=xdxfPlugin;
+    if(xdxfPlugin)
+        _dictHash = xdxfPlugin->hash();
+    _bookmark=0;
 }
 
 QString TranslationXdxf::key() const {
@@ -37,8 +46,17 @@ QString TranslationXdxf::dictionaryInfo() const {
     return _dictionaryInfo;
 }
 
-QString TranslationXdxf::toHtml() const {
-    return xdxfPlugin->search(_key);
+QString TranslationXdxf::toHtml() const { 
+    QString result("");
+    if(!xdxfPlugin)
+        return result;
+    result=result + "<dict>" + "<info";
+    if(isBookmark())
+        result+= " bookmark=\"true\" ";
+    else
+        result+= " bookmark=\"false\" ";
+    result+= _dictionaryInfo + "</info>" + xdxfPlugin->search(_key) + "</dict>";
+    return result.replace("&","&amp;");
 }
 
 void TranslationXdxf::setKey(QString _key) {