connect(stationView, SIGNAL(stationListSelectTriggered()),
SLOT(showStationSelectView()));
+ connect(stationView, SIGNAL(showingArrivalsChanged(bool)),
+ SLOT(setShowingArrivals(bool)));
readSettings();
#if defined(Q_WS_S60)
}
}
+App::~App()
+{
+ saveSettings();
+}
+
void App::downloadFinished(void)
{
disconnect(stationQueryReply, SIGNAL(finished()),
settings.value("ShowingArrivals", showingArrivals);
settings.value("CheckInterval", checkingInterval);
}
+
+void App::setShowingArrivals(bool showArrivals)
+{
+ showingArrivals = showArrivals;
+}
debian/README \
debian/rules \
quandoparte.desktop \
- icons/quandoparte.png
+ icons/quandoparte.png \
+ resources/quandoparte.css \
+ resources/arrivals.css \
+ resources/departures.css
unix:!symbian {
maemo5 {
} else {
desktopfile.path = /usr/share/applications
}
- INSTALLS += desktopfile
+ INSTALLS += desktopfile cssfile
}
unix:!symbian {
+ css.files = resources/$${TARGET}.css resources/arrivals.css resources/departures.css
+ css.path = /usr/share/apps/$${TARGET}/css
icon48.files = icons/48x48/$${TARGET}.png
icon64.files = icons/64x64/$${TARGET}.png
icon48.path = /usr/share/icons/hicolor/48x48/apps
icon64.path = /usr/share/icons/hicolor/64x64/apps
INSTALLS += icon48
INSTALLS += icon64
+ INSTALLS += css
}
#include <QDebug>
#include <QMenu>
#include <QMenuBar>
+#include <QWebElement>
+#include <QWebFrame>
#include <QWebView>
StationView::StationView(QWidget *parent) :
menuBar->addAction(menu->menuAction());
setMenuBar(menuBar);
view->setTextSizeMultiplier(2.0);
+ view->setBackgroundRole(QPalette::Window);
connect(showAboutAction, SIGNAL(triggered()), this, SIGNAL(aboutTriggered()));
connect(showSettingsAction, SIGNAL(triggered()), this, SIGNAL(settingsTriggered()));
connect(showStationListSelectAction, SIGNAL(triggered()), this, SIGNAL(stationListSelectTriggered()));
+ connect(viewSelectionGroup, SIGNAL(triggered(QAction *)), this, SLOT(viewSelectionGroupTriggered(QAction *)));
setCentralWidget(view);
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow);
+ setAttribute(Qt::WA_Maemo5AutoOrientation);
#endif
}
void StationView::updateView(const QByteArray &page)
{
qDebug() << page;
+ updateCss();
view->setContent(page, "text/html", theBaseUrl);
+ QWebElement doc = view->page()->mainFrame()->documentElement();
+
+ // Find the first div
+ QWebElement current = doc.findFirst("div");
+
+ qDebug() << "skipping to the departures";
+ // Skip to the first div of class corpocentrale, which contains the first
+ // departure-related contents
+ while (!current.classes().contains("corpocentrale")) {
+ current = current.nextSibling();
+ qDebug() << "skipping to the next element";
+ if (current.isNull())
+ break;
+ }
+ // Mark every div as a departure class element; the next corpocentrale
+ // marks the start of the arrivals section
+ qDebug() << "marking departures";
+ do {
+ current.addClass("departures");
+ current = current.nextSibling();
+ qDebug() << "marking as departures";
+ if (current.isNull())
+ break;
+ } while (!current.classes().contains("corpocentrale"));
+ // Mark everything as an arrival, until reaching the footer
+ while (!current.classes().contains("footer")) {
+ current.addClass("arrivals");
+ current = current.nextSibling();
+ qDebug() << "marking as arrival";
+ if (current.isNull())
+ break;
+ }
+}
+
+void StationView::viewSelectionGroupTriggered(QAction *action)
+{
+ if (action == showArrivalsAction) {
+ emit showingArrivalsChanged(true);
+ } else {
+ emit showingArrivalsChanged(false);
+ }
+ updateCss();
+}
+
+void StationView::updateCss(void)
+{
+ QByteArray styleSheet("data:text/css;charset=utf-8,base64,");
+ QByteArray styleSheetText = QByteArray(
+ "body {\n"
+ "-webkit-user-select: none ! important;\n"
+ "background-color: black ! important;\n"
+ "color: white ! important;}\n"
+ ".testata_red {visibility: hidden ! important;}\n"
+ "#footer {\n"
+ "visibility: hidden ! important;}\n");
+ styleSheet += styleSheetText.toBase64();
+ qDebug() << styleSheet;
+ //QUrl cssUrl = QUrl::fromEncoded(styleSheet);
+ QUrl cssUrl;
+ if (showArrivalsAction->isChecked()) {
+ cssUrl.setEncodedUrl("file:///usr/share/apps/quandoparte/css/arrivals.css");
+ } else {
+ cssUrl.setEncodedUrl("file:///usr/share/apps/quandoparte/css/departures.css");
+ }
+ QWebSettings::globalSettings()->setUserStyleSheetUrl(cssUrl);
}