From 0b15e72d30ea6d8df96d6f5066a876899e379a75 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sun, 19 Apr 2015 21:03:15 +0200 Subject: [PATCH] Work on feed-on-page detection. --- src/network-web/networkfactory.cpp | 8 ++++++++ src/network-web/networkfactory.h | 2 ++ src/network-web/webbrowser.cpp | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/network-web/networkfactory.cpp b/src/network-web/networkfactory.cpp index bc029ff95..e6d1bfe98 100755 --- a/src/network-web/networkfactory.cpp +++ b/src/network-web/networkfactory.cpp @@ -32,6 +32,14 @@ NetworkFactory::NetworkFactory() { } +QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QString &html) { + QStringList feeds; + + + + return feeds; +} + QString NetworkFactory::networkErrorText(QNetworkReply::NetworkError error_code) { switch (error_code) { case QNetworkReply::ProtocolUnknownError: diff --git a/src/network-web/networkfactory.h b/src/network-web/networkfactory.h index 98efb97bf..8b0ef8055 100644 --- a/src/network-web/networkfactory.h +++ b/src/network-web/networkfactory.h @@ -34,6 +34,8 @@ class NetworkFactory { explicit NetworkFactory(); public: + static QStringList extractFeedLinksFromHtmlPage(const QString &html); + // Returns human readable text for given network error. static QString networkErrorText(QNetworkReply::NetworkError error_code); diff --git a/src/network-web/webbrowser.cpp b/src/network-web/webbrowser.cpp index 0d2700588..1f68763f9 100755 --- a/src/network-web/webbrowser.cpp +++ b/src/network-web/webbrowser.cpp @@ -21,6 +21,7 @@ #include "network-web/webbrowsernetworkaccessmanager.h" #include "network-web/webpage.h" #include "network-web/webview.h" +#include "network-web/networkfactory.h" #include "miscellaneous/skinfactory.h" #include "gui/formmain.h" #include "gui/tabwidget.h" @@ -158,6 +159,15 @@ void WebBrowser::onLoadingProgress(int progress) { void WebBrowser::onLoadingFinished(bool success) { Q_UNUSED(success) + if (success) { + // Let's check if there are any feeds defined on the web and eventually + // display "Add feeds" button. + QString loaded_html = m_webView->page()->toHtml(); + QStringList feeds_on_page = NetworkFactory::extractFeedLinksFromHtmlPage(loaded_html); + + // TODO: mame načteno html, nyni z něj funkcí vytáhneme seznam adres kanálů. dodelat tu fci. + } + m_loadingProgress->hide(); }