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

Contents of /infoscreen/pictureview.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 639 - (show annotations) (download)
Wed Apr 7 17:13:14 2010 UTC (14 years, 1 month ago) by torben
File size: 1024 byte(s)
sorta made pictureview work in localmode
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 void PictureView::paintEvent ( QPaintEvent* event)
14 {
15 Q_UNUSED(event);
16 QPainter painter(this);
17 painter.drawPixmap(0,0,image);
18 painter.end();
19 }
20
21 void PictureView::loadFromUrl(QString source)
22 {
23 QMap<QString, QPixmap>::iterator it = map.find(source);
24 if (it != map.end() ) {
25 image = it.value();
26 this->repaint();
27 } else {
28 qDebug() << "Loading file " << source;
29
30 QPixmap pixmap;
31 if (source.at(0) == '/') { //local file
32 pixmap = QPixmap(source);
33 } else {
34 QByteArray data = HttpWrapper::getSyncData(source);
35 pixmap.loadFromData( data );
36 }
37
38 QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );
39
40 image = scaledImage;
41 this->repaint();
42
43 map.insert(source, scaledImage);
44
45 }
46 }

  ViewVC Help
Powered by ViewVC 1.1.20