Revision: 3832
http://skim-app.svn.sourceforge.net/skim-app/?rev=3832&view=rev
Author: hofman
Date: 2008-04-29 05:57:25 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
Add custom objects for search results groped by pages.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKGroupedSearchResult.h
trunk/SKGroupedSearchResult.m
Added: trunk/SKGroupedSearchResult.h
===================================================================
--- trunk/SKGroupedSearchResult.h (rev 0)
+++ trunk/SKGroupedSearchResult.h 2008-04-29 12:57:25 UTC (rev 3832)
@@ -0,0 +1,63 @@
+//
+// SKGroupedSearchResult.h
+// Skim
+//
+// Created by Christiaan Hofman on 4/29/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <Quartz/Quartz.h>
+
+extern NSString *SKGroupedSearchResultCountKey;
+
[EMAIL PROTECTED] SKGroupedSearchResult : NSObject {
+ PDFPage *page;
+ unsigned int maxCount;
+ NSMutableArray *matches;
+}
+
++ (id)groupedSearchResultWithPage:(PDFPage *)aPage maxCount:(unsigned
int)aMaxCount;
+- (id)initWithPage:(PDFPage *)aPage maxCount:(unsigned int)aMaxCount;
+
+- (PDFPage *)page;
+
+- (unsigned int)count;
+
+- (unsigned int)maxCount;
+- (void)setMaxCount:(unsigned int)newMaxCount;
+
+- (NSArray *)matches;
+- (void)addMatch:(PDFSelection *)match;
+
[EMAIL PROTECTED]
Added: trunk/SKGroupedSearchResult.m
===================================================================
--- trunk/SKGroupedSearchResult.m (rev 0)
+++ trunk/SKGroupedSearchResult.m 2008-04-29 12:57:25 UTC (rev 3832)
@@ -0,0 +1,90 @@
+//
+// SKGroupedSearchResult.m
+// Skim
+//
+// Created by Christiaan Hofman on 4/29/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "SKGroupedSearchResult.h"
+
+NSString *SKGroupedSearchResultCountKey = @"count";
+
[EMAIL PROTECTED] SKGroupedSearchResult
+
++ (id)groupedSearchResultWithPage:(PDFPage *)aPage maxCount:(unsigned
int)aMaxCount {
+ return [[[self alloc] initWithPage:aPage maxCount:aMaxCount] autorelease];
+}
+
+- (id)initWithPage:(PDFPage *)aPage maxCount:(unsigned int)aMaxCount {
+ if (self = [super init]) {
+ page = [aPage retain];
+ maxCount = aMaxCount;
+ matches = [[NSMutableArray alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [page release];
+ [matches release];
+ [super dealloc];
+}
+
+- (PDFPage *)page {
+ return page;
+}
+
+- (unsigned int)count {
+ return [matches count];
+}
+
+- (unsigned int)maxCount {
+ return maxCount;
+}
+
+- (void)setMaxCount:(unsigned int)newMaxCount {
+ maxCount = newMaxCount;
+}
+
+- (NSArray *)matches {
+ return matches;
+}
+
+- (void)addMatch:(PDFSelection *)match {
+ [self willChangeValueForKey:SKGroupedSearchResultCountKey];
+ [matches addObject:match];
+ [self didChangeValueForKey:SKGroupedSearchResultCountKey];
+}
+
[EMAIL PROTECTED]
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-04-29 12:00:51 UTC (rev 3831)
+++ trunk/SKMainWindowController.m 2008-04-29 12:57:25 UTC (rev 3832)
@@ -93,6 +93,7 @@
#import "SKCFCallbacks.h"
#import "NSSegmentedControl_SKExtensions.h"
#import "NSImage_SKExtensions.h"
+#import "SKGroupedSearchResult.h"
static NSString *SKMainWindowFrameKey = @"windowFrame";
static NSString *SKMainWindowLeftSidePaneWidthKey = @"leftSidePaneWidth";
@@ -125,11 +126,6 @@
static NSString *SKMainWindowRelevanceColumnIdentifer = @"relevance";
static NSString *SKMainWindowResultsColumnIdentifer = @"results";
-static NSString *SKMainWindowSearchCountKey = @"count";
-static NSString *SKMainWindowSearchPageKey = @"page";
-static NSString *SKMainWindowSearchResultsKey = @"results";
-static NSString *SKMainWindowSearchMaxCountKey = @"maxCount";
-
static float segmentedControlHeight = 23.0;
static float segmentedControlOffset = 1.0;
@@ -151,6 +147,7 @@
- (BOOL)isDescendantOf:(NSView *)aView { return NO; }
@end
+
@interface SKMainWindowController (Private)
- (void)setupToolbar;
@@ -451,7 +448,7 @@
[snapshotArrayController setSortDescriptors:[NSArray
arrayWithObjects:pageIndexSortDescriptor, nil]];
[ownerController setContent:self];
- NSSortDescriptor *countDescriptor = [[[NSSortDescriptor alloc]
initWithKey:SKMainWindowSearchCountKey ascending:NO] autorelease];
+ NSSortDescriptor *countDescriptor = [[[NSSortDescriptor alloc]
initWithKey:SKGroupedSearchResultCountKey ascending:NO] autorelease];
[groupedFindArrayController setSortDescriptors:[NSArray
arrayWithObjects:countDescriptor, nil]];
[[[groupedFindTableView
tableColumnWithIdentifier:SKMainWindowRelevanceColumnIdentifer] dataCell]
setEnabled:NO];
@@ -2899,21 +2896,19 @@
[searchResults addObject:instance];
PDFPage *page = [[instance pages] objectAtIndex:0];
- NSMutableDictionary *dict = [groupedSearchResults lastObject];
- NSNumber *maxCount = [dict valueForKey:SKMainWindowSearchMaxCountKey];
- if ([[dict valueForKey:SKMainWindowSearchPageKey] isEqual:page] == NO)
{
- dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:page,
SKMainWindowSearchPageKey, [NSMutableArray array],
SKMainWindowSearchResultsKey, maxCount, SKMainWindowSearchMaxCountKey, nil];
- [groupedSearchResults addObject:dict];
+ SKGroupedSearchResult *result = [groupedSearchResults lastObject];
+ unsigned int maxCount = [result maxCount];
+ if ([[result page] isEqual:page] == NO) {
+ result = [SKGroupedSearchResult groupedSearchResultWithPage:page
maxCount:maxCount];
+ [groupedSearchResults addObject:result];
}
- NSMutableArray *results = [dict
valueForKey:SKMainWindowSearchResultsKey];
- [results addObject:instance];
- [dict setValue:[NSNumber numberWithUnsignedInt:[results count]]
forKey:SKMainWindowSearchCountKey];
+ [result addMatch:instance];
- if ([results count] > [maxCount unsignedIntValue]) {
- NSEnumerator *dictEnum = [groupedSearchResults objectEnumerator];
- maxCount = [NSNumber numberWithUnsignedInt:[results count]];
- while (dict = [dictEnum nextObject])
- [dict setValue:maxCount forKey:SKMainWindowSearchMaxCountKey];
+ if ([result count] > maxCount) {
+ NSEnumerator *resultEnum = [groupedSearchResults objectEnumerator];
+ maxCount = [result count];
+ while (result = [resultEnum nextObject])
+ [result setMaxCount:maxCount];
}
}
}
@@ -3106,7 +3101,7 @@
if (findPaneState == SKSingularFindPaneState && [findView window])
findResults = [findArrayController selectedObjects];
else if (findPaneState == SKGroupedFindPaneState && [groupedFindView
window])
- findResults = [[groupedFindArrayController selectedObjects]
valueForKeyPath:@"@unionOfArrays.results"];
+ findResults = [[groupedFindArrayController selectedObjects]
valueForKeyPath:@"@unionOfArrays.matches"];
[self goToFindResults:findResults scrollToVisible:scroll];
}
@@ -4394,7 +4389,7 @@
PDFDestination *dest = [[[findArrayController arrangedObjects]
objectAtIndex:row] destination];
[self showHoverWindowForDestination:dest];
} else if ([tv isEqual:groupedFindTableView]) {
- PDFDestination *dest = [[[[[groupedFindArrayController
arrangedObjects] objectAtIndex:row] valueForKey:SKMainWindowSearchResultsKey]
objectAtIndex:0] destination];
+ PDFDestination *dest = [[[[[groupedFindArrayController
arrangedObjects] objectAtIndex:row] matches] objectAtIndex:0] destination];
[self showHoverWindowForDestination:dest];
}
}
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-04-29 12:00:51 UTC (rev
3831)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-04-29 12:57:25 UTC (rev
3832)
@@ -187,6 +187,7 @@
CEC7B3A00CF5F2D2008CCD63 /* KeyspanFrontRowControl.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEC7B3940CF5F2D2008CCD63 /*
KeyspanFrontRowControl.m */; };
CEC7B3A20CF5F2D2008CCD63 /* MultiClickRemoteBehavior.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEC7B3960CF5F2D2008CCD63 /*
MultiClickRemoteBehavior.m */; };
CEC7B3A40CF5F2D2008CCD63 /* RemoteControlContainer.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEC7B3980CF5F2D2008CCD63 /*
RemoteControlContainer.m */; };
+ CECB03D30DC7503A0000B16B /* SKGroupedSearchResult.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CECB03D20DC7503A0000B16B /*
SKGroupedSearchResult.m */; };
CECDC4FF0C5966A80026AAEC /* NSImage_SKExtensions.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CECDC4FD0C5966A80026AAEC /*
NSImage_SKExtensions.m */; };
CECDD2990C5B68580026AAEC /* SKCenteredTextFieldCell.m in
Sources */ = {isa = PBXBuildFile; fileRef = CECDD2970C5B68580026AAEC /*
SKCenteredTextFieldCell.m */; };
CECDDBAE0C5BB9600026AAEC /* SKFindTableView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CECDDBAC0C5BB95F0026AAEC /* SKFindTableView.m
*/; };
@@ -774,6 +775,8 @@
CEC7B3970CF5F2D2008CCD63 /* RemoteControlContainer.h */ = {isa
= PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name
= RemoteControlContainer.h; path =
vendorsrc/martinkahr/RemoteControlWrapper/RemoteControlContainer.h; sourceTree
= "<group>"; };
CEC7B3980CF5F2D2008CCD63 /* RemoteControlContainer.m */ = {isa
= PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc;
name = RemoteControlContainer.m; path =
vendorsrc/martinkahr/RemoteControlWrapper/RemoteControlContainer.m; sourceTree
= "<group>"; };
CEC7B4E60CF607CA008CCD63 /* QuickLook-Skim.xcodeproj */ = {isa
= PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name =
"QuickLook-Skim.xcodeproj"; path = "QuickLook-Skim/QuickLook-Skim.xcodeproj";
sourceTree = "<group>"; };
+ CECB03D10DC7503A0000B16B /* SKGroupedSearchResult.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKGroupedSearchResult.h; sourceTree = "<group>"; };
+ CECB03D20DC7503A0000B16B /* SKGroupedSearchResult.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKGroupedSearchResult.m; sourceTree = "<group>"; };
CECD97200C57A3230026AAEC /* French */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.nib; name = French; path =
French.lproj/InfoWindow.nib; sourceTree = "<group>"; };
CECD97230C57A32F0026AAEC /* French */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.nib; name = French; path =
French.lproj/MainMenu.nib; sourceTree = "<group>"; };
CECD97260C57A3390026AAEC /* French */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.nib; name = French; path =
French.lproj/MainWindow.nib; sourceTree = "<group>"; };
@@ -1274,6 +1277,8 @@
CEE177950DBE140900E6C317 /*
SKAccessibilityProxyElement.m */,
CEBD52EA0C9C0AE500FBF6A4 /* SKBookmark.h */,
CEBD52EB0C9C0AE500FBF6A4 /* SKBookmark.m */,
+ CECB03D10DC7503A0000B16B /*
SKGroupedSearchResult.h */,
+ CECB03D20DC7503A0000B16B /*
SKGroupedSearchResult.m */,
CEAF2E570C45414100C3ECBB /* SKLine.h */,
CEAF2E580C45414100C3ECBB /* SKLine.m */,
CE4294A10BBD29120016FDC2 /* SKReadingBar.h */,
@@ -2035,6 +2040,7 @@
CECF61FF0DB258D600587D96 /* SKFontWell.m in
Sources */,
CEE176E40DBD5B0C00E6C317 /*
PDFDisplayView_SKExtensions.m in Sources */,
CEE177960DBE140900E6C317 /*
SKAccessibilityProxyElement.m in Sources */,
+ CECB03D30DC7503A0000B16B /*
SKGroupedSearchResult.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit