Fixed searchclients to handle new Google URLs correctly; added GUI
authorgilead <j.becher@ovi.com>
Tue, 14 Sep 2010 21:20:18 +0000 (23:20 +0200)
committergilead <j.becher@ovi.com>
Tue, 14 Sep 2010 21:20:18 +0000 (23:20 +0200)
rotation with options dialog

33 files changed:
debian/changelog
src/control/maincontroller.cpp
src/control/maincontroller.h
src/control/settingscontroller.cpp
src/control/settingscontroller.h
src/data/settings.cpp
src/data/settings.h
src/movieschedule.cpp
src/searchclients/abstractsearchclient.cpp
src/searchclients/abstractsearchclient.h
src/searchclients/movieschedulesearchclient.cpp
src/searchclients/moviesearchclient.cpp
src/searchclients/theaterschedulesearchclient.cpp
src/searchclients/theatersearchclient.cpp
src/src.pro
src/translations/movie-schedule_de.ts
src/ui/aboutdialog.cpp
src/ui/aboutdialog.h
src/ui/aboutdialog.ui
src/ui/backgroundlabel.cpp
src/ui/contextdialog.cpp
src/ui/contextdialog.h
src/ui/locationdialog.cpp
src/ui/locationdialog.h
src/ui/locationdialog.ui
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/optionsdialog.cpp [new file with mode: 0644]
src/ui/optionsdialog.h [new file with mode: 0644]
src/ui/optionsdialog.ui [new file with mode: 0644]
src/ui/styleutils.cpp
src/ui/uiutils.cpp
src/ui/uiutils.h

index 6de16f9..12b3d67 100644 (file)
@@ -1,10 +1,23 @@
+movie-schedule (0.3.0-1) unstable; urgency=low
+
+  * Fixed german translation file
+  * Updated options dialog layout
+
+ -- Jochen Becher <j.becher@ovi.com>  Sun, 13 Sep 2010 22:30:00 +0000
+
+movie-schedule (0.3.0) unstable; urgency=low
+
+  *  Add GUI rotation (including options dialog) (Closes: #6256)
+  *  Fix access of Googles movie pages (Closes: #6399)
+
+ -- Jochen Becher <j.becher@ovi.com>  Sun, 12 Sep 2010 23:00:00 +0000
+
 movie-schedule (0.2.2) unstable; urgency=low
 
   * Fixed interpretation of schedule times (Closes: #6234)
 
  -- Jochen Becher <j.becher@ovi.com>  Sun, 05 Sep 2010 22:15:00 +0000
 
-
 movie-schedule (0.2.1) unstable; urgency=low
 
   * Fixed link to bugtracker in debian/control files (Closes: #6226)
index 5130da7..e409fdc 100644 (file)
@@ -26,6 +26,7 @@
 #include "control/actioncontroller.h"
 #include "control/locationcontroller.h"
 #include "control/itemmodelsortclient.h"
+#include "control/settingscontroller.h"
 #include "ui/aboutdialog.h"
 #include "ui/mainwindow.h"
 #include "ui/theatermodel.h"
@@ -51,6 +52,7 @@ MainController::MainController(MainWindow *main_window, Settings *settings, Cine
                                MovieController *movie_controller,
                                LocationController *location_controller,
                                ActionController *action_controller,
+                               SettingsController *settings_controller,
                                ItemModelSortController *sort_controller,
                                QThread *search_worker)
                                    : _main_window(main_window),
@@ -60,6 +62,7 @@ MainController::MainController(MainWindow *main_window, Settings *settings, Cine
                                    _movie_controller(movie_controller),
                                    _location_controller(location_controller),
                                    _action_controller(action_controller),
+                                   _settings_controller(settings_controller),
                                    _sort_controller(sort_controller),
                                    _search_worker(search_worker),
                                    _connectivity_manager(new ConnectivityManager(this)),
@@ -80,11 +83,14 @@ MainController::MainController(MainWindow *main_window, Settings *settings, Cine
     connect(_main_window, SIGNAL(MovieSelected(MovieKey)), _movie_controller, SLOT(ShowMovie(MovieKey)));
     connect(_main_window, SIGNAL(SearchMovieInWeb(MovieKey)), _action_controller, SLOT(SearchMovieInWeb(MovieKey)));
     connect(_main_window, SIGNAL(OpenLocationDialog()), _location_controller, SLOT(OpenLocationDialog()));
+    connect(_main_window, SIGNAL(OpenOptionsDialog()), _settings_controller, SLOT(OpenSettingsDialog()));
     connect(_main_window, SIGNAL(OpenAboutDialog()), this, SLOT(OpenAboutDialog()));
+    connect(_settings_controller, SIGNAL(SettingsChanged(Settings)), this, SLOT(SettingsChanged(Settings)));
     connect(_location_controller, SIGNAL(Search(Location)), this, SLOT(Search(Location)));
     connect(_connectivity_manager, SIGNAL(Connected()), this, SLOT(NetworkConnected()));
     connect(_connectivity_manager, SIGNAL(Disconnected()), this, SLOT(NetworkDisconnected()));
     connect(_connectivity_manager, SIGNAL(Error()), this, SLOT(NetworkError()));
+    _main_window->SetOrientation(settings->GetOrientationMode());
 }
 
 MainController::~MainController()
@@ -182,6 +188,11 @@ void MainController::NetworkError()
     _main_window->SetError(tr(MSG_NETWORK_ERROR));
 }
 
+void MainController::SettingsChanged(const Settings &settings)
+{
+    _main_window->SetOrientation(settings.GetOrientationMode());
+}
+
 void MainController::SearchTheaters()
 {
     _settings->SetSearchObjectsType(Settings::THEATERS);
index 30f9f4e..d0a3fe1 100644 (file)
@@ -29,6 +29,7 @@ class TheaterController;
 class MovieController;
 class LocationController;
 class ActionController;
+class SettingsController;
 class ItemModelSortController;
 class TheaterModel;
 class MovieModel;
@@ -43,6 +44,7 @@ public:
     MainController(MainWindow *main_window, Settings *settings, CinemaSchedule *cinema_schedule,
                    TheaterController *theater_controller, MovieController *movie_controller,
                    LocationController *location_controller, ActionController *action_controller,
+                   SettingsController *settings_controller,
                    ItemModelSortController *sort_controller, QThread *search_worker);
     ~MainController();
 
@@ -56,6 +58,8 @@ private:
     Q_SLOT void NetworkDisconnected();
     Q_SLOT void NetworkError();
 
+    Q_SLOT void SettingsChanged(const Settings &settings);
+
     Q_SLOT void SearchTheaters();
     Q_SLOT void SearchMovies();
     Q_SLOT void OpenAboutDialog();
@@ -90,6 +94,7 @@ private:
     MovieController *_movie_controller;
     LocationController *_location_controller;
     ActionController *_action_controller;
+    SettingsController *_settings_controller;
     ItemModelSortController *_sort_controller;
     QThread *_search_worker;
     ConnectivityManager *_connectivity_manager;
index a5e1188..aa88363 100644 (file)
@@ -18,6 +18,8 @@
 #include "settingscontroller.h"
 
 #include "data/settings.h"
+#include "ui/mainwindow.h"
+#include "ui/optionsdialog.h"
 
 #include <QFile>
 #include <QXmlStreamReader>
@@ -25,8 +27,9 @@
 #include <QDir>
 #include <iostream>
 
-SettingsController::SettingsController(Settings *settings)
-    : _settings(settings)
+SettingsController::SettingsController(MainWindow *main_window, Settings *settings)
+    : _main_window(main_window),
+    _settings(settings)
 {
 }
 
@@ -40,6 +43,7 @@ enum State {
     STATE_PREVIOUS_LOCATION_NAME,
     STATE_GPS,
     STATE_SEARCH,
+    STATE_ORIENTATION
 };
 
 void SettingsController::Load()
@@ -72,11 +76,15 @@ void SettingsController::Load()
                     state = STATE_GPS;
                 } else if (state == STATE_SETTINGS && xml.name() == "search") {
                     state = STATE_SEARCH;
+                } else if (state == STATE_SETTINGS && xml.name() == "orientation") {
+                    state = STATE_ORIENTATION;
                 } else {
                     state = STATE_DOCUMENT;
                 }
             } else if (token == QXmlStreamReader::EndElement) {
-                if (state == STATE_SEARCH) {
+                if (state == STATE_ORIENTATION) {
+                    state = STATE_SETTINGS;
+                } else if (state == STATE_SEARCH) {
                     state = STATE_SETTINGS;
                 } else if (state == STATE_GPS) {
                     state = STATE_SETTINGS;
@@ -107,6 +115,14 @@ void SettingsController::Load()
                     } else if (xml.text() == "movies") {
                         _settings->SetSearchObjectsType(Settings::MOVIES);
                     }
+                } else if (state == STATE_ORIENTATION) {
+                    if (xml.text() == "landscape") {
+                        _settings->SetOrientationMode(Settings::LANDSCAPE);
+                    } else if (xml.text() == "portrait") {
+                        _settings->SetOrientationMode(Settings::PORTRAIT);
+                    } else if (xml.text() == "autorotation") {
+                        _settings->SetOrientationMode(Settings::AUTOROTATION);
+                    }
                 }
             }
         }
@@ -131,18 +147,18 @@ void SettingsController::Save()
         xml.writeStartElement("settings");
         xml.writeStartElement("location");
         xml.writeTextElement("name", _settings->GetLocation().GetLocationName());
-        xml.writeEndElement();
+        xml.writeEndElement(); // </location>
         xml.writeStartElement("previous-locations");
         Q_FOREACH(Location location, _settings->GetPreviousLocations()) {
             xml.writeStartElement("location");
             xml.writeTextElement("name", location.GetLocationName());
             xml.writeEndElement();
         }
-        xml.writeEndElement();
+        xml.writeEndElement(); // </previous-locations>
         QString v;
         xml.writeStartElement("gps");
         xml.writeAttribute("enabled", _settings->IsGPSEnabled() ? "yes" : "no");
-        xml.writeEndElement();
+        xml.writeEndElement(); // </gps>
         switch (_settings->GetSearchObjectsType()) {
         case Settings::THEATERS:
             v = "theaters";
@@ -152,7 +168,19 @@ void SettingsController::Save()
             break;
         }
         xml.writeTextElement("search", v);
-        xml.writeEndElement();
+        switch (_settings->GetOrientationMode()) {
+        case Settings::LANDSCAPE:
+            v = "landscape";
+            break;
+        case Settings::PORTRAIT:
+            v = "portrait";
+            break;
+        case Settings::AUTOROTATION:
+            v = "autorotation";
+            break;
+        }
+        xml.writeTextElement("orientation", v);
+        xml.writeEndElement(); // </settings>
         xml.writeEndDocument();
     } else {
         // TODO error message unable to create file
@@ -160,6 +188,35 @@ void SettingsController::Save()
     }
 }
 
+void SettingsController::EmitInitialSettings()
+{
+    emit SettingsChanged(*_settings);
+}
+
+void SettingsController::OpenSettingsDialog()
+{
+#ifdef Q_WS_MAEMO_5
+    OptionsDialog *dialog = new OptionsDialog(_main_window);
+    connect(dialog, SIGNAL(Accept(Settings)), this, SLOT(AcceptSettingsDialog(Settings)));
+    connect(dialog, SIGNAL(Cancel(Settings)), this, SLOT(CancelSettingsDialog(Settings)));
+    dialog->SetSettings(*_settings);
+    dialog->show();
+    // dialog deletes itself
+#endif
+}
+
+void SettingsController::AcceptSettingsDialog(const Settings &settings)
+{
+    *_settings = settings;
+    emit SettingsChanged(settings);
+}
+
+void SettingsController::CancelSettingsDialog(const Settings &settings)
+{
+    Q_UNUSED(settings);
+    // do nothing
+}
+
 QString SettingsController::GetSettingsFileName()
 {
     QString dirpath = QDir::homePath() + "/.movie-schedule";
index 7d7889c..2a44ac5 100644 (file)
 #define SETTINGSCONTROLLER_H
 
 #include <QString>
+#include <QObject>
 
+class MainWindow;
 class Settings;
 
-class SettingsController
+class SettingsController : public QObject
 {
+    Q_OBJECT
 public:
-    SettingsController(Settings *settings);
+    SettingsController(MainWindow *main_window, Settings *settings);
 
     void Load();
     void Save();
 
+    void EmitInitialSettings();
+
+public:
+    Q_SIGNAL void SettingsChanged(const Settings &);
+
+public:
+    Q_SLOT void OpenSettingsDialog();
+
+private:
+    Q_SLOT void AcceptSettingsDialog(const Settings &);
+    Q_SLOT void CancelSettingsDialog(const Settings &);
+
 private:
     QString GetSettingsFileName();
 
 private:
+    MainWindow *_main_window;
     Settings *_settings;
 };
 
index 6c1528a..8b90acd 100644 (file)
@@ -21,7 +21,8 @@ Settings::Settings()
     : _location(),
     _previous_locations(),
     _gps_enabled(true),
-    _search_objects_type(MOVIES)
+    _search_objects_type(MOVIES),
+    _rotation_mode(AUTOROTATION)
 {
 }
 
index d94c76c..40fb2b7 100644 (file)
@@ -33,6 +33,12 @@ public:
         MOVIES
     };
 
+    enum OrientationMode {
+        LANDSCAPE,
+        PORTRAIT,
+        AUTOROTATION
+    };
+
 public:
     Settings();
 
@@ -48,11 +54,15 @@ public:
     SearchObjectsType GetSearchObjectsType() const { return _search_objects_type; }
     void SetSearchObjectsType(SearchObjectsType search_objects_type) { _search_objects_type = search_objects_type; }
 
+    OrientationMode GetOrientationMode() const { return _rotation_mode; }
+    void SetOrientationMode(OrientationMode rotation_mode) { _rotation_mode = rotation_mode; }
+
 private:
     Location _location;
     Locations _previous_locations;
     bool _gps_enabled;
     SearchObjectsType _search_objects_type;
+    OrientationMode _rotation_mode;
 };
 
 #endif // SETTINGS_H
index 0063016..ec44af9 100644 (file)
@@ -105,7 +105,7 @@ int MovieSchedule::exec(int argc, char *argv[])
     main_window.show();
 
     Settings settings;
-    SettingsController settings_controller(&settings);
+    SettingsController settings_controller(&main_window, &settings);
     settings_controller.Load();
 
     ActionController action_controller(&cinema_schedule);
@@ -131,8 +131,9 @@ int MovieSchedule::exec(int argc, char *argv[])
 
     MainController main_controller(&main_window, &settings, &cinema_schedule, &theater_controller,
                                    &movie_controller, &location_controller, &action_controller,
-                                   &sort_controller, &search_worker);
+                                   &settings_controller, &sort_controller, &search_worker);
 
+    settings_controller.EmitInitialSettings();
     main_controller.Run();
 
     int rc = app.exec();
index c19b7bc..eea2103 100644 (file)
@@ -48,20 +48,21 @@ void AbstractSearchClient::Search(const QUrl &url, int start)
     }
     QNetworkRequest request;
     QUrl xurl(url);
-    if (_start != 0) {
+    if (_start != 0 && !url.hasQueryItem("start")) {
         xurl.addQueryItem("start", QString::number(_start));
     }
     FixLocation(&xurl);
     //std::cout << "URL: " << qPrintable(QString(xurl.toEncoded())) << std::endl;
     request.setUrl(xurl);
-    //request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.9) Gecko/20100401 Ubuntu/9.10 (karmic) Firefox/3.5.9");
+    //request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.8) Gecko/20100723 Ubuntu/9.10 (karmic) Firefox/3.6.8");
     request.setRawHeader("User-Agent", "Mozilla/5.0");
     //request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
     request.setRawHeader("Accept", "application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
     request.setRawHeader("Accept-Language", "en-gb;q=1.0,en;q=0.9,de-de;q=0.5,de;q=0.3");
+    //request.setRawHeader("Accept-Language", "en-us,en;q=0.8,de-de;q=0.5,de;q=0.3");
     //request.setRawHeader("Accept-Encoding", "gzip,deflate");
     request.setRawHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
-    request.setRawHeader("Keep-Alive", "300");
+    request.setRawHeader("Keep-Alive", "115");
     request.setRawHeader("Connection", "keep-alive");
     request.setRawHeader("Cache-Control", "max-age=0");
     QNetworkReply *reply = _network->get(request);
@@ -69,6 +70,12 @@ void AbstractSearchClient::Search(const QUrl &url, int start)
     connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(NetworkError(QNetworkReply::NetworkError)));
 }
 
