Fixed searchclients to handle new Google URLs correctly; added GUI
[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 SettingsController;
33 class ItemModelSortController;
34 class TheaterModel;
35 class MovieModel;
36 class ConnectivityManager;
37 class QAbstractItemModel;
38 class QSortFilterProxyModel;
39
40 class MainController : public QObject
41 {
42     Q_OBJECT
43 public:
44     MainController(MainWindow *main_window, Settings *settings, CinemaSchedule *cinema_schedule,
45                    TheaterController *theater_controller, MovieController *movie_controller,
46                    LocationController *location_controller, ActionController *action_controller,
47                    SettingsController *settings_controller,
48                    ItemModelSortController *sort_controller, QThread *search_worker);
49     ~MainController();
50
51 public:
52     void Run();
53     void Search();
54     Q_SLOT void Search(Location location);
55
56 private:
57     Q_SLOT void NetworkConnected();
58     Q_SLOT void NetworkDisconnected();
59     Q_SLOT void NetworkError();
60
61     Q_SLOT void SettingsChanged(const Settings &settings);
62
63     Q_SLOT void SearchTheaters();
64     Q_SLOT void SearchMovies();
65     Q_SLOT void OpenAboutDialog();
66     void CancelTheaterSearch();
67     void CancelMovieSearch();
68
69     Q_SLOT void TheatersSearchStarted(int search_task_id);
70     Q_SLOT void TheatersSearchReply(int search_task_id, bool intermediate);
71     Q_SLOT void TheatersSearchError(int search_task_id);
72     Q_SLOT void TheatersSearchFinished(int search_task_id, bool success);
73
74     void SortTheaters(bool intermediate, const char *);
75     Q_SLOT void TheatersSortFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
76     Q_SLOT void TheatersSortErrorFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
77     void SetTheaterModel(QAbstractItemModel *model);
78
79     Q_SLOT void MoviesSearchStarted(int search_task_id);
80     Q_SLOT void MoviesSearchReply(int search_task_id, bool intermediate);
81     Q_SLOT void MoviesSearchError(int search_task_id);
82     Q_SLOT void MoviesSearchFinished(int search_task_id, bool success);
83
84     void SortMovies(bool intermediate, const char *);
85     Q_SLOT void MoviesSortFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
86     Q_SLOT void MoviesSortErrorFinished(QAbstractItemModel *model, int search_task_id, bool intermediate);
87     void SetMovieModel(QAbstractItemModel *model);
88
89 private:
90     MainWindow *_main_window;
91     Settings *_settings;
92     CinemaSchedule *_cinema_schedule;
93     TheaterController *_theater_controller;
94     MovieController *_movie_controller;
95     LocationController *_location_controller;
96     ActionController *_action_controller;
97     SettingsController *_settings_controller;
98     ItemModelSortController *_sort_controller;
99     QThread *_search_worker;
100     ConnectivityManager *_connectivity_manager;
101     int _current_theater_search_task_id;
102     int _current_movies_search_task_id;
103     TheaterModel *_theater_model;
104     MovieModel *_movie_model;
105     QSortFilterProxyModel *_theater_proxy_model;
106     QSortFilterProxyModel *_movie_proxy_model;
107     Settings _last_search_settings;    
108 };
109
110 #endif // MAINCONTROLLER_H