Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track filter fix #363

Merged
merged 2 commits into from
May 29, 2019
Merged

Track filter fix #363

merged 2 commits into from
May 29, 2019

Conversation

tsteven4
Copy link
Collaborator

@tsteven4 tsteven4 commented May 23, 2019

Fix compatibility for track filter GUI<->CLI.

Add a week unit for the track filter move option,
in addition to the existing day, hour, minute and second units.

Allow combination of units for track filter move option, e.g.
1w2d3h4m-5s = 1 week + 2 days + 3 hours + 4 minutes - 5 seconds.
This matches historical use, and is expected by the GUI.

Add the week unit to the GUI track filter ui.

Change the limits on the track filter move specs:
week: +/-10000 (unit didn't exit before)
day,hour,minute,second: +/- 100000 (+/-2000 for day before, +/-100 for others before).

This resolves #357.
This resolves #358.

Add a week unit for the track filter move option,
in addition to the existing day, hour, minute and second units.

Allow combination of units for track filter move option, e.g.
1w2d3h4m-5s = 1 week + 2 days + 3 hours + 4 minutes - 5 seconds.
This matches historical use, and is expected by the GUI.

Add the week unit to the GUI track filter ui.

Change the limits on the track filter move specs:
week: +/-10000 (unit didn't exit before)
day,hour,minute,second: +/- 100000 (+/-2000 for day before, +/-100 on others).

This resolves GPSBabel#357.
This resolves GPSBabel#358.

QRegularExpression re("^([+-]?\\d+)([dhms])$", QRegularExpression::CaseInsensitiveOption);
QRegularExpression re("^([+-]?\\d+)([wdhms])(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?(?:([+-]?\\d+)([wdhms]))?$", QRegularExpression::CaseInsensitiveOption);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't read this regex now, but can it ever match a unit into match[0] but not have a value so that the offset below will walk off the end of match? Maybe track,move=+1024 (no units)

Otherwise, lgtm. Thanx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so.

  1. match.captured(0) is the whole match. we don't use 0.
  2. we use pairs of match with indexes 1 & 2, 3 & 4, ...
  3. since the first index in a pair is < the lastCapturedIndex we are guaranteed that
    the second index in a pair is <= lastCapturedIndex. So even if the re can capture matches not in pairs (ignoring 0) we won't index off the end.
  4. the re is anchored by ^ and $ so we shouldn't get partial matches (with a few caveats).
  5. the re is build of units of ([+-]?\d+)([wdhms]). The first group has to find one or more digits due to the + quantifier, and the second group has to match one of the supplied characters due to the implicit quantifier of 1. So we either get 0 matches or 2 from each of these units.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GUI Track Move Filter limits move time to 2000 days. Track Move Filter doesn't work from GUI
2 participants