mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Add method _keyPathForValueBinding to encapsulate the code for getting the path
This commit is contained in:
parent
4b380ab272
commit
27d57fe5eb
2 changed files with 19 additions and 11 deletions
|
@ -152,6 +152,7 @@ static NSImage *unexpandable = nil;
|
|||
@interface NSTableColumn (Private)
|
||||
- (void) _applyBindingsToCell: (NSCell *)cell
|
||||
atRow: (NSInteger)index;
|
||||
- (NSString *) _keyPathForValueBinding;
|
||||
@end
|
||||
|
||||
@interface NSTreeNode (Private_NSOutlineView)
|
||||
|
@ -2020,20 +2021,11 @@ Also returns the child index relative to this parent. */
|
|||
row: (NSInteger) index
|
||||
{
|
||||
id result = nil;
|
||||
NSString *keyPath = [tb _keyPathForValueBinding];
|
||||
|
||||
// If we have content binding the data source is used only
|
||||
// like a delegate
|
||||
NSDictionary *info = [GSKeyValueBinding infoForBinding: NSValueBinding forObject: tb];
|
||||
if (info != nil)
|
||||
if (keyPath != nil)
|
||||
{
|
||||
id theItem = [_items objectAtIndex: index];
|
||||
NSString *ikp = [info objectForKey: NSObservedKeyPathKey];
|
||||
NSUInteger location = [ikp rangeOfString: @"."].location;
|
||||
NSString *keyPath = (location == NSNotFound ? ikp : [ikp substringFromIndex: location + 1]);
|
||||
|
||||
// Here we are getting the last part of the keyPath since elsewhere in this class
|
||||
// we are recursively storing the contents of arrangedObjects (for example) to
|
||||
// display it as an outline in _loadDictionaryStartingWith:atLevel:.
|
||||
result = [theItem valueForKeyPath: keyPath];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -654,6 +654,22 @@ to YES. */
|
|||
return [_headerCell stringValue];
|
||||
}
|
||||
|
||||
- (NSString *) _keyPathForValueBinding
|
||||
{
|
||||
NSString *keyPath = nil;
|
||||
NSDictionary *info = [GSKeyValueBinding infoForBinding: NSValueBinding
|
||||
forObject: self];
|
||||
if (info != nil)
|
||||
{
|
||||
NSString *ikp = [info objectForKey: NSObservedKeyPathKey];
|
||||
NSUInteger location = [ikp rangeOfString: @"."].location;
|
||||
|
||||
keyPath = (location == NSNotFound ? ikp : [ikp substringFromIndex: location + 1]);
|
||||
}
|
||||
|
||||
return keyPath;
|
||||
}
|
||||
|
||||
- (void) _applyBindingsToCell: (NSCell *)cell
|
||||
atRow: (NSInteger)index
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue