Initial commit (software version 0.2.0)
[movie-schedule] / src / control / theatercontroller.h
1 // Copyright 2010 Jochen Becher
2 //
3 // This file is part of MovieSchedule.
4 //
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.
9 //
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.
14 //
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/>.
17
18 #ifndef THEATERCONTROLLER_H
19 #define THEATERCONTROLLER_H
20
21 #include "data/scheduleentrykey.h"
22 #include "data/cinemakey.h"
23
24 #include <QObject>
25
26 class TheaterWindow;
27 class CinemaSchedule;
28 class TheaterScheduleModel;
29 class ItemModelSortController;
30 class ScheduleEntry;
31 class ActionController;
32 class QAbstractItemModel;
33 class QSortFilterProxyModel;
34
35 class TheaterController : public QObject
36 {
37     Q_OBJECT
38 public:
39     TheaterController(TheaterWindow *theater_window, CinemaSchedule *cinema_schedule, ActionController *action_controller,
40                       ItemModelSortController *sort_controller, QThread *search_worker);
41
42 public:
43     Q_SLOT void ShowTheater(CinemaKey cinema_key);
44     void Cancel();
45
46 private:
47     void CancelSearch();
48     Q_SLOT void ScheduleEntrySelected(ScheduleEntryKey schedule_entry_key);
49     Q_SLOT void SearchStarted(int search_task_id);
50     Q_SLOT void Reply(int search_task_id, bool intermediate);
51     Q_SLOT void Error(int search_task_id);
52     Q_SLOT void SearchFinished(int search_task_id, bool success);
53
54     void Sort(bool intermediate, const char *);
55     Q_SLOT void SortFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
56     Q_SLOT void SortErrorFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
57     void SetModel(QAbstractItemModel *model);
58
59 private:
60     TheaterWindow *_theater_window;
61     CinemaSchedule *_cinema_schedule;
62     ActionController *_action_controller;
63     ItemModelSortController *_sort_controller;
64     QThread *_search_worker;
65     int _current_search_task_id;
66     TheaterScheduleModel *_theater_schedule_model;
67     QSortFilterProxyModel *_theater_schedule_proxy_model;
68     CinemaKey _cinema_key;
69 };
70
71 #endif // THEATERCONTROLLER_H