1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 \file TranslationStarDict.cpp
23 \brief Implementation of stardict plugin's translation.
25 \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
28 #include "TranslationStarDict.h"
32 TranslationStarDict::TranslationStarDict():_key(""),_dictionaryInfo("") {
37 TranslationStarDict::TranslationStarDict(QString _key, QString _dictionaryInfo,
38 StarDictPlugin *starDictPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
39 this->starDictPlugin=starDictPlugin;
41 _dictHash = starDictPlugin->hash();
46 TranslationStarDict::TranslationStarDict(const TranslationStarDict &base) {
48 _dictHash = base._dictHash;
49 _dictionaryInfo = base._dictionaryInfo;
50 lengths = base.lengths;
51 offsets = base.offsets;
52 starDictPlugin = base.starDictPlugin;
56 void TranslationStarDict::add(qint64 offset, qint32 len) {
57 offsets.append(offset);
62 QString TranslationStarDict::key() const {
67 QString TranslationStarDict::toXml() const {
72 for(int i = 0; i < offsets.size(); i++) {
73 result=result + "<dict> <info path=\"/usr/share/mdictionary/stardict.png\" ";
75 result+= " bookmark=\"true\" > \n";
77 result+= " bookmark=\"false\" > \n";
78 if(_dictionaryInfo.isEmpty())
79 result+= "starDict dictionary </info>";
81 result+= _dictionaryInfo +"</info>";
83 /*conwert returned string to XML format*/
84 result+=starDictPlugin->search(_key, offsets.at(i), lengths.at(i));
91 void TranslationStarDict::setKey(QString _key) {
96 void TranslationStarDict::setDictionaryInfo(QString _dictionaryInfo) {
97 this->_dictionaryInfo=_dictionaryInfo;