[PATCH] Show sample time in the mouseover.

Dirk Hohndel dirk at hohndel.org
Tue Sep 17 04:39:04 UTC 2013


On Tue, 2013-09-17 at 08:26 +0200, Anton Lundin wrote:
> This is really nice to have when looking at specific coutures of a dive
> or events. This needs hooking up in the preferences dialog.

Do you want to try to hook it up? It's surprisingly easy to do that in
Qt (I've done a few minor changes myself already).

Also, for the very common patter of "x/N, x%N" we have a macro called
FRACTION, so that snprintf could be written as 

snprintf(buf, bufsize, _("%s\nT:%d:%02d"), buf2, FRACTION(entry->sec, 60));

which I find easier to read.

Would you mind doing both of these changes (really, the Qt part doesn't
hurt... and Tomaz will be so thrilled to have someone else poke at Qt
:-)

/D

> Signed-off-by: Anton Lundin <glance at acc.umu.se>
> ---
>  pref.h    | 1 +
>  profile.c | 4 ++++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/pref.h b/pref.h
> index f722dd1..8098c27 100644
> --- a/pref.h
> +++ b/pref.h
> @@ -47,6 +47,7 @@ struct preferences {
>  	short show_invalid;
>  	short unit_system;
>  	struct units units;
> +	short show_time;
>  };
>  enum unit_system_values { METRIC, IMPERIAL, PERSONALIZE };
>  
> diff --git a/profile.c b/profile.c
> index e0e9bad..b2d0d8a 100644
> --- a/profile.c
> +++ b/profile.c
> @@ -1224,6 +1224,10 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
>  
>  	depthvalue = get_depth_units(depth, NULL, &depth_unit);
>  	snprintf(buf, bufsize, _("D:%.1f %s"), depthvalue, depth_unit);
> +	if (prefs.show_time) {
> +		memcpy(buf2, buf, bufsize);
> +		snprintf(buf, bufsize, _("%s\nT:%d:%02d"), buf2, entry->sec/60, entry->sec%60);
> +	}
>  	if (pressure) {
>  		pressurevalue = get_pressure_units(pressure, &pressure_unit);
>  		memcpy(buf2, buf, bufsize);




More information about the subsurface mailing list