1 // Copyright 2010 Jochen Becher
3 // This file is part of MovieSchedule.
5 // MovieSchedule 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 3 of the License, or
8 // (at your option) any later version.
10 // MovieSchedule 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 MovieSchedule. If not, see <http://www.gnu.org/licenses/>.
18 #include "cinemapainter.h"
20 #include "data/cinema.h"
21 #include "ui/styleutils.h"
24 #include <QStyleOptionViewItem>
26 CinemaPainter::CinemaPainter()
30 void CinemaPainter::Paint(QPainter *painter, const QStyleOptionViewItem &option, const Cinema *cinema) const
32 painter->setFont(option.font);
33 painter->setPen(StyleUtils::INSTANCE()->GetColor(option.palette, StyleUtils::DefaultTextColor));
34 painter->drawText(0, painter->fontMetrics().ascent(), cinema->GetName());
35 int y = painter->fontMetrics().height() + 2;
37 painter->setPen(StyleUtils::INSTANCE()->GetColor(option.palette, StyleUtils::SecondaryTextColor));
39 if (!cinema->GetAddress().isEmpty()) {
40 QFont font2(option.font);
41 font2.setPointSizeF(font2.pointSizeF() * 0.7);
42 painter->setFont(font2);
43 painter->drawText(0, y, 1000, painter->fontMetrics().height(),
44 0, cinema->GetAddress(), &bounding_rect);
47 if (!cinema->GetTelephone().isEmpty()) {
48 painter->drawText(bounding_rect.right(), y, 1000, painter->fontMetrics().height(),
49 0, QString((drawn ? ", %1" : "%1")).arg(cinema->GetTelephone()), &bounding_rect);
53 QSize CinemaPainter::GetSizeHint(const QStyleOptionViewItem &option) const
55 return QSize(0, option.fontMetrics.height() + 2 + option.fontMetrics.height() * 0.7 + 4);