/[projects]/infoscreen/pictureview.cpp
ViewVC logotype

Diff of /infoscreen/pictureview.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 525 by torben, Tue Jan 5 16:54:21 2010 UTC revision 639 by torben, Wed Apr 7 17:13:14 2010 UTC
# Line 1  Line 1 
1  #include "pictureview.h"  #include "pictureview.h"
2    
3  #include <QGraphicsView>  #include <QPainter>
 #include <QGraphicsScene>  
4  #include <QDebug>  #include <QDebug>
5  #include <QUrl>  
6  #include <QHttp>  #include "httpwrapper.h"
7    
8  PictureView::PictureView(QWidget* parent)  PictureView::PictureView(QWidget* parent)
9          : QWidget(parent)          : QWidget(parent)
# Line 26  void PictureView::loadFromUrl(QString so Line 25  void PictureView::loadFromUrl(QString so
25          image = it.value();          image = it.value();
26          this->repaint();          this->repaint();
27      } else {      } else {
28          requestedUrl = source;          qDebug() << "Loading file " << source;
   
         QUrl imageUrl(requestedUrl);  
         http = new QHttp(imageUrl.host() );  
         http->connect(http, SIGNAL(requestFinished(int,bool)),this, SLOT(onLoad(int,bool)) );  
   
         http->get(imageUrl.path(), 0);  
     }  
 }  
29    
30  void PictureView::onLoad(int id, bool ok)          QPixmap pixmap;
31  {          if (source.at(0) == '/') { //local file
32      Q_UNUSED(id);              pixmap = QPixmap(source);
33      Q_UNUSED(ok);          } else {
34                QByteArray data = HttpWrapper::getSyncData(source);
35                pixmap.loadFromData( data );
36            }
37    
38      QByteArray data = http->readAll();          QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );
39    
40      QPixmap pixmap;          image = scaledImage;
41      pixmap.loadFromData( data );          this->repaint();
     delete http;  
   
     QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );  
   
     image = scaledImage;  
     this->repaint();  
42    
43      map.insert(requestedUrl, scaledImage);          map.insert(source, scaledImage);
44    
45        }
46  }  }
47    

Legend:
Removed from v.525  
changed lines
  Added in v.639

  ViewVC Help
Powered by ViewVC 1.1.20