Skip to content

Commit 834929d

Browse files
committed
The Lazy Data Source seems to all work now, but tests are still incomplete. Many bugs in it were fixed by these changes:
• Explained in comments how -[ContentOutlineView outlineView:toolTipForCell:rect:tableColumn:item:mouseLocation:] overrides -[BkmxDocViewController tableView:toolTipForCell:rect:tableColumn:row:mouseLocation:] • The noteChangedChildrenForStark: kludgey chain of drill-down methods has now been replaced by SSYManagedTreeChildrenChangedNotification. • Added declaration of -[NSOutlineView itemAtRow:] to BkmxOutlineView.h to fix nonsense incorrect Xcode warnings that NSOutlineView does not implement this. • More rework to the -checkAllProxies: mechanisms. • Reworked how proxies are created. • No longer leaks m_proxies and m_rootProxies • Added kludge so that ContentOutlineView scrolls to the top now (-1 row - 1 point) in NSTableView (Scrolling) • Reworked ContentProxy to handle dirty values in general instead of just dirty children, and replaced method -ensureChildren method -ensureDeeplyAndRegardlessly: • Combined -setIndex: and -setParent: custom setters from Stark class into SSYManagedTreeObject. Previously, the latter did not work because it was overridden by the former! • Officially removed 0[Stark stealthilySetIndex:], which has not been used in recent commits.
1 parent 4d6260c commit 834929d

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed

SSYManagedTreeObject.h

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
extern NSString* const constKeyChildren ;
66
extern NSString* const constKeyParent ;
77

8+
extern NSString* const SSYManagedTreeObjectKey ;
9+
extern NSString* const SSYManagedTreeChildrenChangedNotification ;
10+
811
/*!
912
@brief A subclass of SSYManagedObject which has 'parent'
1013
'children' and 'index' properties, so that it can be used as

SSYManagedTreeObject.m

+42-17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
NSString* const constKeyChildren = @"children" ;
77
NSString* const constKeyParent = @"parent" ;
8+
9+
NSString* const SSYManagedTreeObjectKey = @"SSYManagedTreeObjectKey" ;
10+
NSString* const SSYManagedTreeChildrenChangedNotification = @"SSYManagedTreeChildrenChangedNotification" ;
11+
812
/*
913
See note on DropboxFalseStart below
1014
// NodeId was going to be needed because, when adding a new bookmark
@@ -113,7 +117,7 @@ - (void)handleWillSetNewChildren:(NSSet*)newValue {
113117
/* Testing indicates that this method can be invoked, and children can by
114118
mutated, without invoking -setChildren: or any other setter. In other words,
115119
this method seems to be an independent value-changer. Therefore, the following
116-
override is necessary. It was added in BookMacster 1.12.7. */
120+
override *is* necessary. It was added in BookMacster 1.12.7. */
117121
- (NSMutableSet*)mutableSetValueForKey:(NSString *)key {
118122
if ([key isEqualToString:constKeyChildren]) {
119123
[self forgetCachedChildrenOrdered];
@@ -184,16 +188,25 @@ - (void)setIndex:(NSNumber*)newValue {
184188
// In order to avoid registering undo and unnecessarily dirtying the dot,
185189
// we only do the overwrite if there was a substantive change.
186190
// (Note that current or new value can be nil.)
187-
if ([NSObject isEqualHandlesNilObject1:[self index]
191+
if (![NSObject isEqualHandlesNilObject1:[self index]
188192
object2:newValue]) {
189-
return ;
190-
}
193+
[self postWillSetNewValue:newValue
194+
forKey:constKeyIndex] ;
195+
[self willChangeValueForKey:constKeyIndex] ;
196+
[self setPrimitiveIndex:newValue] ;
197+
[self didChangeValueForKey:constKeyIndex] ;
198+
199+
SSYManagedTreeObject* parent = [self parent] ;
200+
if (parent) {
201+
// The order of the following two statements must be as is:
202+
[[self parent] forgetCachedChildrenOrdered] ;
203+
[[NSNotificationCenter defaultCenter] postNotificationName:SSYManagedTreeChildrenChangedNotification
204+
object:[self owner]
205+
userInfo:[NSDictionary dictionaryWithObject:[self parent]
206+
forKey:SSYManagedTreeObjectKey]] ;
207+
}
208+
}
191209

192-
[self postWillSetNewValue:newValue
193-
forKey:constKeyIndex] ;
194-
[self willChangeValueForKey:constKeyIndex] ;
195-
[self setPrimitiveIndex:newValue] ;
196-
[self didChangeValueForKey:constKeyIndex] ;
197210
}
198211

199212
- (NSInteger)indexValue {
@@ -221,7 +234,7 @@ - (NSArray*)childrenOrdered {
221234
if (!m_cachedChildrenOrdered) {
222235
m_cachedChildrenOrdered = [[[self children] arraySortedByKeyPath:constKeyIndex] retain] ;
223236
}
224-
237+
225238
// arrayWithArray was added in BookMacster 1.12.8 to fix crashes which
226239
// were occuring in various methods when m_cachedChildrenOrdered was
227240
// changed. I also removed -arrayWithArray in several methods where the
@@ -313,13 +326,25 @@ - (NSInteger)numberOfChildren {
313326
}
314327

315328
// This is required to trigger -[BkmxDoc objectWillChangeNote:]
316-
- (void)setParent:(SSYManagedTreeObject*)newValue {
317-
[self postWillSetNewValue:newValue
318-
forKey:constKeyParent] ;
319-
[self willChangeValueForKey:constKeyParent] ;
320-
[self setPrimitiveParent:newValue] ;
321-
[self didChangeValueForKey:constKeyParent] ;
322-
329+
- (void)setParent:(SSYManagedTreeObject*)newParent {
330+
if (![NSObject isEqualHandlesNilObject1:[self index]
331+
object2:newParent]) {
332+
[self postWillSetNewValue:newParent
333+
forKey:constKeyParent] ;
334+
335+
[self willChangeValueForKey:constKeyParent] ;
336+
[self setPrimitiveParent:newParent] ;
337+
[self didChangeValueForKey:constKeyParent] ;
338+
339+
if (newParent) {
340+
// The order of the following two statements must be as is:
341+
[newParent forgetCachedChildrenOrdered] ;
342+
[[NSNotificationCenter defaultCenter] postNotificationName:SSYManagedTreeChildrenChangedNotification
343+
object:[self owner]
344+
userInfo:[NSDictionary dictionaryWithObject:newParent
345+
forKey:SSYManagedTreeObjectKey]] ;
346+
}
347+
}
323348
}
324349

325350
/*

0 commit comments

Comments
 (0)