5c68df933bb938f9c8da90729a955f8cacba7079
[mdictionary] / src / plugins / stardict / TranslationStarDict.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
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.
9
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.
14
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/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21 /*! \file TranslationXdxf.h
22 */
23 #ifndef TRANSLATIONSTARDICT_H
24 #define TRANSLATIONSTARDICT_H
25
26 #include <QString>
27 #include <QHash>
28 #include <QDebug>
29 #include <QTranslator>
30 #include <QCoreApplication>
31 #include <QThread>
32 #include <QSet>
33
34 #include "StarDictReaderFactory.h"
35 #include "../../include/translation.h"
36 #include "StarDictPlugin.h"
37 #include "../../include/Notify.h"
38 #include "TranslationStarDict.h"
39
40 class TranslationStarDict : public Translation
41 {
42 public:
43     TranslationStarDict();
44     TranslationStarDict(QString _key,
45                     QString _dictionaryInfo,
46                     StarDictPlugin *starDictPlugin);
47     TranslationStarDict(const TranslationStarDict &base);
48
49     //! \return word to be translated
50     QString key() const;
51
52     //! \return parsed raw format into xml
53     QString toXml() const;
54
55     /*!
56         sets the word for which we want to find a translation
57         \param word for which we want to find a translation
58     */
59     void setKey(QString);
60
61     //! sets information about dictionary
62     void setDictionaryInfo(QString);
63
64     //! \return whether given translation is taken from bookmarks
65     int isBookmark() const {
66         return _bookmark;
67    }
68
69     //! returns corresponding dict object
70     uint dict() const {return _dictHash;}
71
72     /*!
73         Add another hit in *.id(x) file
74         \param offset offset from begining of file to searched keyword
75         \param len lenght of searched keyword
76     */
77     void add(qint64 offset, qint32 len);
78
79
80
81     bool operator==(const TranslationStarDict &key) {
82         if (this->key() == key.key())
83             return true;
84         return false;
85     }
86
87 private:
88     QString _key;
89     QString _dictionaryInfo;
90     StarDictPlugin *starDictPlugin;
91     int _dictHash;
92     QVector<qint64> offsets;
93     QVector<qint32> lengths;
94 };
95
96
97 #endif // TRANSLATIONSTARDICT_H
98