mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-03 14:40:43 +00:00
Add child index, add category that properly prepends the index to the NSIndexPath
This commit is contained in:
parent
8059cdadd0
commit
13f86ebfa9
2 changed files with 30 additions and 2 deletions
|
@ -1740,6 +1740,34 @@ Also returns the child index relative to this parent. */
|
||||||
|
|
||||||
@end /* implementation of NSOutlineView */
|
@end /* implementation of NSOutlineView */
|
||||||
|
|
||||||
|
@interface NSIndexPath (__NSOutlineView__Prepend__)
|
||||||
|
|
||||||
|
- (NSIndexPath *) _indexPathByPrependingIndex: (NSUInteger)index;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSIndexPath (__NSOutlineView__Prepend__)
|
||||||
|
|
||||||
|
- (NSIndexPath *) _indexPathByPrependingIndex: (NSUInteger)index
|
||||||
|
{
|
||||||
|
NSIndexPath *newPath = [NSIndexPath indexPathWithIndex: index];
|
||||||
|
NSUInteger length = [self length];
|
||||||
|
NSUInteger indexes[length + 1];
|
||||||
|
NSUInteger i = 0;
|
||||||
|
|
||||||
|
[self getIndexes: indexes];
|
||||||
|
|
||||||
|
// Iterate over existing indexes...
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
newPath = [newPath indexPathByAddingIndex: indexes[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return newPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSOutlineView (NotificationRequestMethods)
|
@implementation NSOutlineView (NotificationRequestMethods)
|
||||||
|
|
||||||
- (NSIndexPath *) _findIndexPathForItem: (id)item
|
- (NSIndexPath *) _findIndexPathForItem: (id)item
|
||||||
|
@ -1764,7 +1792,7 @@ Also returns the child index relative to this parent. */
|
||||||
|
|
||||||
if (foundPath != nil)
|
if (foundPath != nil)
|
||||||
{
|
{
|
||||||
return [foundPath indexPathByAddingIndex: index];
|
return [foundPath _indexPathByPrependingIndex: index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
lastIndex = [indexPath indexAtPosition: length - 1];
|
lastIndex = [indexPath indexAtPosition: length - 1];
|
||||||
[children insertObject: object atIndex: lastIndex];
|
[children insertObject: object atIndex: lastIndex + 1];
|
||||||
|
|
||||||
[self rearrangeObjects];
|
[self rearrangeObjects];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue