On Nov 28, 2012, at 16:35 , Graham Cox <[email protected]> wrote:
> So the question now is, can the table reordering with animation be made to > work in the undo case? I think it's doable. Note that the existing code is simple because there's no need to adjust the indexes in the selectionIndexes set at each step of the loop -- the indexes for the unmoved rows are still valid, even though the indexes for moved rows aren't. To go in the opposite direction, it seems like you'd need to take the destination set (a clump of contiguous indexes), and divide it into two parts -- the indexes that need to go somewhere below the clump and the indexes that need to go somewhere above the clump. In order to avoid adjusting indexes, you'd then need to do the loops in the *opposite* order: from lowest to highest in the "below" subset and from highest to lowest in the "above" subset. I *think* that at each iteration, you'd be putting back the row that would make the index in the next iteration valid again. That means you'd need a different though similar twelve lines of code to implement the reverse algorithm. That in turn means you'd need to know which direction you were going, so there might need to be a 3rd "direction" parameter (or it might be clear from the context, depending on how your undo works). Does that sound plausible? _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
