mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Picture handling: switch to stronger typed offset
Also change the on file XML to be even easier to read by making it a duration as well (which gets us '32:34 min' instead of un-typed seconds). This is backwards compatible, it will happily read what was written with the previous commit). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b0983d9d13
commit
a26719c541
5 changed files with 9 additions and 9 deletions
4
dive.c
4
dive.c
|
@ -2290,7 +2290,7 @@ void dive_create_picture(struct dive *d, char *filename, int shift_time)
|
|||
p->filename = filename;
|
||||
picture_load_exif_data(p, ×tamp);
|
||||
if (timestamp)
|
||||
p->offset = timestamp - d->when + shift_time;
|
||||
p->offset.seconds = timestamp - d->when + shift_time;
|
||||
dive_add_picture(d, p);
|
||||
dive_set_geodata_from_picture(d, p);
|
||||
}
|
||||
|
@ -2299,7 +2299,7 @@ void dive_add_picture(struct dive *d, struct picture *newpic)
|
|||
{
|
||||
struct picture **pic_ptr = &d->picture_list;
|
||||
/* let's keep the list sorted by time */
|
||||
while( *pic_ptr && (*pic_ptr)->offset < newpic->offset )
|
||||
while( *pic_ptr && (*pic_ptr)->offset.seconds < newpic->offset.seconds )
|
||||
pic_ptr = &(*pic_ptr)->next;
|
||||
newpic->next = *pic_ptr;
|
||||
*pic_ptr = newpic;
|
||||
|
|
2
dive.h
2
dive.h
|
@ -289,7 +289,7 @@ struct dive {
|
|||
/* picture list and methods related to dive picture handling */
|
||||
struct picture {
|
||||
char *filename;
|
||||
int32_t offset;
|
||||
duration_t offset;
|
||||
degrees_t latitude;
|
||||
degrees_t longitude;
|
||||
struct picture *next;
|
||||
|
|
|
@ -1084,7 +1084,7 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
|
|||
|
||||
if (MATCH("filename.picture", utf8_string, &cur_picture->filename))
|
||||
return;
|
||||
if (MATCH("offset.picture", get_index, &cur_picture->offset))
|
||||
if (MATCH("offset.picture", sampletime, &cur_picture->offset))
|
||||
return;
|
||||
if (MATCH("gps.picture", gps_picture_location, cur_picture))
|
||||
return;
|
||||
|
@ -1295,7 +1295,7 @@ static void event_end(void)
|
|||
if (cur_event.type == 123) {
|
||||
struct picture *pic = alloc_picture();
|
||||
pic->filename = strdup(cur_event.name);
|
||||
pic->offset = cur_event.time.seconds;
|
||||
pic->offset = cur_event.time;
|
||||
dive_add_picture(cur_dive, pic);
|
||||
} else {
|
||||
add_event(dc, cur_event.time.seconds,
|
||||
|
|
|
@ -1307,13 +1307,13 @@ void ProfileWidget2::plotPictures()
|
|||
struct picture *pic = (struct picture*) m->index(i,1).data(Qt::UserRole).value<void*>();
|
||||
// it's a correct picture, but doesn't have a timestamp: only show on the widget near the
|
||||
// information area.
|
||||
if (!pic->offset)
|
||||
if (!pic->offset.seconds)
|
||||
continue;
|
||||
DivePictureItem *item = new DivePictureItem();
|
||||
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>());
|
||||
// let's put the picture at the correct time, but at a fixed "depth" on the profile
|
||||
// not sure this is ideal, but it seems to look right.
|
||||
x = timeAxis->posAtValue(pic->offset);
|
||||
x = timeAxis->posAtValue(pic->offset.seconds);
|
||||
if (i == 0)
|
||||
y = 10;
|
||||
else
|
||||
|
|
|
@ -333,8 +333,8 @@ static void save_picture(struct membuffer *b, struct picture *pic)
|
|||
put_string(b, " <picture filename='");
|
||||
put_string(b, pic->filename);
|
||||
put_string(b, "'");
|
||||
if (pic->offset)
|
||||
put_format(b, " offset='%d'", pic->offset);
|
||||
if (pic->offset.seconds)
|
||||
put_format(b, " offset='%u:%02u min'", FRACTION(pic->offset.seconds, 60));
|
||||
if (pic->latitude.udeg || pic->longitude.udeg) {
|
||||
put_degrees(b, pic->latitude, " gps='", " ");
|
||||
put_degrees(b, pic->longitude, "", "'");
|
||||
|
|
Loading…
Add table
Reference in a new issue