Tags are only shown if they are identical for all edited dives

Linus Torvalds torvalds at linux-foundation.org
Wed Apr 10 11:39:45 PDT 2013


On Wed, Apr 10, 2013 at 10:58 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
>
>> I would expect the following logic: If I select several dives for editing
>> then changed properties are set for all of them.
>
> No, we definitely don't want that and that is not what we have
> implemented for all the other features that you can edit across multiple
> dives.

Actually, it should be pretty easy to just treat the properties as
individual booleans (which they largely are), and use the standard "if
it has changed in the master dive, _and_ the old state matched in the
current dive, then change in the current dive". And you don't have to
do it bit-by-bit, you can do it with a bitmask the whole word at a
time.

So in sae_dive_info_changes(), we'd have something like:

  unsigned old = info->tags;
  unsigned new = info->tags;
  unsigned changed = new & master->tags;
  unsigned matched = ~(dive->tags ^ master->tags);

where "changed" now has the mask of bits that were changed by the
user, and "matched" is the mask of bits that matched in this dive and
the master dive.

You now have two options:

   /* If the changed bits are all a subset of the matched bits (there
are no changed bits that didn't match), we change them all */
   if (!(changed & ~matched))
       dive->tags ^= changed;

*or* you just say "we'll change any individual bit that used to match":

    dive->tags ^= changed & matched;

and both of these are perfectly logical, and actually match our
behavior in other fields.

Hmm?

With the above, you can allow editing of tags, and select multiple
dives (that might not match exactly), and then set the "lake" tag for
all of them, for example.

              Linus


More information about the subsurface mailing list