Revision: 2702
http://skim-app.svn.sourceforge.net/skim-app/?rev=2702&view=rev
Author: hofman
Date: 2007-08-22 09:40:50 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
Implement type-select for the TOC outlineView.
Don't update outline selection when the outline selection changes.
Reset tracking rects in outline views when items expand or collapse, as Apple
does not call resetCursorRects in those cases.
Modified Paths:
--------------
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKNoteOutlineView.m
trunk/SKOutlineView.h
trunk/SKOutlineView.m
trunk/SKTypeSelectHelper.m
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2007-08-22 15:02:59 UTC (rev 2701)
+++ trunk/SKMainWindowController.h 2007-08-22 16:40:50 UTC (rev 2702)
@@ -97,7 +97,7 @@
SKStatusBar *statusBar;
- IBOutlet NSOutlineView *outlineView;
+ IBOutlet SKOutlineView *outlineView;
IBOutlet NSView *tocView;
PDFOutline *pdfOutline;
NSMutableArray *pdfOutlineItems;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2007-08-22 15:02:59 UTC (rev 2701)
+++ trunk/SKMainWindowController.m 2007-08-22 16:40:50 UTC (rev 2702)
@@ -385,6 +385,11 @@
[typeSelectHelper setDataSource:self];
[noteOutlineView setTypeSelectHelper:typeSelectHelper];
+ typeSelectHelper = [[[SKTypeSelectHelper alloc] init] autorelease];
+ [typeSelectHelper setMatchOption:SKSubstringMatch];
+ [typeSelectHelper setDataSource:self];
+ [outlineView setTypeSelectHelper:typeSelectHelper];
+
// This update toolbar item and other states
[self handleChangedHistoryNotification:nil];
[self handlePageChangedNotification:nil];
@@ -3169,7 +3174,9 @@
- (void)outlineViewSelectionDidChange:(NSNotification *)notification{
// Get the destination associated with the search result list. Tell the
PDFView to go there.
if ([[notification object] isEqual:outlineView] &&
(updatingOutlineSelection == NO)){
+ updatingOutlineSelection = YES;
[pdfView goToDestination: [[outlineView itemAtRow: [outlineView
selectedRow]] destination]];
+ updatingOutlineSelection = NO;
if ([self isPresentation] && [[NSUserDefaults standardUserDefaults]
boolForKey:SKAutoHidePresentationContentsKey])
[self hideLeftSideWindow];
}
@@ -3523,6 +3530,12 @@
return pageLabels;
} else if ([typeSelectHelper isEqual:[noteOutlineView typeSelectHelper]]) {
return [[noteArrayController arrangedObjects] valueForKey:@"contents"];
+ } else if ([typeSelectHelper isEqual:[outlineView typeSelectHelper]]) {
+ int i, count = [outlineView numberOfRows];
+ NSMutableArray *array = [NSMutableArray arrayWithCapacity:count];
+ for (i = 0; i < count; i++)
+ [array addObject:[(PDFOutline *)[outlineView itemAtRow:i] label]];
+ return array;
}
return nil;
}
@@ -3532,6 +3545,9 @@
return [[thumbnailTableView selectedRowIndexes] lastIndex];
} else if ([typeSelectHelper isEqual:[noteOutlineView typeSelectHelper]]) {
return [[noteArrayController arrangedObjects] indexOfObject:[self
selectedNote]];
+ } else if ([typeSelectHelper isEqual:[outlineView typeSelectHelper]]) {
+ int row = [outlineView selectedRow];
+ return row == -1 ? NSNotFound : row;
}
return NSNotFound;
}
@@ -3542,6 +3558,8 @@
} else if ([typeSelectHelper isEqual:[noteOutlineView typeSelectHelper]]) {
int row = [noteOutlineView rowForItem:[[noteArrayController
arrangedObjects] objectAtIndex:itemIndex]];
[noteOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
byExtendingSelection:NO];
+ } else if ([typeSelectHelper isEqual:[outlineView typeSelectHelper]]) {
+ [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex]
byExtendingSelection:NO];
}
}
@@ -3556,6 +3574,11 @@
[statusBar setRightStringValue:[NSString
stringWithFormat:NSLocalizedString(@"Finding note: \"[EMAIL PROTECTED]"",
@"Status message"), searchString]];
else
[self updateRightStatus];
+ } else if ([typeSelectHelper isEqual:[outlineView typeSelectHelper]]) {
+ if (searchString)
+ [statusBar setLeftStringValue:[NSString
stringWithFormat:NSLocalizedString(@"Finding: %@", @"Status message"),
searchString]];
+ else
+ [self updateLeftStatus];
}
}
@@ -3580,7 +3603,7 @@
- (void)updateOutlineSelection{
// Skip out if this PDF has no outline.
- if (pdfOutline == nil)
+ if (pdfOutline == nil || updatingOutlineSelection)
return;
// Get index of current page.
@@ -3588,7 +3611,8 @@
// Test that the current selection is still valid.
PDFOutline *outlineItem = (PDFOutline *)[outlineView itemAtRow:
[outlineView selectedRow]];
- if ([[pdfView document] indexForPage: [[outlineItem destination] page]]
== pageIndex)
+
+ if ([[pdfView document] indexForPage: [[outlineItem destination] page]] ==
pageIndex)
return;
int row = [self outlineRowForPageIndex:pageIndex];
Modified: trunk/SKNoteOutlineView.m
===================================================================
--- trunk/SKNoteOutlineView.m 2007-08-22 15:02:59 UTC (rev 2701)
+++ trunk/SKNoteOutlineView.m 2007-08-22 16:40:50 UTC (rev 2702)
@@ -207,8 +207,14 @@
}
}
+- (void)expandItem:(id)item expandChildren:(BOOL)collapseChildren {
+ // NSOutlineView does not call resetCursorRect when expanding
+ [super expandItem:item expandChildren:collapseChildren];
+ [self resetCursorRects];
+}
+
- (void)collapseItem:(id)item collapseChildren:(BOOL)collapseChildren {
- // NSOutlineView seems to call resetCursorRect when expanding, but not
when collapsing
+ // NSOutlineView does not call resetCursorRect when collapsing
[super collapseItem:item collapseChildren:collapseChildren];
[self resetCursorRects];
}
Modified: trunk/SKOutlineView.h
===================================================================
--- trunk/SKOutlineView.h 2007-08-22 15:02:59 UTC (rev 2701)
+++ trunk/SKOutlineView.h 2007-08-22 16:40:50 UTC (rev 2702)
@@ -39,10 +39,16 @@
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
[EMAIL PROTECTED] SKTypeSelectHelper;
@interface SKOutlineView : NSOutlineView {
CFMutableArrayRef trackingRects;
+ SKTypeSelectHelper *typeSelectHelper;
}
+
+- (SKTypeSelectHelper *)typeSelectHelper;
+- (void)setTypeSelectHelper:(SKTypeSelectHelper *)newTypeSelectHelper;
+
@end
Modified: trunk/SKOutlineView.m
===================================================================
--- trunk/SKOutlineView.m 2007-08-22 15:02:59 UTC (rev 2701)
+++ trunk/SKOutlineView.m 2007-08-22 16:40:50 UTC (rev 2702)
@@ -37,6 +37,7 @@
*/
#import "SKOutlineView.h"
+#import "SKTypeSelectHelper.h"
@implementation SKOutlineView
@@ -44,9 +45,22 @@
- (void)dealloc {
if (trackingRects != NULL)
CFRelease(trackingRects);
+ [typeSelectHelper setDataSource:nil];
+ [typeSelectHelper release];
[super dealloc];
}
+- (SKTypeSelectHelper *)typeSelectHelper {
+ return typeSelectHelper;
+}
+
+- (void)setTypeSelectHelper:(SKTypeSelectHelper *)newTypeSelectHelper {
+ if (typeSelectHelper != newTypeSelectHelper) {
+ [typeSelectHelper release];
+ typeSelectHelper = [newTypeSelectHelper retain];
+ }
+}
+
- (void)highlightSelectionInClipRect:(NSRect)clipRect {
if ([[self delegate]
respondsToSelector:@selector(outlineViewHighlightedRows:)]) {
NSMutableIndexSet *rowIndexes = [[[self selectedRowIndexes]
mutableCopy] autorelease];
@@ -108,8 +122,23 @@
}
}
+- (void)expandItem:(id)item expandChildren:(BOOL)collapseChildren {
+ // NSOutlineView does not call resetCursorRect when expanding
+ [super expandItem:item expandChildren:collapseChildren];
+ [typeSelectHelper rebuildTypeSelectSearchCache];
+ [self rebuildTrackingRects];
+}
+
+- (void)collapseItem:(id)item collapseChildren:(BOOL)collapseChildren {
+ // NSOutlineView does not call resetCursorRect when collapsing
+ [super collapseItem:item collapseChildren:collapseChildren];
+ [typeSelectHelper rebuildTypeSelectSearchCache];
+ [self rebuildTrackingRects];
+}
+
- (void)reloadData{
[super reloadData];
+ [typeSelectHelper rebuildTypeSelectSearchCache];
[self rebuildTrackingRects];
}
@@ -164,4 +193,18 @@
}
}
+- (void)keyDown:(NSEvent *)theEvent {
+ NSString *characters = [theEvent charactersIgnoringModifiers];
+ unichar eventChar = [characters length] > 0 ? [characters
characterAtIndex:0] : 0;
+ unsigned modifierFlags = [theEvent modifierFlags] &
NSDeviceIndependentModifierFlagsMask;
+
+ if (typeSelectHelper && modifierFlags == 0 && [[NSCharacterSet
alphanumericCharacterSet] characterIsMember:eventChar]) {
+ [typeSelectHelper processKeyDownCharacter:eventChar];
+ } else if (typeSelectHelper && modifierFlags == 0 && eventChar == '/') {
+ [typeSelectHelper repeatSearch];
+ } else {
+ [super keyDown:theEvent];
+ }
+}
+
@end
Modified: trunk/SKTypeSelectHelper.m
===================================================================
--- trunk/SKTypeSelectHelper.m 2007-08-22 15:02:59 UTC (rev 2701)
+++ trunk/SKTypeSelectHelper.m 2007-08-22 16:40:50 UTC (rev 2702)
@@ -248,8 +248,9 @@
if ([label caseInsensitiveCompare:searchString] == NSOrderedSame)
return labelIndex;
} else {
- if ([label containsStringStartingAtWord:searchString
options:options range:NSMakeRange(0, [label length])])
+ if ([label containsStringStartingAtWord:searchString
options:options range:NSMakeRange(0, [label length])]) {
return labelIndex;
+ }
}
}
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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit