Re: Reordering a table insanity
Re: Reordering a table insanity
- Subject: Re: Reordering a table insanity
- From: Quincey Morris <email@hidden>
- Date: Wed, 28 Nov 2012 18:18:49 -0800
On Nov 28, 2012, at 17:24 , Graham Cox <email@hidden> wrote:
> Ideally I'd like the following method signature:
>
> - (void) moveStuffFrom:(NSIndexSet*) source to:(NSIndexSet*) destination;
>
> which internally calls [ [undoManager prepare...] moveStuffFrom:destination to:source]; to set up undo.
>
> this implies that the algorithm must by symmetric or universal, in that the two index sets supply all the necessary information, without any extra direction parameters (though that could be derived).
If I understand you correctly, then it can't be done without an extra parameter. The "coordinate system" of the indexes in *both* index sets is that of the original list. When you're undoing, all of the indexes in both index sets are "wrong" for the current state of the table. Even if the "right" indexes could be recovered, which I'm not sure about but perhaps, you still wouldn't know whether to do the recovery.
Descending to hand-waving, I suspect that the only way to do it with 2 parameters would be for each to be an array of indexes (not a set). Conceptually, each array would need to contain an entry for every row in the table, and each array would specify the rearrangement for one direction. (In practice, you could trim the beginning and end of each array to omit contiguous row indexes that aren't actually moving.)
That's as far as I've got with it.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden