Revision: 4455
http://skim-app.svn.sourceforge.net/skim-app/?rev=4455&view=rev
Author: hofman
Date: 2008-08-26 19:51:27 +0000 (Tue, 26 Aug 2008)
Log Message:
-----------
Remove some bulk KVC setters for to-many properties. Instead implement KVO
compatible methods to remove all objects.
Modified Paths:
--------------
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2008-08-26 19:01:27 UTC (rev 4454)
+++ trunk/SKMainWindowController.h 2008-08-26 19:51:27 UTC (rev 4455)
@@ -354,23 +354,24 @@
- (void)setPdfDocument:(PDFDocument *)document;
- (NSArray *)notes;
-- (void)setNotes:(NSArray *)newNotes;
- (unsigned int)countOfNotes;
- (PDFAnnotation *)objectInNotesAtIndex:(unsigned int)theIndex;
- (void)insertObject:(PDFAnnotation *)note inNotesAtIndex:(unsigned
int)theIndex;
- (void)removeObjectFromNotesAtIndex:(unsigned int)theIndex;
+- (void)removeAllObjectsFromNotes;
- (unsigned int)countOfThumbnails;
- (SKThumbnail *)objectInThumbnailsAtIndex:(unsigned int)theIndex;
- (void)insertObject:(SKThumbnail *)thumbnail inThumbnailsAtIndex:(unsigned
int)theIndex;
- (void)removeObjectFromThumbnailsAtIndex:(unsigned int)theIndex;
+- (void)removeAllObjectsFromThumbnails;
- (NSArray *)snapshots;
-- (void)setSnapshots:(NSArray *)newSnapshots;
- (unsigned int)countOfSnapshots;
- (SKSnapshotWindowController *)objectInSnapshotsAtIndex:(unsigned
int)theIndex;
- (void)insertObject:(SKSnapshotWindowController *)snapshot
inSnapshotsAtIndex:(unsigned int)theIndex;
- (void)removeObjectFromSnapshotsAtIndex:(unsigned int)theIndex;
+- (void)removeAllObjectsFromSnapshots;
- (NSArray *)searchResults;
- (void)setSearchResults:(NSArray *)newSearchResults;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-08-26 19:01:27 UTC (rev 4454)
+++ trunk/SKMainWindowController.m 2008-08-26 19:51:27 UTC (rev 4455)
@@ -710,12 +710,12 @@
// these will be invalid. If needed, the document will restore them
[self setSearchResults:nil];
[self setGroupedSearchResults:nil];
- [self setNotes:nil];
- [[self mutableArrayValueForKey:SKMainWindowThumbnailsKey]
removeAllObjects];
+ [self removeAllObjectsFromNotes];
+ [self removeAllObjectsFromThumbnails];
snapshotDicts = [snapshots valueForKey:SKSnapshotCurrentSetupKey];
[snapshots makeObjectsPerformSelector:@selector(close)];
- [self setSnapshots:nil];
+ [self removeAllObjectsFromSnapshots];
[pdfOutline release];
pdfOutline = nil;
@@ -809,7 +809,7 @@
}
if (undoable == NO)
- [self setNotes:nil];
+ [self removeAllObjectsFromNotes];
[self addAnnotationsFromDictionaries:noteDicts undoable:undoable];
}
@@ -967,54 +967,6 @@
- (NSArray *)notes {
return [[notes copy] autorelease];
}
-
-- (void)setNotes:(NSArray *)newNotes {
- NSMutableSet *old = (NSMutableSet *)CFSetCreateMutable(NULL, 0,
&kSKPointerEqualObjectSetCallBacks);
- NSMutableSet *new = (NSMutableSet *)CFSetCreateMutable(NULL, 0,
&kSKPointerEqualObjectSetCallBacks);
- NSMutableSet *removed;
- NSMutableSet *added;
-
- [old addObjectsFromArray:notes];
- [new addObjectsFromArray:newNotes];
- removed = (NSMutableSet *)CFSetCreateMutableCopy(NULL, 0, (CFSetRef)old);
- [removed minusSet:new];
- added = (NSMutableSet *)CFSetCreateMutableCopy(NULL, 0, (CFSetRef)new);
- [added minusSet:old];
- [old release];
- [new release];
-
- if ([removed count]) {
- NSEnumerator *wcEnum = [[[self document] windowControllers]
objectEnumerator];
- NSWindowController *wc = [wcEnum nextObject];
-
- while (wc = [wcEnum nextObject]) {
- if ([wc isKindOfClass:[SKNoteWindowController class]] && [removed
containsObject:[(SKNoteWindowController *)wc note]])
- [[wc window] orderOut:self];
- }
-
- NSEnumerator *noteEnum = [removed objectEnumerator];
- PDFAnnotation *note;
-
- while (note = [noteEnum nextObject]) {
- if ([[note texts] count])
- CFDictionaryRemoveValue(rowHeights, (const void *)[[note
texts] lastObject]);
- CFDictionaryRemoveValue(rowHeights, (const void *)note);
- }
-
- // Stop observing the removed notes so that
- [self stopObservingNotes:[removed allObjects]];
- }
- [removed release];
-
- [notes setArray:newNotes];
-
- // Start observing the added notes so that, when they're changed, we can
record undo operations.
- if ([added count])
- [self startObservingNotes:[added allObjects]];
- [added release];
-
- [noteOutlineView reloadData];
-}
- (unsigned int)countOfNotes {
return [notes count];
@@ -1053,6 +1005,29 @@
[notes removeObjectAtIndex:theIndex];
}
+- (void)removeAllObjectsFromNotes {
+ if ([notes count]) {
+ NSIndexSet *indexes = [NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [notes count])];
+ [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes
forKey:SKMainWindowNotesKey];
+
+ NSEnumerator *wcEnum = [[[self document] windowControllers]
objectEnumerator];
+ NSWindowController *wc = [wcEnum nextObject];
+ while (wc = [wcEnum nextObject]) {
+ if ([wc isKindOfClass:[SKNoteWindowController class]])
+ [[wc window] orderOut:self];
+ }
+
+ CFDictionaryRemoveAllValues(rowHeights);
+
+ [self stopObservingNotes:notes];
+
+ [notes removeAllObjects];
+
+ [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes
forKey:SKMainWindowNotesKey];
+ [noteOutlineView reloadData];
+ }
+}
+
- (unsigned int)countOfThumbnails {
return [thumbnails count];
}
@@ -1088,26 +1063,19 @@
[thumbnails removeObjectAtIndex:theIndex];
}
+- (void)removeAllObjectsFromThumbnails {
+ if ([thumbnails count]) {
+ NSIndexSet *indexes = [NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [thumbnails count])];
+ [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes
forKey:SKMainWindowThumbnailsKey];
+ [thumbnails removeAllObjects];
+ [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes
forKey:SKMainWindowThumbnailsKey];
+ }
+}
+
- (NSArray *)snapshots {
return [[snapshots copy] autorelease];
}
-- (void)setSnapshots:(NSArray *)newSnapshots {
- NSMutableSet *removed = (NSMutableSet *)CFSetCreateMutable(NULL, 0,
&kSKPointerEqualObjectSetCallBacks);
- NSMutableSet *new = (NSMutableSet *)CFSetCreateMutable(NULL, 0,
&kSKPointerEqualObjectSetCallBacks);
-
- [new addObjectsFromArray:newSnapshots];
- [removed addObjectsFromArray:snapshots];
- [removed minusSet:new];
- [new release];
-
- if ([removed count])
- [dirtySnapshots removeObjectsInArray:[removed allObjects]];
- [removed release];
-
- [snapshots setArray:snapshots];
-}
-
- (unsigned int)countOfSnapshots {
return [snapshots count];
}
@@ -1125,6 +1093,19 @@
[snapshots removeObjectAtIndex:theIndex];
}
+- (void)removeAllObjectsFromSnapshots {
+ if ([snapshots count]) {
+ NSIndexSet *indexes = [NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [snapshots count])];
+ [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes
forKey:SKMainWindowSnapshotsKey];
+
+ [dirtySnapshots removeAllObjects];
+
+ [snapshots removeAllObjects];
+
+ [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes
forKey:SKMainWindowSnapshotsKey];
+ }
+}
+
- (NSArray *)selectedNotes {
NSMutableArray *selectedNotes = [NSMutableArray array];
NSIndexSet *rowIndexes = [noteOutlineView selectedRowIndexes];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit