class DownloadDict
{
public:
- DownloadDict(QString html);
- QString fromLang() {return _from;};
- QString toLang() {return _to;};
+ DownloadDict(QString html) {
+ QRegExp reg("<td.*>(.*)</td>");
+ reg.setMinimal(true);
+ int pos = 0;
+ QStringList tmp;
+ while ((pos = reg.indexIn(html, pos)) != -1) {
+ tmp << reg.cap(1);
+ pos += reg.matchedLength();
+ }
+ _from = tmp.at(6);
+ _to = tmp.at(7);
+ _title = tmp.at(1);
+ _size = tmp.at(3);
+ QRegExp lreg("href=\"(.*)\"");
+ lreg.setMinimal(true);
+ lreg.indexIn(tmp.at(2));
+ _link = lreg.capturedTexts().at(1);
+ }
+
+ QString fromLang() {return _from;}
+ QString toLang() {return _to;}
QString title() {return _title;}
QString size() {return _size;}
QString link() {return _link;}
};
-DownloadDict::DownloadDict(QString html) {
- QRegExp reg("<td.*>(.*)</td>");
- reg.setMinimal(true);
- int pos = 0;
- QStringList tmp;
- while ((pos = reg.indexIn(html, pos)) != -1) {
- tmp << reg.cap(1);
- pos += reg.matchedLength();
- }
- _from = tmp.at(6);
- _to = tmp.at(7);
- _title = tmp.at(1);
- _size = tmp.at(3);
- QRegExp lreg("href=\"(.*)\"");
- lreg.setMinimal(true);
- lreg.indexIn(tmp.at(2));
- _link = lreg.capturedTexts().at(1);
-
-
-}
-
#endif // DOWNLOADDICT_H
#include "XdxfDictDownloader.h"
#include "XdxfDictDownloadProgressDialog.h"
+
XdxfDictDownloader::XdxfDictDownloader(QObject *parent) :
QObject(parent)
{
void XdxfDictDownloader::download(QWidget *parent) {
- XdxfDictDownloadProgressDialog progress(parent);
- //XdxfDictSelectDialog selectDialog(parent);
+
+ QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+
+ connect(manager, SIGNAL(finished(QNetworkReply*)),
+ this, SLOT(dictListReceived(QNetworkReply*)));
+
+ manager->get(QNetworkRequest(QUrl("http://xdxf.revdanica.com/down/")));
+
+ XdxfDictSelectDialog selectDialog(parent);
+
+ selectDialog.exec();
+}
+
+
+void XdxfDictDownloader::dictListReceived(QNetworkReply *reply) {
+
}
#include <QObject>
#include "XdxfDictSelectDialog.h"
#include <QTimer>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <DownloadDict.h>
class XdxfDictDownloader : public QObject
{
public Q_SLOTS:
void download(QWidget* parent);
+private Q_SLOTS:
+ void dictListReceived(QNetworkReply*);
+
+private:
+ QList<DownloadDict> dicts;
};