mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-30 07:00:41 +00:00
Add proper encoding decoding for keyed objects
This commit is contained in:
parent
15a65bce26
commit
21e8018d7d
1 changed files with 61 additions and 34 deletions
|
@ -385,43 +385,49 @@
|
||||||
|
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
// These names do not stick to convention. Usually it would be
|
if ([coder allowsKeyedCoding])
|
||||||
// NS* or NSTreeController* so they must be overriden in
|
|
||||||
// GSXib5KeyedUnarchver.
|
|
||||||
if ([coder containsValueForKey: @"NSTreeContentChildrenKey"])
|
|
||||||
{
|
{
|
||||||
[self setChildrenKeyPath:
|
// These names do not stick to convention. Usually it would be
|
||||||
[coder decodeObjectForKey: @"NSTreeContentChildrenKey"]];
|
// NS* or NSTreeController* so they must be overriden in
|
||||||
}
|
// GSXib5KeyedUnarchver.
|
||||||
if ([coder containsValueForKey: @"NSTreeContentCountKey"])
|
if ([coder containsValueForKey: @"NSTreeContentChildrenKey"])
|
||||||
{
|
{
|
||||||
[self setChildrenKeyPath:
|
[self setChildrenKeyPath:
|
||||||
[coder decodeObjectForKey: @"NSTreeContentCountKey"]];
|
[coder decodeObjectForKey: @"NSTreeContentChildrenKey"]];
|
||||||
}
|
}
|
||||||
if ([coder containsValueForKey: @"NSTreeContentLeafKey"])
|
if ([coder containsValueForKey: @"NSTreeContentCountKey"])
|
||||||
{
|
{
|
||||||
[self setChildrenKeyPath:
|
[self setChildrenKeyPath:
|
||||||
[coder decodeObjectForKey: @"NSTreeContentLeafKey"]];
|
[coder decodeObjectForKey: @"NSTreeContentCountKey"]];
|
||||||
}
|
}
|
||||||
|
if ([coder containsValueForKey: @"NSTreeContentLeafKey"])
|
||||||
|
{
|
||||||
|
[self setChildrenKeyPath:
|
||||||
|
[coder decodeObjectForKey: @"NSTreeContentLeafKey"]];
|
||||||
|
}
|
||||||
|
|
||||||
// Since we don't inherit from NSArrayController these are decoded here
|
// Since we don't inherit from NSArrayController these are decoded here
|
||||||
// as well.
|
// as well.
|
||||||
if ([coder containsValueForKey: @"NSAvoidsEmptySelection"])
|
if ([coder containsValueForKey: @"NSAvoidsEmptySelection"])
|
||||||
{
|
{
|
||||||
[self setAvoidsEmptySelection:
|
[self setAvoidsEmptySelection:
|
||||||
[coder decodeBoolForKey: @"NSAvoidsEmptySelection"]];
|
[coder decodeBoolForKey: @"NSAvoidsEmptySelection"]];
|
||||||
}
|
}
|
||||||
if ([coder containsValueForKey: @"NSPreservesSelection"])
|
if ([coder containsValueForKey: @"NSPreservesSelection"])
|
||||||
{
|
{
|
||||||
[self setPreservesSelection:
|
[self setPreservesSelection:
|
||||||
[coder decodeBoolForKey: @"NSPreservesSelection"]];
|
[coder decodeBoolForKey: @"NSPreservesSelection"]];
|
||||||
}
|
}
|
||||||
if ([coder containsValueForKey: @"NSSelectsInsertedObjects"])
|
if ([coder containsValueForKey: @"NSSelectsInsertedObjects"])
|
||||||
{
|
{
|
||||||
[self setSelectsInsertedObjects:
|
[self setSelectsInsertedObjects:
|
||||||
[coder decodeBoolForKey: @"NSSelectsInsertedObjects"]];
|
[coder decodeBoolForKey: @"NSSelectsInsertedObjects"]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -429,6 +435,27 @@
|
||||||
- (void) encodeWithCoder: (NSCoder*)coder
|
- (void) encodeWithCoder: (NSCoder*)coder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: coder];
|
[super encodeWithCoder: coder];
|
||||||
|
|
||||||
|
if ([coder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
[coder encodeObject: _childrenKeyPath
|
||||||
|
forKey: @"NSTreeContentChildrenKey"];
|
||||||
|
[coder encodeObject: _countKeyPath
|
||||||
|
forKey: @"NSTreeContentCountKey"];
|
||||||
|
[coder encodeObject: _leafKeyPath
|
||||||
|
forKey: @"NSTreeContentLeafKey"];
|
||||||
|
|
||||||
|
|
||||||
|
[coder encodeBool: _avoidsEmptySelection
|
||||||
|
forKey: @"NSAvoidsEmptySelection"];
|
||||||
|
[coder encodeBool: _preservesSelection
|
||||||
|
forKey: @"NSPreservesSelection"];
|
||||||
|
[coder encodeBool: _selectsInsertedObjects
|
||||||
|
forKey: @"NSSelectsInsertedObjects"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone*)zone
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
|
|
Loading…
Reference in a new issue