pull request

Dirk Hohndel dirk at hohndel.org
Mon Aug 20 09:27:43 PDT 2012


Linus Torvalds <torvalds at linux-foundation.org> writes:

> On Mon, Aug 20, 2012 at 9:11 AM, Linus Torvalds
> <torvalds at linux-foundation.org> wrote:
>>
>> Yes. This is one of those ambiguous cases ("should the group entry be
>> selected when *some* of the children are selected, and some are
>> unselected"), and the reason I picked the solution I picked is that it
>> gets the common case of "single contiguous selection-by-date" right.
>
> Btw, it isn't the *only* choice that gets it right. I could have made
> the rule be:
>
>  - Select the group entry *if* the whole group is selected *or* if the
> first entry of that group *and* the last entry of the previous group
> are selected.
>
> There are possibly other similar rules that migth make sense.
>
> But the "select the group entry by default iff the first dive in the
> group is selected" was the simplest algorithm that gets the expected
> pattern.
>
> Btw, this particular ambiguity only comes up when moving from non-date
> view to date view. Normally, the group entry selection is under
> control of the user (with the caveat that collapsing a group with
> active dives *has* to select the group entry, and that entry will stay
> selected when expanding it again), and I tried to make sure that all
> our selection rules did minimal possible "damage" to user selections.
>
> So if somebody selects all dives under a group, but doesn't select the
> group entry itself, that's fine. The selection logic doesn't try to
> second-guess what the user wants. It's only when it moves from
> non-grouped view to grouped view that it simply has to make *some*
> choice.

So you are trying to treat the group entry as if it was a dive. I want
to treat it decidedly special - as you keep pointing out the "treat it
almost as if it was a dive" thing has several truely ambigous
situations.

Here's the definition of semantic that I propose. Can you poke a hole in
it?

group collapsed:

IFF any dive in a group is selected, group entry is selected

selecting unselected group entry causes all dives under it to be selected

selecting selected group entry causes all dives under it to be unselected


group expanded:

IFF all dives in a group are selected, group entry is selected

selecting unselected group entry causes all dives under it to be selected

selecting selected group entry causes all dives under it to be unselected


This appears to be deterministic, we should be able to maintain this
through collapse / expand events and through sort function changes.

It has one odd side effect that I can think of - if we have expanded the
group and select a range of dives that includes partial groups, then the
last group has it's group entry unselected (which may look slightly odd
at first). But while visually odd at first it is completely consistent
behavior. And as far as I can tell you always have the same outcome of
selected rows, regardless how you end up picking the dives that are
selected.

/D



More information about the subsurface mailing list