diff --git a/config.pri b/config.pri index fcb0a15..46ffd5d 100644 --- a/config.pri +++ b/config.pri @@ -121,7 +121,6 @@ config_pri_source_group1 { $$quote($$BASEDIR/src/ActiveFrameQML.cpp) \ $$quote($$BASEDIR/src/Pnut.cpp) \ $$quote($$BASEDIR/src/Pnut_test.cpp) \ - $$quote($$BASEDIR/src/WebImageView.cpp) \ $$quote($$BASEDIR/src/applicationui.cpp) \ $$quote($$BASEDIR/src/main.cpp) \ $$quote($$BASEDIR/src/netimagemanager.cpp) \ @@ -130,7 +129,6 @@ config_pri_source_group1 { HEADERS += \ $$quote($$BASEDIR/src/ActiveFrameQML.h) \ $$quote($$BASEDIR/src/Pnut.h) \ - $$quote($$BASEDIR/src/WebImageView.h) \ $$quote($$BASEDIR/src/applicationui.hpp) \ $$quote($$BASEDIR/src/globals.h) \ $$quote($$BASEDIR/src/netimagemanager.h) \ diff --git a/src/WebImageView.cpp b/src/WebImageView.cpp deleted file mode 100644 index 8cbc80f..0000000 --- a/src/WebImageView.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "WebImageView.h" -#include - -QNetworkAccessManager * WebImageView::mNetManager = new QNetworkAccessManager; -QNetworkDiskCache * WebImageView::mNetworkDiskCache = new QNetworkDiskCache(); - -WebImageView::WebImageView() { - mNetworkDiskCache->setCacheDirectory(QDesktopServices::storageLocation(QDesktopServices::CacheLocation)); - mNetManager->setCache(mNetworkDiskCache); -} - -const QUrl& WebImageView::url() const { - return mUrl; -} - -void WebImageView::setUrl(const QUrl& url) { - - mUrl = url; - mLoading = 0; - - resetImage(); - QNetworkRequest request; - request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - request.setUrl(url); - - QNetworkReply * reply = mNetManager->get(QNetworkRequest(request)); - connect(reply,SIGNAL(finished()), this, SLOT(imageLoaded())); - connect(reply,SIGNAL(downloadProgress ( qint64 , qint64 )), this, SLOT(dowloadProgressed(qint64,qint64))); - emit urlChanged(); -} - -double WebImageView::loading() const { - return mLoading; -} - -void WebImageView::imageLoaded() { - - QNetworkReply * reply = qobject_cast(sender()); - - QVariant possibleRedirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - - mRedirectUrl = this->redirectUrl(possibleRedirectUrl.toUrl(),mRedirectUrl); - if (!mRedirectUrl.isEmpty()) { - this->setUrl(mRedirectUrl); - } else { - setImage(Image(reply->readAll())); - } - - reply->deleteLater(); - -} - -void WebImageView::dowloadProgressed(qint64 bytes,qint64 total) { - - - mLoading = double(bytes)/double(total); - emit loadingChanged(); - -} - -QUrl WebImageView::redirectUrl(const QUrl& possibleRedirectUrl, const QUrl& oldRedirectUrl) const { - QUrl redirectUrl; - if (!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl) { - redirectUrl = possibleRedirectUrl; - } - return redirectUrl; -} - - - - diff --git a/src/WebImageView.h b/src/WebImageView.h deleted file mode 100644 index 78fe413..0000000 --- a/src/WebImageView.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef WEBIMAGEVIEW_H_ -#define WEBIMAGEVIEW_H_ - -#include -#include -using namespace bb::cascades; - -class QNetworkAccessManager; -class WebImageView: public bb::cascades::ImageView { - Q_OBJECT - Q_PROPERTY (QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY (float loading READ loading NOTIFY loadingChanged) - -public: - WebImageView(); - const QUrl& url() const; - double loading() const; - - public Q_SLOTS: - void setUrl(const QUrl& url); - - private Q_SLOTS: - void imageLoaded(); - void dowloadProgressed(qint64,qint64); - - signals: - void urlChanged(); - void loadingChanged(); - - -private: - static QNetworkAccessManager * mNetManager; - static QNetworkDiskCache * mNetworkDiskCache; - QUrl mUrl; - QUrl mRedirectUrl; - float mLoading; - - QUrl redirectUrl(const QUrl& possibleRedirectUrl, const QUrl& oldRedirectUrl) const; -}; - -#endif /* WEBIMAGEVIEW_H_ */ diff --git a/src/applicationui.cpp b/src/applicationui.cpp index e37354c..2a5ce32 100644 --- a/src/applicationui.cpp +++ b/src/applicationui.cpp @@ -16,7 +16,6 @@ #include "applicationui.hpp" #include "Pnut.h" -#include "WebImageView.h" #include "ActiveFrameQML.h" #include "netimagemanager.h" #include "netimagetracker.h" @@ -57,7 +56,6 @@ ApplicationUI::ApplicationUI() : qmlRegisterType("com.monkeystew.pnut", 1, 0, "Pnut"); qmlRegisterType ("com.monkeystew.qtimer", 1, 0, "QTimer"); - qmlRegisterType("org.labsquare", 1, 0, "WebImageView"); qmlRegisterType("com.netimage", 1, 0, "NetImageTracker"); qmlRegisterType("com.netimage", 1, 0, "NetImageManager");