Merge https://vcs.maemo.org/git/movie-schedule
[movie-schedule] / src / control / maincontroller.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 MAINCONTROLLER_H
19 #define MAINCONTROLLER_H
20
21 #include "data/location.h"
22 #include "data/settings.h"
23
24 #include <QObject>
25
26 class MainWindow;
27 class CinemaSchedule;
28 class TheaterController;
29 class MovieController;
30 class LocationController;
31 class ActionController;
32 class ItemModelSortController;
33 class TheaterModel;
34 class MovieModel;
35 class ConnectivityManager;
36 class QAbstractItemModel;
37 class QSortFilterProxyModel;
38
39 class MainController : public QObject
40 {
41     Q_OBJECT
42 public:
43     MainController(MainWindow *main_window, Settings *settings, CinemaSchedule *cinema_schedule,
44                    TheaterController *theater_controller, MovieController *movie_controller,
45                    LocationController *location_controller, ActionController *action_controller,
46                    ItemModelSortController *sort_controller, QThread *search_worker);
47     ~MainController();
48
49 public:
50     void Run();
51     void Search();
52     Q_SLOT void Search(Location location);
53
54 private:
55     Q_SLOT void NetworkConnected();
56     Q_SLOT void NetworkDisconnected();
57     Q_SLOT void NetworkError();
58
59     Q_SLOT void SearchTheaters();
60     Q_SLOT void SearchMovies();
61     Q_SLOT void OpenAboutDialog();
62     void CancelTheaterSearch();
63     void CancelMovieSearch();
64
65     Q_SLOT void TheatersSearchStarted(int search_task_id);
66     Q_SLOT void TheatersSearchReply(int search_task_id, bool intermediate);
67     Q_SLOT void TheatersSearchError(int search_task_id);
68     Q_SLOT void TheatersSearchFinished(int search_task_id, bool success);
69
70     void SortTheaters(bool intermediate, const char *);
71     Q_SLOT void TheatersSortFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
72     Q_SLOT void TheatersSortErrorFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
73     void SetTheaterModel(QAbstractItemModel *model);
74
75     Q_SLOT void MoviesSearchStarted(int search_task_id);
76     Q_SLOT void MoviesSearchReply(int search_task_id, bool intermediate);
77     Q_SLOT void MoviesSearchError(int search_task_id);
78     Q_SLOT void MoviesSearchFinished(int search_task_id, bool success);
79
80     void SortMovies(bool intermediate, const char *);
81     Q_SLOT void MoviesSortFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
82     Q_SLOT void MoviesSortErrorFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
83     void SetMovieModel(QAbstractItemModel *model);
84
85 private:
86     MainWindow *_main_window;
87     Settings *_settings;
88     CinemaSchedule *_cinema_schedule;
89     TheaterController *_theater_controller;
90     MovieController *_movie_controller;
91     LocationController *_location_controller;
92     ActionController *_action_controller;
93     ItemModelSortController *_sort_controller;
94     QThread *_search_worker;
95     ConnectivityManager *_connectivity_manager;
96     int _current_theater_search_task_id;
97     int _current_movies_search_task_id;
98     TheaterModel *_theater_model;
99     MovieModel *_movie_model;
100     QSortFilterProxyModel *_theater_proxy_model;
101     QSortFilterProxyModel *_movie_proxy_model;
102     Settings _last_search_settings;    
103 };
104
105 #endif // MAINCONTROLLER_H