mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Improve adding a child, also do whitespace-cleanup
This commit is contained in:
parent
13f86ebfa9
commit
300a84c493
2 changed files with 25 additions and 21 deletions
|
@ -222,7 +222,7 @@ static NSImage *unexpandable = nil;
|
|||
- (void) dealloc
|
||||
{
|
||||
[GSKeyValueBinding unbindAllForObject: self];
|
||||
|
||||
|
||||
RELEASE(_items);
|
||||
RELEASE(_expandedItems);
|
||||
RELEASE(_selectedIndexPaths);
|
||||
|
@ -804,7 +804,7 @@ static NSImage *unexpandable = nil;
|
|||
*/
|
||||
_dataSource_editable = YES;
|
||||
}
|
||||
|
||||
|
||||
/* We do *not* retain the dataSource, it's like a delegate */
|
||||
_dataSource = anObject;
|
||||
[self tile];
|
||||
|
@ -1047,14 +1047,14 @@ static NSImage *unexpandable = nil;
|
|||
{
|
||||
GSKeyValueBinding *theBinding = nil;
|
||||
|
||||
theBinding = [GSKeyValueBinding getBinding: NSContentBinding
|
||||
theBinding = [GSKeyValueBinding getBinding: NSContentBinding
|
||||
forObject: self];
|
||||
|
||||
|
||||
if (_dataSource == nil && theBinding == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_viewBased)
|
||||
{
|
||||
[self _drawCellViewRow: rowIndex
|
||||
|
@ -1754,7 +1754,7 @@ Also returns the child index relative to this parent. */
|
|||
NSUInteger length = [self length];
|
||||
NSUInteger indexes[length + 1];
|
||||
NSUInteger i = 0;
|
||||
|
||||
|
||||
[self getIndexes: indexes];
|
||||
|
||||
// Iterate over existing indexes...
|
||||
|
@ -1780,7 +1780,7 @@ Also returns the child index relative to this parent. */
|
|||
for (NSInteger index = 0; index < childCount; index++)
|
||||
{
|
||||
id childItem = [children objectAtIndex: index];
|
||||
|
||||
|
||||
if (childItem == item)
|
||||
{
|
||||
return [NSIndexPath indexPathWithIndex: index];
|
||||
|
@ -1831,7 +1831,7 @@ Also returns the child index relative to this parent. */
|
|||
|
||||
index = [_selectedRows indexGreaterThanIndex: index];
|
||||
}
|
||||
|
||||
|
||||
// According to tests and observation, if none of the
|
||||
// objects respond to and we can't get the indices from
|
||||
// the above calculation, then we need return the
|
||||
|
@ -1859,7 +1859,7 @@ Also returns the child index relative to this parent. */
|
|||
{
|
||||
NSTableColumn *tb = [_tableColumns objectAtIndex: 0];
|
||||
GSKeyValueBinding *theBinding;
|
||||
|
||||
|
||||
theBinding = [GSKeyValueBinding getBinding: NSValueBinding
|
||||
forObject: tb];
|
||||
|
||||
|
@ -2103,7 +2103,7 @@ Also returns the child index relative to this parent. */
|
|||
@selector(outlineView:setObjectValue:forTableColumn:byItem:)])
|
||||
{
|
||||
id item = [self itemAtRow: index];
|
||||
|
||||
|
||||
[_dataSource outlineView: self
|
||||
setObjectValue: value
|
||||
forTableColumn: tb
|
||||
|
@ -2286,7 +2286,7 @@ Also returns the child index relative to this parent. */
|
|||
{
|
||||
NSNumber *countValue = [sitem valueForKeyPath: countKeyPath];
|
||||
num = [countValue integerValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@
|
|||
NSMutableArray *children = [_arranged_objects mutableChildNodes];
|
||||
NSUInteger lastIndex = 0;
|
||||
id obj = nil;
|
||||
|
||||
|
||||
for (pos = 0; pos < length - 1; pos++)
|
||||
{
|
||||
NSUInteger i = [indexPath indexAtPosition: pos];
|
||||
|
@ -335,21 +335,25 @@
|
|||
if ([self canAddChild]
|
||||
&& [self countKeyPath] == nil)
|
||||
{
|
||||
NSUInteger length = [indexPath length];
|
||||
NSUInteger length = [indexPath length] - 1;
|
||||
NSUInteger pos = 0;
|
||||
NSMutableArray *children = [_arranged_objects mutableChildNodes];
|
||||
NSUInteger lastIndex = 0;
|
||||
|
||||
for (pos = 0; pos < length - 1; pos++)
|
||||
for (pos = 0; pos < length; pos++)
|
||||
{
|
||||
NSUInteger i = [indexPath indexAtPosition: pos];
|
||||
id node = [children objectAtIndex: i];
|
||||
|
||||
|
||||
children = [node valueForKeyPath: _childrenKeyPath];
|
||||
}
|
||||
|
||||
lastIndex = [indexPath indexAtPosition: length - 1];
|
||||
[children insertObject: object atIndex: lastIndex + 1];
|
||||
|
||||
lastIndex = [indexPath indexAtPosition: length];
|
||||
|
||||
id child = [children objectAtIndex: lastIndex];
|
||||
|
||||
children = [child valueForKeyPath: _childrenKeyPath];
|
||||
[children addObject: object];
|
||||
|
||||
[self rearrangeObjects];
|
||||
}
|
||||
|
@ -359,7 +363,7 @@
|
|||
{
|
||||
if ([self canAddChild]
|
||||
&& [self countKeyPath] == nil)
|
||||
{
|
||||
{
|
||||
if ([objects count] != [indexPaths count])
|
||||
{
|
||||
return;
|
||||
|
@ -367,11 +371,11 @@
|
|||
else
|
||||
{
|
||||
NSUInteger i = 0;
|
||||
|
||||
|
||||
FOR_IN(id, object, objects)
|
||||
{
|
||||
NSIndexPath *indexPath = [indexPaths objectAtIndex: i];
|
||||
|
||||
|
||||
[self insertObject: object atArrangedObjectIndexPath: indexPath];
|
||||
i++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue