Added spliting html from xdxf downlowad page to fields describing dicts
[mdictionary] / src / plugins / xdxf / DownloadDict.h
1 #ifndef DOWNLOADDICT_H
2 #define DOWNLOADDICT_H
3
4 #include <QRegExp>
5
6 class DownloadDict
7 {
8 public:
9     DownloadDict(QString html);
10     QString fromLang() {return _from;};
11     QString toLang() {return _to;};
12     QString title() {return _title;}
13     QString size() {return _size;}
14     QString link() {return _link;}
15
16 private:
17     QString _from, _to, _title, _link, _size;
18 };
19
20
21 DownloadDict::DownloadDict(QString html) {
22     QRegExp reg("<td.*>(.*)</td>");
23     reg.setMinimal(true);
24     int pos = 0;
25     QStringList tmp;
26     while ((pos = reg.indexIn(html, pos)) != -1) {
27         tmp << reg.cap(1);
28         pos += reg.matchedLength();
29     }
30     _from = tmp.at(6);
31     _to = tmp.at(7);
32     _title = tmp.at(1);
33     _size = tmp.at(3);
34     QRegExp lreg("href=\"(.*)\"");
35     lreg.setMinimal(true);
36     lreg.indexIn(tmp.at(2));
37     _link = lreg.capturedTexts().at(1);
38
39
40 }
41
42 #endif // DOWNLOADDICT_H