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 "moviewindow.h"
19 #include "ui_moviewindow.h"
21 #include "moviescheduledelegate.h"
22 #include "movieschedulemodel.h"
23 #include "data/cinemaschedule.h"
25 #include <QStackedLayout>
27 #include <QAbstractKineticScroller>
30 MovieWindow::MovieWindow(CinemaSchedule *cinema_schedule, QWidget *parent) :
31 AbstractMainWindow(parent),
32 ui(new Ui::MovieWindow),
33 _cinema_schedule(cinema_schedule),
34 _movie_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 MovieScheduleDelegate(this));
48 ui->Schedule->setProperty("FingerScrollable", true);
49 connect(ui->Schedule, SIGNAL(clicked(QModelIndex)), this, SLOT(ScheduleEntrySelected(QModelIndex)));
52 MovieWindow::~MovieWindow()
57 void MovieWindow::SetMovieName(QString movie_name)
59 ui->Background->SetLabelText(movie_name);
62 void MovieWindow::SetMovieScheduleModel(QAbstractItemModel *movie_schedule_model)
64 _movie_schedule_model = movie_schedule_model;
65 ui->MoviePages->setCurrentWidget(ui->MoviePage);
66 ui->Schedule->setModel(_movie_schedule_model);
69 void MovieWindow::SetError(QString error_text)
71 ui->MoviePages->setCurrentWidget(ui->ErrorPage);
72 ui->ErrorMessage->setText(error_text);
75 bool MovieWindow::IsIdle()
78 QAbstractKineticScroller *k1 = ui->Schedule->property("kineticScroller").value<QAbstractKineticScroller *>();
79 bool k1_idle = (k1 == 0) || (k1->state() == QAbstractKineticScroller::Inactive);
86 void MovieWindow::changeEvent(QEvent *e)
88 QMainWindow::changeEvent(e);
90 case QEvent::LanguageChange:
91 ui->retranslateUi(this);
98 void MovieWindow::ScheduleEntrySelected(QModelIndex index)
100 QVariant var = _movie_schedule_model->data(index, MovieScheduleModel::MovieScheduleKeyRole);
101 ScheduleEntryKey schedule_entry_key = qVariantValue<ScheduleEntryKey>(var);
102 emit ScheduleEntrySelected(schedule_entry_key);