mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Override addObject(s):, removeObject(s): update _contentDictionary
This commit is contained in:
parent
99e25244af
commit
08fc055321
2 changed files with 53 additions and 11 deletions
|
@ -78,7 +78,7 @@ extern "C" {
|
|||
APPKIT_EXPORT_CLASS
|
||||
@interface NSDictionaryController : NSArrayController
|
||||
{
|
||||
NSDictionary *_contentDictionary;
|
||||
NSMutableDictionary *_contentDictionary;
|
||||
NSString *_initialKey;
|
||||
id _initialValue;
|
||||
NSArray *_includedKeys;
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
|
||||
- (void) _setup
|
||||
{
|
||||
_contentDictionary = [[NSDictionary alloc] init];
|
||||
_contentDictionary = [[NSMutableDictionary alloc] init];
|
||||
_includedKeys = [[NSArray alloc] init];
|
||||
_excludedKeys = [[NSArray alloc] init];
|
||||
_initialKey = @"key";
|
||||
|
@ -196,7 +196,7 @@
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_contentDicrionary);
|
||||
RELEASE(_contentDictionary);
|
||||
RELEASE(_includedKeys);
|
||||
RELEASE(_excludedKeys);
|
||||
RELEASE(_initialKey);
|
||||
|
@ -204,6 +204,52 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) addObject: (id)obj
|
||||
{
|
||||
NSString *k = [obj key];
|
||||
NSString *v = [obj value];
|
||||
|
||||
[super addObject: obj];
|
||||
[_contentDictionary setObject: v
|
||||
forKey: k];
|
||||
}
|
||||
|
||||
- (void) addObjects: (NSArray *)array
|
||||
{
|
||||
[super addObjects: array];
|
||||
|
||||
FOR_IN(NSDictionaryControllerKeyValuePair*, kvp, array)
|
||||
{
|
||||
NSString *k = [kvp key];
|
||||
NSString *v = [kvp value];
|
||||
|
||||
[_contentDictionary setObject: v
|
||||
forKey: k];
|
||||
}
|
||||
END_FOR_IN(array);
|
||||
}
|
||||
|
||||
- (void) removeObject: (id)obj
|
||||
{
|
||||
NSString *k = [obj key];
|
||||
|
||||
[super removeObject: obj];
|
||||
[_contentDictionary removeObjectForKey: k];
|
||||
}
|
||||
|
||||
- (void) removeObjects: (NSArray *)array
|
||||
{
|
||||
[super addObjects: array];
|
||||
|
||||
FOR_IN(NSDictionaryControllerKeyValuePair*, kvp, array)
|
||||
{
|
||||
NSString *k = [kvp key];
|
||||
|
||||
[_contentDictionary removeObjectForKey: k];
|
||||
}
|
||||
END_FOR_IN(array);
|
||||
}
|
||||
|
||||
- (NSDictionaryControllerKeyValuePair *) newObject
|
||||
{
|
||||
NSDictionaryControllerKeyValuePair *kvp = [[NSDictionaryControllerKeyValuePair alloc] init];
|
||||
|
@ -265,8 +311,10 @@
|
|||
|
||||
- (void) setExcludedKeys: (NSArray *)excludedKeys
|
||||
{
|
||||
[self willChangeValueForKey: NSContentBinding];
|
||||
ASSIGNCOPY(_excludedKeys, excludedKeys);
|
||||
[self rearrangeObjects];
|
||||
[self setContent: _contentDictionary];
|
||||
[self didChangeValueForKey: NSContentBinding];
|
||||
}
|
||||
|
||||
- (NSDictionary *) localizedKeyDictionary
|
||||
|
@ -297,16 +345,10 @@
|
|||
|
||||
- (void) setContent: (id)content
|
||||
{
|
||||
ASSIGN(_contentDictionary, content);
|
||||
[super setContent: [self _buildArray: content]];
|
||||
}
|
||||
|
||||
- (NSArray *) arrangeObjects: (NSArray *)obj
|
||||
{
|
||||
NSArray *array = [self _buildArray: obj];
|
||||
NSArray *result = [super arrangeObjects: obj];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) observeValueForKeyPath: (NSString*)aPath
|
||||
ofObject: (id)anObject
|
||||
change: (NSDictionary*)aChange
|
||||
|
|
Loading…
Reference in a new issue