From: Bartosz Szatkowski Date: Tue, 28 Sep 2010 08:40:51 +0000 (+0200) Subject: Added spliting html from xdxf downlowad page to fields describing dicts X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=106a69ed4e065bd672bef885f558bf86d629e0e2;p=mdictionary Added spliting html from xdxf downlowad page to fields describing dicts --- diff --git a/src/plugins/xdxf/DownloadDict.h b/src/plugins/xdxf/DownloadDict.h new file mode 100644 index 0000000..dfe708a --- /dev/null +++ b/src/plugins/xdxf/DownloadDict.h @@ -0,0 +1,42 @@ +#ifndef DOWNLOADDICT_H +#define DOWNLOADDICT_H + +#include + +class DownloadDict +{ +public: + DownloadDict(QString html); + QString fromLang() {return _from;}; + QString toLang() {return _to;}; + QString title() {return _title;} + QString size() {return _size;} + QString link() {return _link;} + +private: + QString _from, _to, _title, _link, _size; +}; + + +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/xdxf.pro b/src/plugins/xdxf/xdxf.pro index ef29877..025ed82 100644 --- a/src/plugins/xdxf/xdxf.pro +++ b/src/plugins/xdxf/xdxf.pro @@ -1,24 +1,16 @@ TARGET = xdxf - include(../plugin.pri) - QT = core \ gui \ xml \ sql - maemo5:QT += maemo5 - -SOURCES += \ - xdxfplugin.cpp \ +SOURCES += xdxfplugin.cpp \ TranslationXdxf.cpp \ XdxfDictDialog.cpp \ XdxfCachingDialog.cpp \ XdxfDialog.cpp - - -HEADERS += \ - xdxfplugin.h \ +HEADERS += xdxfplugin.h \ TranslationXdxf.h \ ../../include/DictDialog.h \ XdxfDictDialog.h \ @@ -26,24 +18,21 @@ HEADERS += \ ../../include/settings.h \ ../../include/CommonDictInterface.h \ XdxfCachingDialog.h \ - XdxfDialog.h - -RESOURCES += \ - xdxf.qrc - + XdxfDialog.h \ + ../DownloadDict.h \ + DownloadDict.h +RESOURCES += xdxf.qrc TRANSLATIONS += pl_PL.ts \ - en_US.ts - -unix { - INSTALLS += dicts plugin-icon - - dicts.path = $$PLUGINS_DIR - dicts.files += ../../../data/dicts/eng-us.xdxf - dicts.files += ../../../data/dicts/eng-thai.xdxf - - plugin-icon.path = $$DATA_DIR - plugin-icon.files += xdxf.png + en_US.ts +unix { + INSTALLS += dicts \ + plugin-icon + dicts.path = $$PLUGINS_DIR + dicts.files += ../../../data/dicts/eng-us.xdxf + dicts.files += ../../../data/dicts/eng-thai.xdxf + plugin-icon.path = $$DATA_DIR + plugin-icon.files += xdxf.png } - -check.commands = echo 'No check here' +check.commands = echo \ + 'No check here' QMAKE_EXTRA_TARGETS += check diff --git a/src/plugins/xdxf/xdxfplugin.cpp b/src/plugins/xdxf/xdxfplugin.cpp index ee8ee03..a0f49f0 100644 --- a/src/plugins/xdxf/xdxfplugin.cpp +++ b/src/plugins/xdxf/xdxfplugin.cpp @@ -26,9 +26,14 @@ #include "xdxfplugin.h" #include #include "../../include/Notify.h" +#include "DownloadDict.h" XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent), _langFrom(""), _langTo(""),_name(""), _infoNote("") { + + //DownloadDict a("\"icon\"English-Bulgarian computer dictionarycomn_sdict05_bulg_comp.tar.bz213,88955,094523EnglishBulgarianCommon XDXF2006-04-23 23:34:40"); + + _settings = new Settings(); _dictDialog = new XdxfDictDialog(this, this);