Merge https://vcs.maemo.org/git/movie-schedule
[movie-schedule] / src / control / moviecontroller.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 MOVIECONTROLLER_H
19 #define MOVIECONTROLLER_H
20
21 #include "data/scheduleentrykey.h"
22 #include "data/moviekey.h"
23
24 #include <QObject>
25
26 class MovieWindow;
27 class CinemaSchedule;
28 class ActionController;
29 class ItemModelSortController;
30 class MovieScheduleModel;
31 class QAbstractItemModel;
32 class QSortFilterProxyModel;
33
34 class MovieController : public QObject
35 {
36     Q_OBJECT
37 public:
38     MovieController(MovieWindow *movie_window, CinemaSchedule *cinema_schedule, ActionController *action_controller,
39                     ItemModelSortController *sort_controller, QThread *search_worker);
40
41 public:
42     Q_SLOT void ShowMovie(MovieKey movie_key);
43     void Cancel();
44
45 private:
46     void CancelSearch();
47     Q_SLOT void ScheduleEntrySelected(ScheduleEntryKey schedule_entry_key);
48     Q_SLOT void SearchStarted(int search_task_id);
49     Q_SLOT void Reply(int search_task_id, bool intermediate);
50     Q_SLOT void Error(int search_task_id);
51     Q_SLOT void SearchFinished(int search_task_id, bool success);
52
53     void Sort(bool intermediate, const char *);
54     Q_SLOT void SortFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
55     Q_SLOT void SortErrorFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
56     void SetModel(QAbstractItemModel *model);
57
58 private:
59     MovieWindow *_movie_window;
60     CinemaSchedule *_cinema_schedule;
61     ActionController *_action_controller;
62     ItemModelSortController *_sort_controller;
63     QThread *_search_worker;
64     int _current_search_task_id;
65     MovieScheduleModel *_movie_schedule_model;
66     QSortFilterProxyModel *_movie_schedule_proxy_model;
67     MovieKey _movie_key;
68 };
69
70 #endif // MOVIECONTROLLER_H