applets/notifications: Work the speed chart out from the job's own record
Original commit message(s)
- applets/notifications: Work the speed chart out from the job's own record
The chart collected its own readings from the moment it was created, and it is created with the list entry for the job. Anything the copy did before then went unrecorded, so the line was drawn climbing out of the corner up to the first reading, showing a copy accelerating from a standstill it had never been at. Closing the popup threw the readings away, and opening it again started the same climb over.
Have the job note how far it has got and when, from its first bytes onward, and work the chart out from that. Two readings give the speed between them, the bytes they are apart over the time they are apart, and where that belongs across the width, their bytes against the total. The chart then draws the same for a job watched from the start, has something true to draw for one that was not, keeps what it has when the popup closes, and has a speed to draw even for a job that never says how fast it is going.
Both are worked out when they are asked for rather than as the readings arrive, because the total moves: a copy does not know how much it is about to copy until it has finished looking, KIO revises it again for a single file whose size only the transfer knows, and upward for a download that outgrows what it claimed. Readings already placed across a width that no longer holds would be stranded, while readings kept as they were taken are simply placed again.
The stretch before the first reading is drawn at the speed that reading was found at, which is what removes the climb. Once there are more readings than the chart has points to show them in, every second one is dropped.
A job is allowed to be further along than the total it announced, and to announce a total of only a few bytes, so where a reading belongs is worked out and held within the width of the chart rather than taken at its word.
Reason for the change
cc #150
Fixes #154 (closed)