From d97189e07820bcf10b23704b404618f029706912 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mateusz=20P=C3=B3=C5=82rola?= Date: Tue, 28 Sep 2010 11:07:11 +0200 Subject: [PATCH] Added downloading of html site with dicts --- src/plugins/xdxf/DownloadDict.h | 45 +++++++++++++++---------------- src/plugins/xdxf/XdxfDictDownloader.cpp | 19 +++++++++++-- src/plugins/xdxf/XdxfDictDownloader.h | 8 ++++++ 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/plugins/xdxf/DownloadDict.h b/src/plugins/xdxf/DownloadDict.h index dfe708a..4442501 100644 --- a/src/plugins/xdxf/DownloadDict.h +++ b/src/plugins/xdxf/DownloadDict.h @@ -6,9 +6,27 @@ class DownloadDict { public: - DownloadDict(QString html); - QString fromLang() {return _from;}; - QString toLang() {return _to;}; + DownloadDict(QString html) { + QRegExp reg("(.*)"); + 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;} @@ -18,25 +36,4 @@ private: }; -DownloadDict::DownloadDict(QString html) { - QRegExp reg("(.*)"); - 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 diff --git a/src/plugins/xdxf/XdxfDictDownloader.cpp b/src/plugins/xdxf/XdxfDictDownloader.cpp index e0e99ba..b7acba9 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.cpp +++ b/src/plugins/xdxf/XdxfDictDownloader.cpp @@ -24,6 +24,7 @@ #include "XdxfDictDownloader.h" #include "XdxfDictDownloadProgressDialog.h" + XdxfDictDownloader::XdxfDictDownloader(QObject *parent) : QObject(parent) { @@ -31,6 +32,20 @@ XdxfDictDownloader::XdxfDictDownloader(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) { + } diff --git a/src/plugins/xdxf/XdxfDictDownloader.h b/src/plugins/xdxf/XdxfDictDownloader.h index da82b23..ca88865 100644 --- a/src/plugins/xdxf/XdxfDictDownloader.h +++ b/src/plugins/xdxf/XdxfDictDownloader.h @@ -27,6 +27,9 @@ #include #include "XdxfDictSelectDialog.h" #include +#include +#include +#include class XdxfDictDownloader : public QObject { @@ -37,6 +40,11 @@ public: public Q_SLOTS: void download(QWidget* parent); +private Q_SLOTS: + void dictListReceived(QNetworkReply*); + +private: + QList dicts; }; -- 1.7.9.5