Added spliting html from xdxf downlowad page to fields describing dicts
authorBartosz Szatkowski <bulislaw@linux.com>
Tue, 28 Sep 2010 08:40:51 +0000 (10:40 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Tue, 28 Sep 2010 08:40:51 +0000 (10:40 +0200)
src/plugins/xdxf/DownloadDict.h [new file with mode: 0644]
src/plugins/xdxf/xdxf.pro
src/plugins/xdxf/xdxfplugin.cpp

diff --git a/src/plugins/xdxf/DownloadDict.h b/src/plugins/xdxf/DownloadDict.h
new file mode 100644 (file)
index 0000000..dfe708a
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef DOWNLOADDICT_H
+#define DOWNLOADDICT_H
+
+#include <QRegExp>
+
+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("<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
index ef29877..025ed82 100644 (file)
@@ -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
index ee8ee03..a0f49f0 100644 (file)
 #include "xdxfplugin.h"
 #include <QDebug>
 #include "../../include/Notify.h"
+#include "DownloadDict.h"
 
 XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                     _langFrom(""), _langTo(""),_name(""), _infoNote("") {
+
+    //DownloadDict a("<tr><td><img src=\"buf/comn_sdict05_bulg_comp/icon16.png\" alt=\"icon\" /></td><td align=\"center\">English-Bulgarian computer dictionary</td><td align=\"center\"><a href=\"http://downloads.sourceforge.net/xdxf/comn_sdict05_bulg_comp.tar.bz2\" target=\"_blank\">comn_sdict05_bulg_comp.tar.bz2</a></td><td align=\"right\">13,889</td><td align=\"right\">55,094</td><td align=\"right\">523</td><td align=\"center\">English</td><td align=\"center\">Bulgarian</td><td align=\"center\"><a href=\"http://xdxf.revdanica.com/\">Common XDXF</a></td><td align=\"center\">2006-04-23 23:34:40</td></tr>");
+
+
     _settings = new Settings();
     _dictDialog = new XdxfDictDialog(this, this);