@@ -28,7 +28,7 @@ THE SOFTWARE.
28
28
#include " arrivalsproxymodel.h"
29
29
#include " journeyprogressmodel.h"
30
30
31
- // custom search algorithms because Qt algorithms are not sufficent and labmbdas or bind is not available in C++03 to use std algorithms
31
+ // custom search algorithms because Qt algorithms are not sufficent and lambdas or bind is not available in C++03 to use std algorithms
32
32
namespace {
33
33
typedef QList<QPair<QString,double > > StopList;
34
34
StopList::const_iterator find (StopList::const_iterator begin,StopList::const_iterator end, const QString& val) {
@@ -50,11 +50,14 @@ StopList::iterator find(StopList::iterator begin,StopList::iterator end, const Q
50
50
// any other case it just returns end() iterator
51
51
StopList::const_iterator findNextStop (StopList::const_iterator begin,StopList::const_iterator end, double val, double time) {
52
52
for (StopList::const_iterator iter = begin; iter != end; ++iter) {
53
- if (iter->second - time > 0 && iter->second < val) return iter;
53
+ if ((iter->second - time > 0 )) {
54
+ // if the original time is in the past and this isn't, then this is still better match,
55
+ // otherwise only return if it is smaller then given value
56
+ if (val - time < 0 || iter->second < val) { return iter; }
57
+ }
54
58
}
55
59
return end;
56
60
}
57
-
58
61
}// end of unnamed namespace
59
62
60
63
JourneyProgressContainer::JourneyProgressContainer (QObject* parent) : QObject(parent),
@@ -110,7 +113,6 @@ QString JourneyProgressContainer::getNextStop() const {
110
113
}
111
114
else return smallestSoFar->first ;
112
115
}
113
-
114
116
else {
115
117
return QString (" NOT AVAILABLE" );
116
118
}
0 commit comments