projects
/
quandoparte
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0a3a281
)
Handle error pages in the schedule model
author
Luciano Montanaro
<mikelima@cirulla.net>
Sat, 4 Feb 2012 21:02:30 +0000
(22:02 +0100)
committer
Luciano Montanaro
<mikelima@cirulla.net>
Sat, 4 Feb 2012 21:02:30 +0000
(22:02 +0100)
application/stationschedulemodel.cpp
patch
|
blob
|
history
diff --git
a/application/stationschedulemodel.cpp
b/application/stationschedulemodel.cpp
index
6f13b79
..
7343b30
100644
(file)
--- a/
application/stationschedulemodel.cpp
+++ b/
application/stationschedulemodel.cpp
@@
-212,6
+212,20
@@
void StationScheduleModel::parse(const QByteArray &htmlReply, const QUrl &baseUr
page.mainFrame()->setContent(htmlReply, "text/html", baseUrl);
QWebElement doc = page.mainFrame()->documentElement();
page.mainFrame()->setContent(htmlReply, "text/html", baseUrl);
QWebElement doc = page.mainFrame()->documentElement();
+ // Check if the page is reporting an error before parsing it
+ QWebElement errorElement = doc.findFirst("span.errore");
+ if (!errorElement.isNull()) {
+ m_departureSchedules.clear();
+ m_arrivalSchedules.clear();
+ QString errorText = errorElement.toPlainText().trimmed();
+ if (errorText == "localita' non trovata") {
+ setError(tr("Unknown station"));
+ } else {
+ setError(tr("Unknown error"));
+ }
+ qDebug() << "error:" << error();
+ return;
+ }
// Find the first div
QWebElement current = doc.findFirst("div");
// Find the first div
QWebElement current = doc.findFirst("div");