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 "theaterwindow.h"
19 #include "ui_theaterwindow.h"
21 #include "theaterscheduledelegate.h"
22 #include "theaterschedulemodel.h"
23 #include "data/cinemaschedule.h"
25 #include <QStackedLayout>
27 #include <QAbstractKineticScroller>
30 TheaterWindow::TheaterWindow(CinemaSchedule *cinema_schedule, QWidget *parent) :
31 AbstractMainWindow(parent),
32 ui(new Ui::TheaterWindow),
33 _cinema_schedule(cinema_schedule),
34 _theater_schedule_model(0)
38 setAttribute(Qt::WA_Maemo5StackedWindow);
40 QStackedLayout *layout = dynamic_cast<QStackedLayout*>(ui->MainStack->layout());
42 layout->setStackingMode(QStackedLayout::StackAll);
45 f.setPointSizeF(f.pointSizeF() * 1.5);
46 ui->ErrorMessage->setFont(f);
47 ui->Schedule->setItemDelegate(new TheaterScheduleDelegate(this));
48 ui->Schedule->setProperty("FingerScrollable", true);
49 connect(ui->Schedule, SIGNAL(clicked(QModelIndex)), this, SLOT(ScheduleEntrySelected(QModelIndex)));
52 TheaterWindow::~TheaterWindow()
57 void TheaterWindow::SetTheaterName(QString movie_name)
59 ui->Background->SetLabelText(movie_name);
62 void TheaterWindow::SetTheaterScheduleModel(QAbstractItemModel *theater_schedule_model)
64 _theater_schedule_model = theater_schedule_model;
65 ui->TheaterPages->setCurrentWidget(ui->TheaterPage);
66 ui->Schedule->setModel(_theater_schedule_model);
69 void TheaterWindow::SetError(QString error_text)
71 ui->TheaterPages->setCurrentWidget(ui->ErrorPage);
72 ui->ErrorMessage->setText(error_text);
75 bool TheaterWindow::IsIdle()
78 QAbstractKineticScroller *k1 = ui->Schedule->property("kineticScroller").value<QAbstractKineticScroller *>();
79 bool k1_idle = (k1 == 0) || (k1->state() == QAbstractKineticScroller::Inactive);
86 void TheaterWindow::changeEvent(QEvent *e)
88 QMainWindow::changeEvent(e);
90 case QEvent::LanguageChange:
91 ui->retranslateUi(this);
98 void TheaterWindow::ScheduleEntrySelected(QModelIndex index)
100 QVariant var = _theater_schedule_model->data(index, TheaterScheduleModel::TheaterScheduleKeyRole);
101 ScheduleEntryKey schedule_entry_key = qVariantValue<ScheduleEntryKey>(var);
102 emit ScheduleEntrySelected(schedule_entry_key);