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
26 #include "forecastwidget.h"
29 ForecastWidget::ForecastWidget(QGraphicsWidget *parent) : QGraphicsWidget(parent)
31 ForecastWidget::ForecastWidget(QWidget *parent) : QWidget(parent)
38 void ForecastWidget::setImage(const QString &filename)
40 m_filename = filename;
45 void ForecastWidget::clearImage(bool error)
53 void ForecastWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
58 QRect widgetArea(rect().x(), rect().y(), rect().width(), 369);
60 painter->setFont(MLabel().font());
61 painter->setPen(QColor(0, 0, 0));
62 painter->setBrush(QColor(255, 255, 255));
63 painter->drawRect(widgetArea);
66 painter->drawText(widgetArea, Qt::AlignCenter, tr("Download failed!"));
68 if (!m_filename.isEmpty()) {
69 QImage image(m_filename);
70 painter->drawImage(widgetArea, image);
72 painter->drawText(widgetArea, Qt::AlignCenter, tr("Downloading image..."));
77 void ForecastWidget::paintEvent(QPaintEvent * /* event */)
79 QPainter painter(this);
80 painter.setRenderHint(QPainter::Antialiasing);
82 QRect widgetArea(rect().x(), rect().y(), rect().width(), 408);
84 painter.setPen(QColor(0, 0, 0));
85 painter.setBrush(QColor(255, 255, 255));
86 painter.drawRect(widgetArea);
89 painter.drawText(widgetArea, Qt::AlignCenter, tr("Download failed!"));
91 if (!m_filename.isEmpty()) {
92 QImage image(m_filename);
93 painter.drawImage(widgetArea, image);
95 painter.drawText(widgetArea, Qt::AlignCenter, tr("Downloading image..."));