3 * Copyright (C) 2011 Roman Moravcik
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "forecastwidget.h"
25 ForecastWidget::ForecastWidget(QGraphicsWidget *parent) : QGraphicsWidget(parent)
27 ForecastWidget::ForecastWidget(QWidget *parent) : QWidget(parent)
34 void ForecastWidget::setImage(const QString &filename)
36 m_filename = filename;
41 void ForecastWidget::clearImage(bool error)
49 void ForecastWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
54 painter->setRenderHint(QPainter::Antialiasing);
56 QRect widgetArea(rect().x(), rect().y(), rect().width(), 369);
58 painter->setPen(QColor(0, 0, 0));
59 painter->setBrush(QColor(255, 255, 255));
60 painter->drawRect(widgetArea);
63 painter->drawText(widgetArea, Qt::AlignCenter, tr("Download failed!"));
65 if (!m_filename.isEmpty()) {
66 QImage image(m_filename);
67 painter->drawImage(widgetArea, image);
69 painter->drawText(widgetArea, Qt::AlignCenter, tr("Downloading image..."));
74 void ForecastWidget::paintEvent(QPaintEvent * /* event */)
76 QPainter painter(this);
77 painter.setRenderHint(QPainter::Antialiasing);
79 QRect widgetArea(rect().x(), rect().y(), rect().width(), 408);
81 painter.setPen(QColor(0, 0, 0));
82 painter.setBrush(QColor(255, 255, 255));
83 painter.drawRect(widgetArea);
86 painter.drawText(widgetArea, Qt::AlignCenter, tr("Download failed!"));
88 if (!m_filename.isEmpty()) {
89 QImage image(m_filename);
90 painter.drawImage(widgetArea, image);
92 painter.drawText(widgetArea, Qt::AlignCenter, tr("Downloading image..."));