8a6c3e7ac6a5fc3623efcf919d510ad018731e21
[movie-schedule] / src / ui / mainwindow.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 MAINWINDOW_H
19 #define MAINWINDOW_H
20
21 #include "abstractmainwindow.h"
22 #include "data/location.h"
23 #include "data/cinemakey.h"
24 #include "data/moviekey.h"
25
26 #include <QModelIndex>
27
28 class CinemaSchedule;
29 class Cinema;
30 class Movie;
31 class QAbstractItemModel;
32 class QMenu;
33 class QAction;
34
35 namespace Ui {
36     class MainWindow;
37 }
38
39 class MainWindow : public AbstractMainWindow {
40     Q_OBJECT
41 public:
42     explicit MainWindow(const CinemaSchedule *cinema_schedule, QWidget *parent = 0);
43     ~MainWindow();
44
45 public:
46     Q_SLOT void SetLocation(Location location);
47     Q_SLOT void SetTheaterModel(QAbstractItemModel *);
48     Q_SLOT void SetMovieModel(QAbstractItemModel *);
49     Q_SLOT void SetError(QString error_text);
50
51 public:
52     Q_SIGNAL void SearchTheaters();
53     Q_SIGNAL void SearchMovies();
54     Q_SIGNAL void OpenLocationDialog();
55     Q_SIGNAL void OpenAboutDialog();
56     Q_SIGNAL void TheaterSelected(CinemaKey);
57     Q_SIGNAL void MovieSelected(MovieKey);
58     Q_SIGNAL void CallTheaterByPhone(CinemaKey);
59     Q_SIGNAL void FindRouteToTheater(CinemaKey);
60     Q_SIGNAL void SearchTheaterInWeb(CinemaKey);
61     Q_SIGNAL void SearchMovieInWeb(MovieKey);
62
63 private:
64     Q_SLOT void TheaterClicked(QModelIndex);
65     Q_SLOT void TheaterContextMenuRequested(const QPoint &);
66     Q_SLOT void MovieClicked(QModelIndex);
67     Q_SLOT void MovieContextMenuRequested(const QPoint &);
68     Q_SLOT void CallTheaterByPhone();
69     Q_SLOT void FindRouteToTheater();
70     Q_SLOT void SearchTheaterInWeb();
71     Q_SLOT void SearchMovieInWeb();
72
73 protected:
74     void changeEvent(QEvent *e);
75
76 private:
77     CinemaKey GetCinema(const QModelIndex &index);
78     MovieKey GetMovie(const QModelIndex &index);
79     void ShowContextMenu(const Cinema *, const QPoint &pos);
80     void ShowContextMenu(const Movie *, const QPoint &pos);
81
82 private:
83     Ui::MainWindow *ui;
84     const CinemaSchedule *_cinema_schedule;
85     QMenu *_theater_context_menu;
86     QMenu *_movie_context_menu;
87     QAction *_theater_phone_call;
88     QAction *_theater_find_route;
89     QAction *_theater_search_web;
90     QAction *_movie_search_web;
91     Location _location;
92     QAbstractItemModel *_theater_model;
93     QAbstractItemModel *_movie_model;
94 };
95
96 #endif // MAINWINDOW_H