+void AbstractSearchClient::SearchEncodedUrl(const QString &encoded_url, int start)
+{
+    QUrl url = QUrl::fromEncoded((QString("http://www.google.com") + encoded_url).toAscii());
+    Search(url, start);
+}
+
 void AbstractSearchClient::DownloadProgress(qint64 a,qint64 b)
 {
     //std::cout << "Search Progress of " << qPrintable(objectName()) << " - " << a << ", " << b << std::endl;
@@ -146,6 +153,7 @@ QList<QTime> AbstractSearchClient::TimesFromString(const QList<QString> &time_st
 
 void AbstractSearchClient::FixLocation(QUrl *url)
 {
+#if 0
     // Try to fix the Google url which returns
     // wrong locations in some links
     if (_location.isNull()) {
@@ -172,6 +180,9 @@ void AbstractSearchClient::FixLocation(QUrl *url)
             url->addQueryItem("defaultloc", _location);
         }
     }
+#else
+    Q_UNUSED(url);
+#endif
 }
 
 QMutex AbstractSearchClient::_next_search_task_id_mutex;
index 123984b..9286ce2 100644 (file)
@@ -39,6 +39,7 @@ protected:
     int GetStartIndex() { return _start; }
 
     virtual void Search(const QUrl &url, int start);
+    virtual void SearchEncodedUrl(const QString &endcoded_url, int start);
 
 public:
     Q_SIGNAL void SearchStarted(int search_task_id);
index 7041c5e..235f549 100644 (file)
@@ -78,6 +78,7 @@ enum State {
     PARSE_LINK,
     PARSE_BR,
     PARSE_SPAN,
+    PARSE_NEXT_PAGE_LINK
 };
 
 void MovieScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
@@ -92,6 +93,8 @@ void MovieScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
     QString theater_phone;
     QList<QString> schedule;
     QRegExp time_pattern("\\d+:\\d+([aApP][mM])*");
+    QString next_page_url;
+    int next_page_start;
     while (!xml.atEnd()) {
         QXmlStreamReader::TokenType token = xml.readNext();
         if (token == QXmlStreamReader::StartElement) {
@@ -102,7 +105,7 @@ void MovieScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                 //std::cout << "LINK " << qPrintable(attr_href) << std::endl;
                 if (url.hasQueryItem("date")) {
                     QString v = url.queryItemValue("date");
-                    std::cout << "FOUND Date Link " << qPrintable(v) << " from " << qPrintable(url.toString()) << std::endl;
+                    //std::cout << "FOUND Date Link " << qPrintable(v) << " from " << qPrintable(url.toString()) << std::endl;
                     if (!_dates_seen.contains(v)) {
                         // TODO replace location with user selected location (Google simplifies to much)
                         _dates_seen.insert(v);
@@ -115,6 +118,16 @@ void MovieScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                     theater_phone = "";
                     schedule.clear();
                     state = PARSE_THEATER_LINK;
+                } else if (url.hasQueryItem("start")) {
+                    QString sort = url.queryItemValue("sort");
+                    QString start = url.queryItemValue("start");
+                    int istart = start.toInt();
+                    if (sort == "0" && istart > GetStartIndex()) {
+                        //std::cout << "next page LINK " << qPrintable(attr_href) << std::endl;
+                        next_page_url = attr_href;
+                        next_page_start = istart;
+                    }
+                    state = PARSE_NEXT_PAGE_LINK;
                 } else {
                     state = PARSE_HTML;
                 }
@@ -176,6 +189,8 @@ void MovieScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                         }
                     }
                 }
+            } else if (state == PARSE_NEXT_PAGE_LINK) {
+                state = PARSE_HTML;
             }
         } else if (token == QXmlStreamReader::Characters) {
             if (state == PARSE_THEATER_LINK) {
@@ -214,9 +229,9 @@ void MovieScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
         emit SearchFinished(GetSearchTaskId(), false);
         deleteLater();
     } else {
-        if (found > 0) {
+        if (!next_page_url.isEmpty()) {
             emit Reply(GetSearchTaskId(), true);
-            Search(GetStartIndex() + found);
+            SearchEncodedUrl(next_page_url, next_page_start);
         } else {
             if (!_date_urls.isEmpty()) {
                 SearchNextDate();
index 670c569..ec642ec 100644 (file)
@@ -48,6 +48,7 @@ void MovieSearchClient::CancelAllRunningSearchs()
 void MovieSearchClient::Search(int start)
 {
     QUrl url("http://www.google.com/m/movies");
+    url.addQueryItem("action","chgloc");
     url.addQueryItem("loc", _town);
     url.addQueryItem("sort", QString::number(1));
     AbstractSearchClient::Search(url, start);
@@ -58,7 +59,8 @@ enum State {
     PARSE_MOVIE_LINK,
     PARSE_EXPECT_DIV1,
     PARSE_EXPECT_DIV2, PARSE_DIV2,
-    PARSE_SPAN, PARSE_RATING, PARSE_TRAILER
+    PARSE_SPAN, PARSE_RATING, PARSE_TRAILER,
+    PARSE_NEXT_PAGE_LINK
 };
 
 void MovieSearchClient::ReplyFinished(QNetworkReply *reply)
@@ -73,6 +75,8 @@ void MovieSearchClient::ReplyFinished(QNetworkReply *reply)
     QString movie_theaters_url;
     QRegExp duration_pattern("((\\d+)hr )?(\\d+)min");
     QRegExp reviews_pattern("\\d+ review(s)?");
+    QString next_page_url;
+    int next_page_start;
     while (!xml.atEnd()) {
         QXmlStreamReader::TokenType token = xml.readNext();
         if (token == QXmlStreamReader::StartElement) {
@@ -88,6 +92,16 @@ void MovieSearchClient::ReplyFinished(QNetworkReply *reply)
                     movie_rating = -1.0;
                     movie_theaters_url = attr_href;
                     state = PARSE_MOVIE_LINK;
+                } else if (url.hasQueryItem("start")) {
+                    QString sort = url.queryItemValue("sort");
+                    QString start = url.queryItemValue("start");
+                    int istart = start.toInt();
+                    if (sort == "1" && istart > GetStartIndex()) {
+                        //std::cout << "next page LINK " << qPrintable(attr_href) << std::endl;
+                        next_page_url = attr_href;
+                        next_page_start = istart;
+                    }
+                    state = PARSE_NEXT_PAGE_LINK;
                 } else {
                     state = PARSE_HTML;
                 }
@@ -151,6 +165,8 @@ void MovieSearchClient::ReplyFinished(QNetworkReply *reply)
                     }
                 }
                 state = PARSE_HTML;
+            } else if (state == PARSE_NEXT_PAGE_LINK) {
+                state = PARSE_HTML;
             }
         } else if (token == QXmlStreamReader::Characters) {
             if (state == PARSE_MOVIE_LINK) {
@@ -178,9 +194,9 @@ void MovieSearchClient::ReplyFinished(QNetworkReply *reply)
         emit SearchFinished(GetSearchTaskId(), false);
         deleteLater();
     } else {
-        if (found > 0) {
+        if (!next_page_url.isEmpty()) {
             emit Reply(GetSearchTaskId(), true);
-            Search(GetStartIndex() + found);
+            SearchEncodedUrl(next_page_url, next_page_start);
         } else {
             emit Reply(GetSearchTaskId(), false);
             emit SearchFinished(GetSearchTaskId(), true);
index 82f8482..3172279 100644 (file)
@@ -82,6 +82,7 @@ enum State {
     PARSE_MOVIE_EXPECT_DIV3,
     PARSE_MOVIE_DIV3,
     PARSE_MOVIE_TIME,
+    PARSE_NEXT_PAGE_LINK
 };
 
 void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
@@ -97,6 +98,8 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
     QRegExp duration_pattern("((\\d+)hr )?(\\d+)min");
     QRegExp reviews_pattern("\\d+ review(s)?");
     QXmlStreamReader xml(reply);
+    QString next_page_url;
+    int next_page_start;
     while (!xml.atEnd()) {
         QXmlStreamReader::TokenType token = xml.readNext();
         if (token == QXmlStreamReader::StartElement) {
@@ -122,6 +125,16 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                     rating = -1.0;
                     schedule.clear();
                     state = PARSE_MOVIE_LINK;
+                } else if (url.hasQueryItem("start")) {
+                    QString sort = url.queryItemValue("sort");
+                    QString start = url.queryItemValue("start");
+                    int istart = start.toInt();
+                    if (sort == "0" && istart > GetStartIndex()) {
+                        //std::cout << "next page LINK " << qPrintable(attr_href) << std::endl;
+                        next_page_url = attr_href;
+                        next_page_start = istart;
+                    }
+                    state = PARSE_NEXT_PAGE_LINK;
                 } else {
                     state = PARSE_HTML;
                 }
@@ -215,6 +228,8 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
                     }
                 }
                 state = PARSE_HTML;
+            } else if (state == PARSE_NEXT_PAGE_LINK) {
+                state = PARSE_HTML;
             }
         } else if (token == QXmlStreamReader::Characters) {
             if (state == PARSE_MOVIE_LINK) {
@@ -251,15 +266,18 @@ void TheaterScheduleSearchClient::ReplyFinished(QNetworkReply *reply)
         emit Cancelled(GetSearchTaskId());
         emit SearchFinished(GetSearchTaskId(), false);
     } else {
-        // all movies are listed on one page
-        // no repetition of search with start parameter
-        if (!_date_urls.isEmpty()) {
+        if (!next_page_url.isEmpty()) {
             emit Reply(GetSearchTaskId(), true);
-            SearchNextDate();
+            SearchEncodedUrl(next_page_url, next_page_start);
         } else {
-            emit Reply(GetSearchTaskId(), false);
-            emit SearchFinished(GetSearchTaskId(), true);
-            deleteLater();
+            if (!_date_urls.isEmpty()) {
+                emit Reply(GetSearchTaskId(), true);
+                SearchNextDate();
+            } else {
+                emit Reply(GetSearchTaskId(), false);
+                emit SearchFinished(GetSearchTaskId(), true);
+                deleteLater();
+            }
         }
     }
     reply->deleteLater();
index f4f02dc..adfbdaa 100644 (file)
@@ -47,6 +47,7 @@ void TheaterSearchClient::CancelAllRunningSearchs()
 void TheaterSearchClient::Search(int start)
 {
     QUrl url("http://www.google.com/m/movies");
+    url.addQueryItem("action","chgloc");
     url.addQueryItem("loc", _town);
     url.addQueryItem("sort", QString::number(0));
     AbstractSearchClient::Search(url, start);
@@ -58,11 +59,13 @@ enum State {
     PARSE_THEATER_DIV,
     PARSE_THEATER_BR,
     PARSE_THEATER_SPAN,
-    PARSE_THEATER_PHONE
+    PARSE_THEATER_PHONE,
+    PARSE_NEXT_PAGE_LINK
 };
 
 void TheaterSearchClient::ReplyFinished(QNetworkReply *reply)
 {
+    //std::cout << qPrintable(QString::fromUtf8(reply->readAll().data())) << std::endl;
     QXmlStreamReader xml(reply);
     State state = PARSE_HTML;
     int found = 0;
@@ -70,6 +73,8 @@ void TheaterSearchClient::ReplyFinished(QNetworkReply *reply)
     QString theater_address;
     QString theater_movies_url;
     QString theater_phone;
+    QString next_page_url;
+    int next_page_start;
     while (!xml.atEnd()) {
         QXmlStreamReader::TokenType token = xml.readNext();
         if (token == QXmlStreamReader::StartElement) {
@@ -84,6 +89,16 @@ void TheaterSearchClient::ReplyFinished(QNetworkReply *reply)
                     theater_movies_url = attr_href;
                     theater_phone = "";
                     state = PARSE_THEATER_LINK;
+                } else if (url.hasQueryItem("start")) {
+                    QString sort = url.queryItemValue("sort");
+                    QString start = url.queryItemValue("start");
+                    int istart = start.toInt();
+                    if (sort == "0" && istart > GetStartIndex()) {
+                        //std::cout << "next page LINK " << qPrintable(attr_href) << std::endl;
+                        next_page_url = attr_href;
+                        next_page_start = istart;
+                    }
+                    state = PARSE_NEXT_PAGE_LINK;
                 } else {
                     state = PARSE_HTML;
                 }
@@ -127,6 +142,8 @@ void TheaterSearchClient::ReplyFinished(QNetworkReply *reply)
                     }
                 }
                 state = PARSE_HTML;
+            } else if (state == PARSE_NEXT_PAGE_LINK) {
+                state = PARSE_HTML;
             }
         } else if (token == QXmlStreamReader::Characters) {
             if (state == PARSE_THEATER_LINK) {
@@ -148,9 +165,9 @@ void TheaterSearchClient::ReplyFinished(QNetworkReply *reply)
         emit SearchFinished(GetSearchTaskId(), false);
         deleteLater();
     } else {
-        if (found > 0) {
+        if (!next_page_url.isEmpty()) {
             emit Reply(GetSearchTaskId(), true);
-            Search(GetStartIndex() + found);
+            SearchEncodedUrl(next_page_url, next_page_start);
         } else {
             emit Reply(GetSearchTaskId(), false);
             emit SearchFinished(GetSearchTaskId(), true);
index eb34058..e6df7f9 100644 (file)
@@ -157,7 +157,7 @@ FORMS    += \
     ui/locationdialog.ui \
     ui/moviewindow.ui \
     ui/contextdialog.ui \
-    ui/aboutdialog.ui
+    ui/aboutdialog.ui \
 
 RESOURCES += \
     resources.qrc
@@ -180,6 +180,12 @@ OTHER_FILES += \
     ../debian/optify \
     ../debian/compat
 
+maemo5 {
+    SOURCES += ui/optionsdialog.cpp
+    HEADERS += ui/optionsdialog.h
+    FORMS += ui/optionsdialog.ui
+}
+
 !isEmpty(TRANSLATIONS) {
     isEmpty(QMAKE_LRELEASE) {
         win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
index 234d259..6598244 100644 (file)
@@ -14,7 +14,7 @@
         <translation>MovieSchedule</translation>
     </message>
     <message utf8="true">
-        <location filename="../ui/aboutdialog.ui" line="109"/>
+        <location filename="../ui/aboutdialog.ui" line="107"/>
         <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
@@ -95,13 +95,11 @@ p, li { white-space: pre-wrap; }
         <translation>Telefonanruf fehlgeschlagen: Kein Anruf möglich.</translation>
     </message>
     <message>
-        <location filename="../control/actioncontroller.cpp" line="221"/>
         <source>Unable to search in web: communication bus not available.</source>
-        <translation>Websuche fehlgeschlagen: Kommunikation mit Browser nicht möglich.</translation>
+        <translation type="obsolete">Websuche fehlgeschlagen: Kommunikation mit Browser nicht möglich.</translation>
     </message>
     <message>
-        <location filename="../control/actioncontroller.cpp" line="226"/>
-        <location filename="../control/actioncontroller.cpp" line="232"/>
+        <location filename="../control/actioncontroller.cpp" line="220"/>
         <source>Unable to search in web: browser service not available.</source>
         <translation>Websuche fehlgeschlagen: Browser steht nicht zur Verfügung.</translation>
     </message>
@@ -155,17 +153,17 @@ p, li { white-space: pre-wrap; }
         <translation>Ort</translation>
     </message>
     <message>
-        <location filename="../ui/locationdialog.ui" line="49"/>
+        <location filename="../ui/locationdialog.ui" line="34"/>
         <source>Search Near</source>
         <translation>In der Nähe suchen</translation>
     </message>
     <message>
-        <location filename="../ui/locationdialog.ui" line="116"/>
+        <location filename="../ui/locationdialog.ui" line="100"/>
         <source>City</source>
         <translation>Stadt</translation>
     </message>
     <message>
-        <location filename="../ui/locationdialog.ui" line="149"/>
+        <location filename="../ui/locationdialog.ui" line="135"/>
         <source>Search</source>
         <translation>Suchen</translation>
     </message>
@@ -177,27 +175,27 @@ p, li { white-space: pre-wrap; }
         <translation type="obsolete">Netzwerk steht nicht zur Verfügung.</translation>
     </message>
     <message>
-        <location filename="../control/maincontroller.cpp" line="43"/>
+        <location filename="../control/maincontroller.cpp" line="44"/>
         <source>Unable to access network.</source>
         <translation>Netzwerk steht nicht zur Verfügung.</translation>
     </message>
     <message>
-        <location filename="../control/maincontroller.cpp" line="44"/>
+        <location filename="../control/maincontroller.cpp" line="45"/>
         <source>No theaters found near %1.</source>
         <translation>Keine Kinos in der Nähe von %1 gefunden.</translation>
     </message>
     <message>
-        <location filename="../control/maincontroller.cpp" line="45"/>
+        <location filename="../control/maincontroller.cpp" line="46"/>
         <source>No movies found near %1.</source>
         <translation>Keine Filme in der Nähe von %1 gefunden.</translation>
     </message>
     <message>
-        <location filename="../control/maincontroller.cpp" line="46"/>
+        <location filename="../control/maincontroller.cpp" line="47"/>
         <source>Error on fetching theaters.</source>
         <translation>Fehler beim Lesen der Kinoliste.</translation>
     </message>
     <message>
-        <location filename="../control/maincontroller.cpp" line="47"/>
+        <location filename="../control/maincontroller.cpp" line="48"/>
         <source>Error on fetching movies.</source>
         <translation>Fehler beim Lesen der Filmliste.</translation>
     </message>
@@ -206,13 +204,13 @@ p, li { white-space: pre-wrap; }
     <name>MainWindow</name>
     <message>
         <location filename="../ui/mainwindow.cpp" line="75"/>
-        <location filename="../ui/mainwindow.cpp" line="113"/>
+        <location filename="../ui/mainwindow.cpp" line="133"/>
         <source>Movies</source>
         <translation>Filme</translation>
     </message>
     <message>
         <location filename="../ui/mainwindow.cpp" line="76"/>
-        <location filename="../ui/mainwindow.cpp" line="105"/>
+        <location filename="../ui/mainwindow.cpp" line="125"/>
         <source>Theaters</source>
         <translation>Kinos</translation>
     </message>
@@ -223,22 +221,27 @@ p, li { white-space: pre-wrap; }
     </message>
     <message>
         <location filename="../ui/mainwindow.cpp" line="78"/>
+        <source>Options</source>
+        <translation>Einstellungen</translation>
+    </message>
+    <message>
+        <location filename="../ui/mainwindow.cpp" line="79"/>
         <source>About</source>
         <translation>Ãœber</translation>
     </message>
     <message>
-        <location filename="../ui/mainwindow.cpp" line="80"/>
+        <location filename="../ui/mainwindow.cpp" line="81"/>
         <source>Call By Phone</source>
         <translation>Kino anrufen</translation>
     </message>
     <message>
-        <location filename="../ui/mainwindow.cpp" line="81"/>
+        <location filename="../ui/mainwindow.cpp" line="82"/>
         <source>Find Route</source>
         <translation>Weg zum Kino suchen</translation>
     </message>
     <message>
-        <location filename="../ui/mainwindow.cpp" line="82"/>
-        <location filename="../ui/mainwindow.cpp" line="84"/>
+        <location filename="../ui/mainwindow.cpp" line="83"/>
+        <location filename="../ui/mainwindow.cpp" line="85"/>
         <source>Search In Web</source>
         <translation>Im Web suchen</translation>
     </message>
@@ -248,7 +251,7 @@ p, li { white-space: pre-wrap; }
     </message>
     <message>
         <location filename="../ui/mainwindow.ui" line="14"/>
-        <location filename="../ui/mainwindow.cpp" line="120"/>
+        <location filename="../ui/mainwindow.cpp" line="140"/>
         <source>MovieSchedule</source>
         <translation>MovieSchedule</translation>
     </message>
@@ -275,6 +278,39 @@ p, li { white-space: pre-wrap; }
     </message>
 </context>
 <context>
+    <name>OptionsDialog</name>
+    <message>
+        <location filename="../ui/optionsdialog.ui" line="14"/>
+        <source>Options</source>
+        <translation>Einstellungen</translation>
+    </message>
+    <message>
+        <location filename="../ui/optionsdialog.ui" line="22"/>
+        <source>Orientation</source>
+        <translation>Orientierung</translation>
+    </message>
+    <message>
+        <location filename="../ui/optionsdialog.ui" line="54"/>
+        <source>Done</source>
+        <translation>Fertig</translation>
+    </message>
+    <message>
+        <location filename="../ui/optionsdialog.cpp" line="32"/>
+        <source>Landscape</source>
+        <translation>Querformat</translation>
+    </message>
+    <message>
+        <location filename="../ui/optionsdialog.cpp" line="33"/>
+        <source>Portrait</source>
+        <translation>Hochformat</translation>
+    </message>
+    <message>
+        <location filename="../ui/optionsdialog.cpp" line="34"/>
+        <source>Automatic Rotation</source>
+        <translation>Automatische Drehung</translation>
+    </message>
+</context>
+<context>
     <name>QObject</name>
     <message>
         <location filename="../utils/timeutils.cpp" line="79"/>
index 63e5d6c..ae3f857 100644 (file)
 // along with MovieSchedule.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "aboutdialog.h"
+
 #include "ui_aboutdialog.h"
+#include "uiutils.h"
+
+#include <QDesktopWidget>
 
 AboutDialog::AboutDialog(QWidget *parent) :
     QDialog(parent),
@@ -33,9 +37,19 @@ AboutDialog::AboutDialog(QWidget *parent) :
     connect(ui->_button_box, SIGNAL(rejected()), this, SLOT(deleteLater()));
     connect(ui->_contact_button, SIGNAL(clicked()), this, SLOT(deleteLater()));
     connect(ui->_contact_button, SIGNAL(clicked()), this, SIGNAL(ContactAuthor()));
+    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(Rotate()));
+    Rotate();
 }
 
 AboutDialog::~AboutDialog()
 {
     delete ui;
 }
+
+void AboutDialog::Rotate()
+{
+    bool landscape = UiUtils::IsLandscape();
+    ui->_dialog_layout->setDirection(landscape ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom);
+    ui->_button_box->setOrientation(landscape ? Qt::Vertical : Qt::Horizontal);
+    adjustSize();
+}
index 0ea60e9..45ecf51 100644 (file)
@@ -36,6 +36,9 @@ public:
     Q_SIGNAL void ContactAuthor();
 
 private:
+    Q_SLOT void Rotate();
+
+private:
     Ui::AboutDialog *ui;
 };
 
index c3e37f2..f088196 100644 (file)
@@ -13,8 +13,8 @@
   <property name="windowTitle">
    <string>About</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0" colspan="2">
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
     <widget class="QLabel" name="_title">
      <property name="font">
       <font>
      </property>
     </widget>
    </item>
-   <item row="3" column="1" rowspan="4">
-    <widget class="QDialogButtonBox" name="_button_box">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel</set>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0" rowspan="6">
-    <widget class="QScrollArea" name="scrollArea">
-     <property name="horizontalScrollBarPolicy">
-      <enum>Qt::ScrollBarAlwaysOff</enum>
-     </property>
-     <property name="widgetResizable">
-      <bool>true</bool>
-     </property>
-     <widget class="QWidget" name="scrollAreaWidgetContents">
-      <property name="geometry">
-       <rect>
-        <x>0</x>
-        <y>0</y>
-        <width>311</width>
-        <height>434</height>
-       </rect>
-      </property>
-      <property name="palette">
-       <palette>
-        <active>
-         <colorrole role="Base">
-          <brush brushstyle="SolidPattern">
-           <color alpha="255">
-            <red>255</red>
-            <green>0</green>
-            <blue>0</blue>
-           </color>
-          </brush>
-         </colorrole>
-        </active>
-        <inactive>
-         <colorrole role="Base">
-          <brush brushstyle="SolidPattern">
-           <color alpha="255">
-            <red>255</red>
-            <green>0</green>
-            <blue>0</blue>
-           </color>
-          </brush>
-         </colorrole>
-        </inactive>
-        <disabled>
-         <colorrole role="Base">
-          <brush brushstyle="SolidPattern">
-           <color alpha="255">
-            <red>255</red>
-            <green>255</green>
-            <blue>255</blue>
-           </color>
-          </brush>
-         </colorrole>
-        </disabled>
-       </palette>
-      </property>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <widget class="QLabel" name="_about_text">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text">
-          <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+   <item>
+    <layout class="QHBoxLayout" name="_dialog_layout">
+     <item>
+      <widget class="QScrollArea" name="scrollArea">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>240</height>
+        </size>
+       </property>
+       <property name="horizontalScrollBarPolicy">
+        <enum>Qt::ScrollBarAlwaysOff</enum>
+       </property>
+       <property name="widgetResizable">
+        <bool>true</bool>
+       </property>
+       <widget class="QWidget" name="scrollAreaWidgetContents">
+        <property name="geometry">
+         <rect>
+          <x>0</x>
+          <y>0</y>
+          <width>307</width>
+          <height>457</height>
+         </rect>
+        </property>
+        <property name="palette">
+         <palette>
+          <active>
+           <colorrole role="Base">
+            <brush brushstyle="SolidPattern">
+             <color alpha="255">
+              <red>255</red>
+              <green>0</green>
+              <blue>0</blue>
+             </color>
+            </brush>
+           </colorrole>
+          </active>
+          <inactive>
+           <colorrole role="Base">
+            <brush brushstyle="SolidPattern">
+             <color alpha="255">
+              <red>255</red>
+              <green>0</green>
+              <blue>0</blue>
+             </color>
+            </brush>
+           </colorrole>
+          </inactive>
+          <disabled>
+           <colorrole role="Base">
+            <brush brushstyle="SolidPattern">
+             <color alpha="255">
+              <red>255</red>
+              <green>255</green>
+              <blue>255</blue>
+             </color>
+            </brush>
+           </colorrole>
+          </disabled>
+         </palette>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <widget class="QLabel" name="_about_text">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text">
+            <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
@@ -115,44 +113,60 @@ p, li { white-space: pre-wrap; }
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:18pt;&quot;&gt;Movies, Theaters, Schedules and GPS Locations use &lt;/span&gt;&lt;a href=&quot;http://www.google.com&quot;&gt;&lt;span style=&quot; font-size:18pt; font-weight:600; text-decoration: underline; color:#2eacff;&quot;&gt;Google&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:18pt;&quot;&gt; services.&lt;/span&gt;&lt;/p&gt;
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:18pt;&quot;&gt;&lt;/p&gt;
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt;&quot;&gt;This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+           </property>
+           <property name="textFormat">
+            <enum>Qt::RichText</enum>
+           </property>
+           <property name="scaledContents">
+            <bool>true</bool>
+           </property>
+           <property name="alignment">
+            <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+           </property>
+           <property name="wordWrap">
+            <bool>true</bool>
+           </property>
+           <property name="openExternalLinks">
+            <bool>true</bool>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QPushButton" name="_contact_button">
+         <property name="text">
+          <string>Contact</string>
          </property>
-         <property name="textFormat">
-          <enum>Qt::RichText</enum>
-         </property>
-         <property name="scaledContents">
-          <bool>true</bool>
+         <property name="autoDefault">
+          <bool>false</bool>
          </property>
-         <property name="alignment">
-          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="_done_button">
+         <property name="text">
+          <string>Done</string>
          </property>
-         <property name="wordWrap">
-          <bool>true</bool>
+        </widget>
+       </item>
+       <item>
+        <widget class="QDialogButtonBox" name="_button_box">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
          </property>
-         <property name="openExternalLinks">
-          <bool>true</bool>
+         <property name="standardButtons">
+          <set>QDialogButtonBox::Cancel</set>
          </property>
         </widget>
        </item>
       </layout>
-     </widget>
-    </widget>
-   </item>
-   <item row="1" column="1">
-    <widget class="QPushButton" name="_contact_button">
-     <property name="text">
-      <string>Contact</string>
-     </property>
-     <property name="autoDefault">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="1">
-    <widget class="QPushButton" name="_done_button">
-     <property name="text">
-      <string>Done</string>
-     </property>
-    </widget>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>
index b9c622b..2ae0e2c 100644 (file)
 // along with MovieSchedule.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "backgroundlabel.h"
+#include "uiutils.h"
 
 #include <QPainter>
 #include <QFont>
+#include <iostream>
 
 static const int MINIMUM_FONT_SIZE = 40;
 
@@ -50,9 +52,10 @@ void BackgroundLabel::paintEvent(QPaintEvent *event)
 
     QRect widget_rect = painter.worldTransform().inverted().mapRect(rect());
     if (_cached_label_font_size <= 0 || widget_rect != _cached_widget_rect) {
+        bool landscape = rect().width() >= rect().height();
         _cached_widget_rect = widget_rect;
         _cached_label_rect = widget_rect;
-        _cached_label_rect.setTop(_cached_label_rect.top() + 20);
+        _cached_label_rect.setTop(_cached_label_rect.top() + (landscape ? 20 : 10));
         _cached_label_alignment = Qt::AlignHCenter | Qt::AlignTop;
         int font_size = 80;
 
index 6122238..330f1da 100644 (file)
 #include "data/cinema.h"
 #include "data/movie.h"
 #include "utils/assertedlocker.h"
+#include "uiutils.h"
 
 #include <QLayoutItem>
+#include <QDesktopWidget>
 
 ContextDialog::ContextDialog(CinemaSchedule *cinema_schedule, QWidget *parent) :
         QDialog(parent),
@@ -40,6 +42,8 @@ ContextDialog::ContextDialog(CinemaSchedule *cinema_schedule, QWidget *parent) :
     connect(ui->find_route_to_theater, SIGNAL(clicked()), this, SLOT(FindRouteToTheater()));
     connect(ui->search_movie_in_web, SIGNAL(clicked()), this, SLOT(SearchMovieInWeb()));
     connect(ui->search_theater_in_web, SIGNAL(clicked()), this, SLOT(SearchTheaterInWeb()));
+    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(Rotate()));
+    Rotate();
 }
 
 ContextDialog::~ContextDialog()
@@ -98,10 +102,11 @@ void ContextDialog::removeAllWidgets()
 
 void ContextDialog::addWidget(QWidget *widget)
 {
+    bool landscape = UiUtils::IsLandscape();
     widget->setVisible(true);
     ui->gridLayout->addWidget(widget, _next_row, _next_column, 1, 1);
     ++_next_column;
-    if (_next_column > 1) {
+    if (_next_column > (landscape ? 1 : 0)) {
         ++_next_row;
         _next_column = 0;
     }
@@ -136,3 +141,10 @@ void ContextDialog::SearchTheaterInWeb()
     hide();
     emit SearchTheaterInWeb(_schedule_entry_key.GetCinemaKey());
 }
+
+void ContextDialog::Rotate()
+{
+    if (isVisible()) {
+        Show(_schedule_entry_key);
+    }
+}
index 29c724e..13c9f96 100644 (file)
@@ -61,6 +61,8 @@ private:
     Q_SLOT void SearchMovieInWeb();
     Q_SLOT void SearchTheaterInWeb();
 
+    Q_SLOT void Rotate();
+
 private:
     Ui::ContextDialog *ui;
     CinemaSchedule *_cinema_schedule;
index 095da2b..c05de0b 100644 (file)
@@ -17,6 +17,9 @@
 
 #include "locationdialog.h"
 #include "ui_locationdialog.h"
+#include "uiutils.h"
+
+#include <QDesktopWidget>
 
 LocationDialog::LocationDialog(QWidget *parent) :
     QDialog(parent),
@@ -39,6 +42,8 @@ LocationDialog::LocationDialog(QWidget *parent) :
     _location_buttons.append(ui->Location3);
     _location_buttons.append(ui->Location4);
     _location_buttons.append(ui->Location5);
+    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(Rotate()));
+    Rotate();
 }
 
 LocationDialog::~LocationDialog()
@@ -80,6 +85,7 @@ void LocationDialog::SetGPSEnabled(bool gps_enabled)
 
 void LocationDialog::show()
 {
+    bool landscape = UiUtils::IsLandscape();
     ui->gridLayout->removeWidget(ui->GPS);
     for (int i = 0; i < _location_buttons.size(); ++i) {
         ui->gridLayout->removeWidget(_location_buttons[i]);
@@ -89,12 +95,16 @@ void LocationDialog::show()
     if (ui->GPS->isEnabled()) {
         ui->gridLayout->addWidget(ui->GPS, row, column);
         ++column;
+        if (column > (landscape ? 1 : 0)) {
+            ++row;
+            column = 0;
+        }
     }
     for (int i = 0; i < _location_buttons.size(); ++i) {
         if (_location_buttons[i]->isEnabled()) {
             ui->gridLayout->addWidget(_location_buttons[i], row, column);
             ++column;
-            if (column > 1) {
+            if (column > (landscape ? 1 : 0)) {
                 ++row;
                 column = 0;
             }
@@ -175,3 +185,13 @@ void LocationDialog::changeEvent(QEvent *e)
         break;
     }
 }
+
+void LocationDialog::Rotate()
+{
+    bool landscape = UiUtils::IsLandscape();
+    ui->_search_layout->setDirection(landscape ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom);
+    ui->_button_box->setOrientation(landscape ? Qt::Vertical : Qt::Horizontal);
+    if (isVisible()) {
+        show();
+    }
+}
index f4d966e..4e297f5 100644 (file)
@@ -63,6 +63,8 @@ private:
     Q_SLOT void PreviousLocation4Clicked();
     Q_SLOT void PreviousLocation5Clicked();
 
+    Q_SLOT void Rotate();
+
 private:
     void PreviousLocationClicked(int i);
 
index 45a5d81..7b8133d 100644 (file)
    <bool>true</bool>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
-   <property name="spacing">
-    <number>4</number>
-   </property>
-   <property name="leftMargin">
-    <number>16</number>
-   </property>
-   <property name="topMargin">
-    <number>8</number>
-   </property>
-   <property name="rightMargin">
-    <number>16</number>
-   </property>
-   <property name="bottomMargin">
-    <number>8</number>
-   </property>
    <item>
     <layout class="QGridLayout" name="gridLayout">
      <property name="spacing">
     </layout>
    </item>
    <item>
-    <layout class="QHBoxLayout">
-     <property name="spacing">
-      <number>4</number>
-     </property>
-     <item>
-      <widget class="QLabel" name="CityLabel">
-       <property name="text">
-        <string>City</string>
-       </property>
-      </widget>
-     </item>
+    <layout class="QHBoxLayout" name="_search_layout">
      <item>
-      <widget class="QLineEdit" name="Location">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-      </widget>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QLabel" name="CityLabel">
+         <property name="text">
+          <string>City</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLineEdit" name="Location">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+        </widget>
+       </item>
+      </layout>
      </item>
      <item>
       <widget class="QDialogButtonBox" name="_button_box">
index d78aae4..d4e9293 100644 (file)
@@ -75,6 +75,7 @@ MainWindow::MainWindow(const CinemaSchedule *cinema_schedule, QWidget *parent) :
     ui->menubar->addAction(tr("Movies"), this, SIGNAL(SearchMovies()));
     ui->menubar->addAction(tr("Theaters"), this, SIGNAL(SearchTheaters()));
     ui->menubar->addAction(tr("Location"), this, SIGNAL(OpenLocationDialog()));
+    ui->menubar->addAction(tr("Options"), this, SIGNAL(OpenOptionsDialog()));
     ui->menubar->addAction(tr("About"), this, SIGNAL(OpenAboutDialog()));
     _theater_context_menu = new QMenu(this);
     _theater_phone_call = _theater_context_menu->addAction(tr("Call By Phone"), this, SLOT(CallTheaterByPhone()));
@@ -89,6 +90,25 @@ MainWindow::~MainWindow()
     delete ui;
 }
 
+void MainWindow::SetOrientation(Settings::OrientationMode orientation)
+{
+#ifdef Q_WS_MAEMO_5
+    switch (orientation) {
+    case Settings::LANDSCAPE:
+        setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+        break;
+    case Settings::PORTRAIT:
+        setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+        break;
+    case Settings::AUTOROTATION:
+        setAttribute(Qt::WA_Maemo5AutoOrientation, true);
+        break;
+    }
+#else
+    Q_UNUSED(orientation);
+#endif
+}
+
 void MainWindow::SetLocation(Location location)
 {
     _location = location;
index 8a6c3e7..b4220e7 100644 (file)
@@ -22,6 +22,7 @@
 #include "data/location.h"
 #include "data/cinemakey.h"
 #include "data/moviekey.h"
+#include "data/settings.h"
 
 #include <QModelIndex>
 
@@ -43,6 +44,7 @@ public:
     ~MainWindow();
 
 public:
+    Q_SLOT void SetOrientation(Settings::OrientationMode orientation);
     Q_SLOT void SetLocation(Location location);
     Q_SLOT void SetTheaterModel(QAbstractItemModel *);
     Q_SLOT void SetMovieModel(QAbstractItemModel *);
@@ -52,6 +54,7 @@ public:
     Q_SIGNAL void SearchTheaters();
     Q_SIGNAL void SearchMovies();
     Q_SIGNAL void OpenLocationDialog();
+    Q_SIGNAL void OpenOptionsDialog();
     Q_SIGNAL void OpenAboutDialog();
     Q_SIGNAL void TheaterSelected(CinemaKey);
     Q_SIGNAL void MovieSelected(MovieKey);
diff --git a/src/ui/optionsdialog.cpp b/src/ui/optionsdialog.cpp
new file mode 100644 (file)
index 0000000..085fac2
--- /dev/null
@@ -0,0 +1,98 @@
+#include "optionsdialog.h"
+#include "ui_optionsdialog.h"
+#include "uiutils.h"
+
+#include <QMaemo5ValueButton>
+#include <QMaemo5ListPickSelector>
+#include <QStandardItem>
+#include <QBoxLayout>
+#include <QDesktopWidget>
+
+static QStandardItem *CreateItem(const QString &label)
+{
+    QStandardItem *item = new QStandardItem(label);
+    item->setTextAlignment(Qt::AlignCenter);
+    item->setEditable(false);
+    return item;
+}
+
+OptionsDialog::OptionsDialog(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::OptionsDialog),
+    _rotation_model(new QStandardItemModel(0, 1, this)),
+    _rotation_selector(new QMaemo5ListPickSelector())
+{
+    ui->setupUi(this);
+    ui->_button_box->addButton(ui->_done_button, QDialogButtonBox::AcceptRole);
+    connect(ui->_button_box, SIGNAL(accepted()), this, SLOT(Accept()));
+    connect(ui->_button_box, SIGNAL(accepted()), this, SLOT(deleteLater()));
+    connect(ui->_button_box, SIGNAL(rejected()), this, SLOT(Cancel()));
+    connect(ui->_button_box, SIGNAL(rejected()), this, SLOT(deleteLater()));
+    ui->_rotation_combo_box->setValueLayout(QMaemo5ValueButton::ValueBesideText);
+    _rotation_model->appendRow(CreateItem(tr("Landscape")));
+    _rotation_model->appendRow(CreateItem(tr("Portrait")));
+    _rotation_model->appendRow(CreateItem(tr("Automatic Rotation")));
+    _rotation_selector->setModel(_rotation_model);
+    _rotation_selector->setCurrentIndex(0);
+    ui->_rotation_combo_box->setPickSelector(_rotation_selector);
+    connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(Rotate()));
+    Rotate();
+}
+
+OptionsDialog::~OptionsDialog()
+{
+    delete ui;
+}
+
+void OptionsDialog::SetSettings(const Settings &settings)
+{
+    _settings = settings;
+    int i = 0;
+    switch (_settings.GetOrientationMode()) {
+    case Settings::LANDSCAPE:
+        i = 0;
+        break;
+    case Settings::PORTRAIT:
+        i = 1;
+        break;
+    case Settings::AUTOROTATION:
+        i = 2;
+        break;
+    }
+    _rotation_selector->setCurrentIndex(i);
+}
+
+Settings OptionsDialog::GetSettings()
+{
+    switch (_rotation_selector->currentIndex()) {
+    case 0:
+        _settings.SetOrientationMode(Settings::LANDSCAPE);
+        break;
+    case 1:
+        _settings.SetOrientationMode(Settings::PORTRAIT);
+        break;
+    case 2:
+        _settings.SetOrientationMode(Settings::AUTOROTATION);
+        break;
+    }
+    return _settings;
+}
+
+void OptionsDialog::Accept()
+{
+    emit Accept(GetSettings());
+}
+
+void OptionsDialog::Cancel()
+{
+    emit Cancel(GetSettings());
+}
+
+void OptionsDialog::Rotate()
+{
+    bool landscape = UiUtils::IsLandscape();
+    ui->_dialog_layout->setDirection(landscape ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom);
+    ui->_button_box->setOrientation(landscape ? Qt::Vertical : Qt::Horizontal);
+    ui->_rotation_combo_box->setValueLayout(landscape ? QMaemo5ValueButton::ValueBesideText : QMaemo5ValueButton::ValueUnderText);
+    adjustSize();
+}
diff --git a/src/ui/optionsdialog.h b/src/ui/optionsdialog.h
new file mode 100644 (file)
index 0000000..00536a4
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef OPTIONSDIALOG_H
+#define OPTIONSDIALOG_H
+
+#include "data/settings.h"
+
+#include <QDialog>
+
+class QStandardItemModel;
+class QMaemo5ListPickSelector;
+
+namespace Ui {
+    class OptionsDialog;
+}
+
+class OptionsDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit OptionsDialog(QWidget *parent = 0);
+    ~OptionsDialog();
+
+    void SetSettings(const Settings &settings);
+    Settings GetSettings();
+
+public:
+    Q_SIGNAL void Accept(const Settings &);
+    Q_SIGNAL void Cancel(const Settings &);
+
+private:
+    Q_SLOT void Accept();
+    Q_SLOT void Cancel();
+    Q_SLOT void Rotate();
+
+private:
+    Ui::OptionsDialog *ui;
+    QStandardItemModel *_rotation_model;
+    QMaemo5ListPickSelector *_rotation_selector;
+    Settings _settings;
+};
+
+#endif // OPTIONSDIALOG_H
diff --git a/src/ui/optionsdialog.ui b/src/ui/optionsdialog.ui
new file mode 100644 (file)
index 0000000..827ffc5
--- /dev/null
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>OptionsDialog</class>
+ <widget class="QDialog" name="OptionsDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>131</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Options</string>
+  </property>
+  <layout class="QHBoxLayout" name="_dialog_layout">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <widget class="QMaemo5ValueButton" name="_rotation_combo_box">
+       <property name="text">
+        <string>Orientation</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticalSpacer">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>0</width>
+         <height>0</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="_button_box">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QPushButton" name="_done_button">
+     <property name="text">
+      <string>Done</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QMaemo5ValueButton</class>
+   <extends>QPushButton</extends>
+   <header location="global">QMaemo5ValueButton</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>_button_box</sender>
+   <signal>accepted()</signal>
+   <receiver>OptionsDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>_button_box</sender>
+   <signal>rejected()</signal>
+   <receiver>OptionsDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 82e6a90..9319814 100644 (file)
@@ -64,6 +64,7 @@ QColor StyleUtils::GetScheduleTimeColor(const QPalette &palette, QTime time)
 {
     Q_UNUSED(time);
 #ifdef Q_WS_MAEMO_5
+    Q_UNUSED(palette);
     return QMaemo5Style::standardColor("DefaultTextColor");
 #else
     QColor color = palette.color(QPalette::WindowText);
@@ -75,6 +76,7 @@ QColor StyleUtils::GetDayTextColor(const QPalette &palette, const QDate &date)
 {
     Q_UNUSED(date);
 #ifdef Q_WS_MAEMO_5
+    Q_UNUSED(palette);
     QColor color = QMaemo5Style::standardColor("DefaultTextColor");
     color.setAlpha(160);
     return color;
@@ -89,6 +91,7 @@ QColor StyleUtils::GetDayBackgroundColor(const QPalette &palette, const QDate &d
 {
     Q_UNUSED(date);
 #ifdef Q_WS_MAEMO_5
+    Q_UNUSED(palette);
     QColor color = QMaemo5Style::standardColor("DefaultTextColor");
     color.setAlpha(48);
     return color;
index 95a5748..ddee5b9 100644 (file)
@@ -23,6 +23,9 @@
 #include <QMessageBox>
 #endif
 
+#include <QApplication>
+#include <QDesktopWidget>
+
 UiUtils::UiUtils()
 {
 }
@@ -44,3 +47,14 @@ void UiUtils::ShowError(const QString &errormsg)
     QMessageBox::critical(0, "Movie-Schedule", errormsg);
 #endif
 }
+
+bool UiUtils::IsLandscape()
+{
+    QRect screenGeometry = QApplication::desktop()->screenGeometry();
+    return (screenGeometry.width() > screenGeometry.height());
+}
+
+bool UiUtils::IsPortrait()
+{
+    return !IsLandscape();
+}
index 4254036..ee8f594 100644 (file)
@@ -31,6 +31,9 @@ public:
 
     static void ShowError(const QString &errormsg);
 
+    static bool IsLandscape();
+
+    static bool IsPortrait();
 };
 
 #endif // UIUTILS_H