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 DownloadDict.h
23 \brief Represenation of dictionary html entry on XDXF webpage
25 \author Bartosz Szatkowski <bulislaw@linux.com>
28 #ifndef DOWNLOADDICT_H
29 #define DOWNLOADDICT_H
32 #include <QStringList>
35 Each dictionary is representing as one html line at XDXF webpage,
36 each entry contains lang from, lang to, file name, file size, link, etc info
37 about dictionary. DownloadDict cut this description and then it may be
38 presented to the user and downloaded
44 /** Cuts html entry to class
46 Html entry looks like <tr><td>...</td><td>...</tr> some of the fields
47 dosn't matters for now so Iam ignoring it.
49 \param html html entry (line describing a dict) to be cut
51 DownloadDict(QString html) {
52 QRegExp reg("<td.*>(.*)</td>");
56 while ((pos = reg.indexIn(html, pos)) != -1) {
58 pos += reg.matchedLength();
65 QRegExp lreg("href=\"(.*)\""); // Cutting link to file
66 lreg.setMinimal(true);
67 lreg.indexIn(tmp.at(2));
68 _link = lreg.capturedTexts().at(1);
71 //! \return dictionary source language
72 QString fromLang() const {return _from;}
74 //! \return dictionary destination language
75 QString toLang() const {return _to;}
77 //! \return dictionary title
78 QString title() const {return _title;}
80 //! \return dictionary archive size
81 QString size() const {return _size;}
83 //! \return link to dictionary archive
84 QString link() const {return _link;}
86 //! Compares dict by from lang then to lang \return 1 if this is before other
87 bool operator <(DownloadDict other) const {
88 if(_from < other.fromLang()) return true;
89 if(_from > other.fromLang()) return false;
90 if(_to < other.toLang()) return true;
95 QString _from, _to, _title, _link, _size;
99 #endif // DOWNLOADDICT_H