Skip to content

Commit

Permalink
Fixed 9292 earlier/later
Browse files Browse the repository at this point in the history
Bump version.
  • Loading branch information
poetaster committed Sep 24, 2022
1 parent 8094532 commit cee8da3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 116 deletions.
2 changes: 1 addition & 1 deletion fahrplan2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
APP_NAME = Fahrplan

# Define Version
VERSION = 2.0.42-1
VERSION = 2.0.43-1

#CONFIG+= openrepos

Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-fahrplan2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Name: harbour-fahrplan2
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Public transportation application
Version: 2.0.42
Version: 2.0.43
Release: 1
Group: Location/Location Adaptation
License: GPLv2
Expand Down
137 changes: 23 additions & 114 deletions src/parser/parser_ninetwo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ void ParserNinetwo::searchJourney(const Station &departureStation,
const ParserAbstract::Mode mode,
int trainrestrictions)
{
lastsearch.from=departureStation;
lastsearch.to=arrivalStation;
lastsearch.restrictions=trainrestrictions;
lastsearch.via=viaStation;
lastsearch.from = departureStation;
lastsearch.to = arrivalStation;
lastsearch.restrictions = trainrestrictions;
lastsearch.via = viaStation;
lastsearch.lastOption = dateTime;
lastsearch.mode = mode;

QUrl url(BASE_URL "/journeyadvice");

Expand Down Expand Up @@ -202,14 +204,24 @@ void ParserNinetwo::searchJourney(const Station &departureStation,
void ParserNinetwo::searchJourneyLater()
{

searchJourney(lastsearch.from, lastsearch.via, lastsearch.to, lastsearch.lastOption, Departure , lastsearch.restrictions);
QDateTime time = lastsearch.lastOption.addSecs(30*60);
searchJourney(lastsearch.from, lastsearch.via, lastsearch.to , time, lastsearch.mode, lastsearch.restrictions);

}

void ParserNinetwo::searchJourneyEarlier()
{
QDateTime time = lastsearch.firstOption.addSecs(-30*60);
searchJourney(lastsearch.from, lastsearch.via, lastsearch.to,time, Departure, lastsearch.restrictions);
QDateTime time = lastsearch.lastOption.addSecs(-30*60);
searchJourney(lastsearch.from, lastsearch.via, lastsearch.to , time, lastsearch.mode, lastsearch.restrictions);
}
void ParserNinetwo::parseSearchLaterJourney(QNetworkReply *)
{

}

void ParserNinetwo::parseSearchEarlierJourney(QNetworkReply *)
{

}

void ParserNinetwo::getJourneyDetails(const QString &id)
Expand Down Expand Up @@ -317,7 +329,7 @@ void ParserNinetwo::parseStationsByName(QNetworkReply *networkReply)
{
qDebug() << __PRETTY_FUNCTION__ << "PARSING STATIONS";
QByteArray allData = networkReply->readAll();
qDebug() << "REPLY:>>>>>>>>>>>>\n" << allData;
//qDebug() << "REPLY:>>>>>>>>>>>>\n" << allData;

QVariantMap doc = parseJson(allData);
if (doc.isEmpty()) {
Expand Down Expand Up @@ -417,24 +429,11 @@ void ParserNinetwo::parseSearchJourney(QNetworkReply *networkReply)
emit journeyResult(resultList.release());
}

void ParserNinetwo::parseSearchLaterJourney(QNetworkReply *)
{

}

void ParserNinetwo::parseSearchEarlierJourney(QNetworkReply *)
{

}

void ParserNinetwo::parseJourneyDetails(QNetworkReply *)
{
//should never happen
}




JourneyResultItem * ParserNinetwo::parseJourneyJson(const QString& jsonData)
{
// this really helps :)
Expand Down Expand Up @@ -546,7 +545,9 @@ JourneyResultItem * ParserNinetwo::parseJourneyJson(const QString& jsonData)
qWarning() << "arrivalmap2: " << arrivalTimeWalk.toString("hh:mm");
item->setArrivalDateTime(arrivalTimeWalk);
} else {
item->setArrivalDateTime(arrivalTime);
item->setArrivalDateTime(arrivalTime);
qWarning() << "dep: " << departureTime.toString("hh:mm");
qWarning() << "arr: " << arrivalTime.toString("hh:mm");
}

item->setArrivalStation(arrivalStation);
Expand Down Expand Up @@ -594,11 +595,8 @@ JourneyResultItem * ParserNinetwo::parseJourneyJson(const QString& jsonData)
response->setTrainType(tTypes);

}

QDateTime minutesBegin;
QDateTime minutesEnd;


// we must calculate duration without first or final leg being a walk.
if (detail->getItem(detail->itemcount()-1)->train().startsWith("walk") ) {
// this is fixed above
Expand Down Expand Up @@ -739,92 +737,3 @@ JourneyResultItem* ParserNinetwo::parseJourneyICS(QString const & ics)

return item.release();
}

// Parse info about one journey option. Store detailed info about segments for later use.
/*
QList<JourneyDetailResultItem*> ParserNinetwo::parseJourneySegments(const QVariantMap &journeyData)
{
QList<JourneyDetailResultItem*> results;
QVariantList segments = journeyData.value("LegList").toMap().value("Leg").toList();
foreach (QVariant segmentData, segments)
{
const QVariantMap& segment = segmentData.toMap();
JourneyDetailResultItem* resultItem = new JourneyDetailResultItem;
// Departure
QVariantMap departure = segment.value("Origin").toMap();
resultItem->setDepartureStation(departure.value("name").toString());
QDateTime departureDateTime;
departureDateTime.setDate(QDate::fromString(departure.value("date").toString(), "yyyy-MM-dd"));
departureDateTime.setTime(QTime::fromString(departure.value("time").toString(), "hh:mm:ss"));
resultItem->setDepartureDateTime(departureDateTime);
// Arrival
QVariantMap arrival = segment.value("Destination").toMap();
resultItem->setArrivalStation(arrival.value("name").toString());
QDateTime arrivalDateTime;
arrivalDateTime.setDate(QDate::fromString(arrival.value("date").toString(), "yyyy-MM-dd"));
arrivalDateTime.setTime(QTime::fromString(arrival.value("time").toString(), "hh:mm:ss"));
resultItem->setArrivalDateTime(arrivalDateTime);
QStringList info;
// Notes
if (segment.contains("Notes")) {
QVariantList notes = segment.value("Notes").toMap().value("Note").toList();
foreach (QVariant note, notes) {
QString hafasDescription(hafasAttribute(note.toMap().value("key").toString()));
if (hafasDescription.isEmpty())
info.append(note.toMap().value("value").toString());
else
info.append(hafasDescription);
}
}
// Means of transportation
QString distance;
QString operatorInfo;
QString transportMainType = segment.value("type").toString();
if (transportMainType == "WALK" || transportMainType == "TRSF") {
distance = segment.value("dist").toString();
resultItem->setInternalData1("WALK");
resultItem->setTrain(tr("Walk"));
} else if (transportMainType == "JNY") {
QVariantMap product = segment.value("Product").toMap();
QString transportType = transportMode(product.value("catOutS").toString(),
product.value("catOutL").toString());
QString lineNumber = product.value("num").toString();
if (!lineNumber.isEmpty())
transportType += " " + lineNumber;
QString operatorName = product.value("operator").toString();
QString operatorURL = product.value("operatorUrl").toString();
if (!operatorName.isEmpty()) {
if (operatorURL.isEmpty())
operatorInfo = operatorName;
else
operatorInfo = "<a href=\"" + operatorURL + "\">" + operatorName + "</a>";
}
resultItem->setTrain(transportType);
} else {
while (!results.isEmpty())
delete results.takeFirst();
delete resultItem;
break;
}
if (!distance.isEmpty())
resultItem->setInfo(distance + " m");
else if (!operatorInfo.isEmpty() && !info.isEmpty())
resultItem->setInfo(operatorInfo + "<br/>" + info.join(", "));
else if (!operatorInfo.isEmpty())
resultItem->setInfo(operatorInfo);
else if (!info.isEmpty())
resultItem->setInfo(info.join(", "));
resultItem->setDirection(segment.value("direction").toString());
results.append(resultItem);
}
return results;
}
*/

0 comments on commit cee8da3

Please sign in to comment.