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

Annotation of /infoscreen/pictureview.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 641 - (hide annotations) (download)
Thu Apr 8 05:50:48 2010 UTC (14 years, 1 month ago) by torben
File size: 1163 byte(s)
added todo comment
1 torben 524 #include "pictureview.h"
2    
3 torben 528 #include <QPainter>
4 torben 639 #include <QDebug>
5 torben 524
6 torben 528 #include "httpwrapper.h"
7    
8 torben 524 PictureView::PictureView(QWidget* parent)
9     : QWidget(parent)
10     {
11     }
12    
13 torben 641
14     // TODO: if the picture doesn't fill the screen, fill the canvas with black before drawing the picture and
15     // place the image mid-screen
16 torben 524 void PictureView::paintEvent ( QPaintEvent* event)
17     {
18 torben 525 Q_UNUSED(event);
19 torben 524 QPainter painter(this);
20     painter.drawPixmap(0,0,image);
21     painter.end();
22     }
23    
24     void PictureView::loadFromUrl(QString source)
25     {
26     QMap<QString, QPixmap>::iterator it = map.find(source);
27     if (it != map.end() ) {
28     image = it.value();
29     this->repaint();
30     } else {
31 torben 639 qDebug() << "Loading file " << source;
32 torben 524
33 torben 526 QPixmap pixmap;
34 torben 639 if (source.at(0) == '/') { //local file
35     pixmap = QPixmap(source);
36     } else {
37     QByteArray data = HttpWrapper::getSyncData(source);
38     pixmap.loadFromData( data );
39     }
40 torben 524
41 torben 526 QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );
42 torben 524
43 torben 526 image = scaledImage;
44     this->repaint();
45 torben 524
46 torben 528 map.insert(source, scaledImage);
47    
48 torben 526 }
49 torben 524 }

  ViewVC Help
Powered by ViewVC 1.1.20