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