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 \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
26 #include "TranslationStarDict.h"
30 TranslationStarDict::TranslationStarDict():_key(""),_dictionaryInfo("") {
35 TranslationStarDict::TranslationStarDict(QString _key, QString _dictionaryInfo,
36 StarDictPlugin *starDictPlugin): _key(_key),_dictionaryInfo(_dictionaryInfo) {
37 this->starDictPlugin=starDictPlugin;
39 _dictHash = starDictPlugin->hash();
44 TranslationStarDict::TranslationStarDict(const TranslationStarDict &base) {
46 _dictHash = base._dictHash;
47 _dictionaryInfo = base._dictionaryInfo;
48 lengths = base.lengths;
49 offsets = base.offsets;
50 starDictPlugin = base.starDictPlugin;
54 void TranslationStarDict::add(qint64 offset, qint32 len) {
55 offsets.append(offset);
60 QString TranslationStarDict::key() const {
65 QString TranslationStarDict::toXml() const {
70 for(int i = 0; i < offsets.size(); i++) {
71 result=result + "<dict> <info path=\"/usr/share/mdictionary/stardict.png\" ";
73 result+= " bookmark=\"true\" > \n";
75 result+= " bookmark=\"false\" > \n";
76 if(_dictionaryInfo.isEmpty())
77 result+= "starDict dictionary </info>";
79 result+= _dictionaryInfo +"</info>";
81 /*conwert returned string to XML format*/
82 result+=starDictPlugin->search(_key, offsets.at(i), lengths.at(i));
89 void TranslationStarDict::setKey(QString _key) {
94 void TranslationStarDict::setDictionaryInfo(QString _dictionaryInfo) {
95 this->_dictionaryInfo=_dictionaryInfo;