--- infoscreen/pictureview.cpp 2010/01/05 17:19:02 526 +++ infoscreen/pictureview.cpp 2010/04/07 17:13:14 639 @@ -1,15 +1,13 @@ #include "pictureview.h" -#include -#include +#include #include -#include -#include + +#include "httpwrapper.h" PictureView::PictureView(QWidget* parent) : QWidget(parent) { - http.connect(&http, SIGNAL(requestFinished(int,bool)),this, SLOT(onLoad(int,bool)) ); } void PictureView::paintEvent ( QPaintEvent* event) @@ -27,32 +25,23 @@ image = it.value(); this->repaint(); } else { - requestedUrl = source; - - QUrl url(requestedUrl); - http.setHost(url.host() ); - http.get(url.path(), 0); - } -} - -void PictureView::onLoad(int id, bool ok) -{ - Q_UNUSED(id); - Q_UNUSED(ok); - qint64 byteCount = http.bytesAvailable(); - - if (byteCount > 0) { - - QByteArray data = http.readAll(); + qDebug() << "Loading file " << source; QPixmap pixmap; - pixmap.loadFromData( data ); + if (source.at(0) == '/') { //local file + pixmap = QPixmap(source); + } else { + QByteArray data = HttpWrapper::getSyncData(source); + pixmap.loadFromData( data ); + } QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation ); image = scaledImage; this->repaint(); - map.insert(requestedUrl, scaledImage); + map.insert(source, scaledImage); + } } +