*******************************************************************************/
-/*! \file DownloadDict.h
-\brief Represenation of dictionary html entry on XDXF webpage
+/*!
+ \file DownloadDict.h
+ \brief Represenation of dictionary html entry on XDXF webpage
-\author Bartosz Szatkowski <bulislaw@linux.com>
+ \author Bartosz Szatkowski <bulislaw@linux.com>
*/
#ifndef DOWNLOADDICT_H
#include <QRegExp>
#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
{
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
+ /*! 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>");
_from = tmp.at(6);
_to = tmp.at(7);
_title = tmp.at(1);
- _size = tmp.at(3);
+ QString sizeStr = tmp.at(3);
+
+ _size = sizeStr.remove(',').toInt();
+ _size = _size / 1024 / 1024;
+ _size = round(_size*1000) / 1000;
QRegExp lreg("href=\"(.*)\""); // Cutting link to file
lreg.setMinimal(true);
//! \return dictionary title
QString title() const {return _title;}
-
+
//! \return dictionary archive size
- QString size() const {return _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
+ /*!
+ 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;
}
private:
- QString _from, _to, _title, _link, _size;
+ QString _from, _to, _title, _link;
+ float _size;
};