+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+/*!
+ \file DownloadDict.h
+ \brief Represenation of dictionary html entry on XDXF webpage
+
+ \author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
#ifndef DOWNLOADDICT_H
#define DOWNLOADDICT_H
#include <QStringList>
#include <math.h>
+/*!
+ Each dictionary is representing as one html line at XDXF webpage,
+ each entry contains lang from, lang to, file name, file size, link, etc info
+ about dictionary. DownloadDict cut this description and then it may be
+ presented to the user and downloaded
+*/
class DownloadDict
{
public:
+
+ /*! Cuts html entry to class
+ Html entry looks like <tr><td>...</td><td>...</tr> some of the fields
+ dosn't matters for now so Iam ignoring it.
+ \param html html entry (line describing a dict) to be cut
+ */
DownloadDict(QString html) {
QRegExp reg("<td.*>(.*)</td>");
reg.setMinimal(true);
QString sizeStr = tmp.at(3);
_size = sizeStr.remove(',').toInt();
-
_size = _size / 1024 / 1024;
-
_size = round(_size*1000) / 1000;
- QRegExp lreg("href=\"(.*)\"");
+ QRegExp lreg("href=\"(.*)\""); // Cutting link to file
lreg.setMinimal(true);
lreg.indexIn(tmp.at(2));
_link = lreg.capturedTexts().at(1);
}
+ //! \return dictionary source language
QString fromLang() const {return _from;}
+
+ //! \return dictionary destination language
QString toLang() const {return _to;}
+
+ //! \return dictionary title
QString title() const {return _title;}
+
+ //! \return dictionary archive size
float size() const {return _size;}
+
+ //! \return link to dictionary archive
QString link() const {return _link;}
+ /*!
+ Compares dict by from lang then to lang
+ \return 1 if this is before other
+ */
bool operator <(DownloadDict other) const {
if(_from < other.fromLang()) return true;
if(_from > other.fromLang()) return false;