/[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 526 by torben, Tue Jan 5 17:19:02 2010 UTC
# Line 9  Line 9 
9  PictureView::PictureView(QWidget* parent)  PictureView::PictureView(QWidget* parent)
10          : QWidget(parent)          : QWidget(parent)
11  {  {
12        http.connect(&http, SIGNAL(requestFinished(int,bool)),this, SLOT(onLoad(int,bool)) );
13  }  }
14    
15  void PictureView::paintEvent ( QPaintEvent* event)  void PictureView::paintEvent ( QPaintEvent* event)
# Line 28  void PictureView::loadFromUrl(QString so Line 29  void PictureView::loadFromUrl(QString so
29      } else {      } else {
30          requestedUrl = source;          requestedUrl = source;
31    
32          QUrl imageUrl(requestedUrl);          QUrl url(requestedUrl);
33          http = new QHttp(imageUrl.host() );          http.setHost(url.host() );
34          http->connect(http, SIGNAL(requestFinished(int,bool)),this, SLOT(onLoad(int,bool)) );          http.get(url.path(), 0);
   
         http->get(imageUrl.path(), 0);  
35      }      }
36  }  }
37    
# Line 40  void PictureView::onLoad(int id, bool ok Line 39  void PictureView::onLoad(int id, bool ok
39  {  {
40      Q_UNUSED(id);      Q_UNUSED(id);
41      Q_UNUSED(ok);      Q_UNUSED(ok);
42        qint64 byteCount = http.bytesAvailable();
43    
44      QByteArray data = http->readAll();      if (byteCount > 0) {
45    
46      QPixmap pixmap;          QByteArray data = http.readAll();  
     pixmap.loadFromData( data );  
     delete http;  
47    
48      QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );          QPixmap pixmap;
49            pixmap.loadFromData( data );
50    
51      image = scaledImage;          QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );
     this->repaint();  
52    
53      map.insert(requestedUrl, scaledImage);          image = scaledImage;
54            this->repaint();
55    
56            map.insert(requestedUrl, scaledImage);
57        }
58  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.20