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

Contents of /infoscreen/pictureview.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 641 - (show 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 #include "pictureview.h"
2
3 #include <QPainter>
4 #include <QDebug>
5
6 #include "httpwrapper.h"
7
8 PictureView::PictureView(QWidget* parent)
9 : QWidget(parent)
10 {
11 }
12
13
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 void PictureView::paintEvent ( QPaintEvent* event)
17 {
18 Q_UNUSED(event);
19 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 qDebug() << "Loading file " << source;
32
33 QPixmap pixmap;
34 if (source.at(0) == '/') { //local file
35 pixmap = QPixmap(source);
36 } else {
37 QByteArray data = HttpWrapper::getSyncData(source);
38 pixmap.loadFromData( data );
39 }
40
41 QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );
42
43 image = scaledImage;
44 this->repaint();
45
46 map.insert(source, scaledImage);
47
48 }
49 }

  ViewVC Help
Powered by ViewVC 1.1.20