Revision: 3093
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3093&view=rev
Author:   hofman
Date:     2007-10-29 06:46:30 -0700 (Mon, 29 Oct 2007)

Log Message:
-----------
Use a custom comparator for note type, instead of comparing a custom accessor. 
Notes dictionaries (in NotesDocument) don't have that accessor.

Modified Paths:
--------------
    trunk/NSArray_SKExtensions.m
    trunk/NSString_SKExtensions.h
    trunk/NSString_SKExtensions.m
    trunk/SKMainWindowController.m
    trunk/SKNotesDocument.m
    trunk/SKPDFAnnotationNote.h
    trunk/SKPDFAnnotationNote.m

Modified: trunk/NSArray_SKExtensions.m
===================================================================
--- trunk/NSArray_SKExtensions.m        2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/NSArray_SKExtensions.m        2007-10-29 13:46:30 UTC (rev 3093)
@@ -55,7 +55,7 @@
 }
 
 - (NSArray *)arraySortedByType {
-    return [self sortedArrayUsingDescriptors:[NSArray 
arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"noteType" 
ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease]]];
+    return [self sortedArrayUsingDescriptors:[NSArray 
arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES 
selector:@selector(noteTypeCompare:)] autorelease]]];
 }
 
 - (NSArray *)arraySortedByContents {
@@ -63,11 +63,11 @@
 }
 
 - (NSArray *)arraySortedByTypeAndContents {
-    return [self sortedArrayUsingDescriptors:[NSArray 
arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"noteType" 
ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], 
[[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES 
selector:@selector(caseInsensitiveCompare:)] autorelease], nil]];
+    return [self sortedArrayUsingDescriptors:[NSArray 
arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES 
selector:@selector(noteTypeCompare:)] autorelease], [[[NSSortDescriptor alloc] 
initWithKey:@"contents" ascending:YES 
selector:@selector(caseInsensitiveCompare:)] autorelease], nil]];
 }
 
 - (NSArray *)arraySortedByTypeAndPageIndex {
-    return [self sortedArrayUsingDescriptors:[NSArray 
arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"noteType" 
ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], 
[[[NSSortDescriptor alloc] initWithKey:@"pageIndex" ascending:YES 
selector:@selector(compare:)] autorelease], nil]];
+    return [self sortedArrayUsingDescriptors:[NSArray 
arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES 
selector:@selector(noteTypeCompare:)] autorelease], [[[NSSortDescriptor alloc] 
initWithKey:@"pageIndex" ascending:YES selector:@selector(compare:)] 
autorelease], nil]];
 }
 
 @end

Modified: trunk/NSString_SKExtensions.h
===================================================================
--- trunk/NSString_SKExtensions.h       2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/NSString_SKExtensions.h       2007-10-29 13:46:30 UTC (rev 3093)
@@ -41,6 +41,8 @@
 
 @interface NSString (SKExtensions)
 
+- (NSComparisonResult)noteTypeCompare:(id)other;
+
 - (NSString 
*)stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines;
 
 - (NSString *)stringByAppendingEllipsis;

Modified: trunk/NSString_SKExtensions.m
===================================================================
--- trunk/NSString_SKExtensions.m       2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/NSString_SKExtensions.m       2007-10-29 13:46:30 UTC (rev 3093)
@@ -104,6 +104,31 @@
 
 @implementation NSString (SKExtensions)
 
+- (NSNumber *)noteTypeOrder {
+    int order = 8;
+    if ([[self type] isEqualToString:SKFreeTextString])
+        order = 0;
+    else if ([[self type] isEqualToString:SKNoteString] || [[self type] 
isEqualToString:SKTextString])
+        order = 1;
+    else if ([[self type] isEqualToString:SKCircleString])
+        order = 2;
+    else if ([[self type] isEqualToString:SKSquareString])
+        order = 3;
+    else if ([[self type] isEqualToString:SKHighlightString] || [[self type] 
isEqualToString:SKMarkUpString])
+        order = 4;
+    else if ([[self type] isEqualToString:SKUnderlineString])
+        order = 5;
+    else if ([[self type] isEqualToString:SKStrikeOutString])
+        order = 6;
+    else if ([[self type] isEqualToString:SKLineString])
+        order = 7;
+    return [NSNumber numberWithInt:order];
+}
+
+- (NSComparisonResult)noteTypeCompare:(id)other {
+    return [[self noteTypeOrder] compare:[other noteTypeOrder]];
+}
+
 - (NSString 
*)stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines;
 {
     return 
[(id)SKStringCreateByCollapsingAndTrimmingWhitespaceAndNewlines(CFAllocatorGetDefault(),
 (CFStringRef)self) autorelease];

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/SKMainWindowController.m      2007-10-29 13:46:30 UTC (rev 3093)
@@ -3383,7 +3383,7 @@
             NSSortDescriptor *boundsSortDescriptor = [[[NSSortDescriptor 
alloc] initWithKey:@"bounds" ascending:ascending 
selector:@selector(boundsCompare:)] autorelease];
             NSMutableArray *sds = [NSMutableArray 
arrayWithObjects:pageIndexSortDescriptor, boundsSortDescriptor, nil];
             if ([tcID isEqualToString:@"type"]) {
-                [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:@"noteType" ascending:YES 
selector:@selector(caseInsensitiveCompare:)] autorelease] atIndex:0];
+                [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:@"type" ascending:YES selector:@selector(noteTypeCompare:)] 
autorelease] atIndex:0];
             } else if ([tcID isEqualToString:@"note"]) {
                 [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:@"contents" ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] 
atIndex:0];
             } else if ([tcID isEqualToString:@"page"]) {

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/SKNotesDocument.m     2007-10-29 13:46:30 UTC (rev 3093)
@@ -323,7 +323,7 @@
         NSSortDescriptor *boundsSortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:@"bounds" ascending:ascending selector:@selector(boundsCompare:)] 
autorelease];
         NSMutableArray *sds = [NSMutableArray 
arrayWithObjects:pageIndexSortDescriptor, boundsSortDescriptor, nil];
         if ([tcID isEqualToString:@"type"]) {
-            [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:@"noteType" ascending:YES 
selector:@selector(caseInsensitiveCompare:)] autorelease] atIndex:0];
+            [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"type" 
ascending:YES selector:@selector(noteTypeCompare:)] autorelease] atIndex:0];
         } else if ([tcID isEqualToString:@"note"]) {
             [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:@"contents" ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] 
atIndex:0];
         } else if ([tcID isEqualToString:@"page"]) {

Modified: trunk/SKPDFAnnotationNote.h
===================================================================
--- trunk/SKPDFAnnotationNote.h 2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/SKPDFAnnotationNote.h 2007-10-29 13:46:30 UTC (rev 3093)
@@ -54,7 +54,6 @@
 
 - (PDFDestination *)destination;
 - (unsigned int)pageIndex;
-- (int)noteType;
 
 - (PDFBorderStyle)borderStyle;
 - (void)setBorderStyle:(PDFBorderStyle)style;

Modified: trunk/SKPDFAnnotationNote.m
===================================================================
--- trunk/SKPDFAnnotationNote.m 2007-10-29 12:51:35 UTC (rev 3092)
+++ trunk/SKPDFAnnotationNote.m 2007-10-29 13:46:30 UTC (rev 3093)
@@ -301,26 +301,6 @@
     return page ? [page pageIndex] : NSNotFound;
 }
 
-- (int)noteType {
-    if ([[self type] isEqualToString:SKFreeTextString])
-        return SKFreeTextNote;
-    else if ([[self type] isEqualToString:SKNoteString])
-        return SKAnchoredNote;
-    else if ([[self type] isEqualToString:SKCircleString])
-        return SKCircleNote;
-    else if ([[self type] isEqualToString:SKSquareString])
-        return SKSquareNote;
-    else if ([[self type] isEqualToString:SKHighlightString] || [[self type] 
isEqualToString:SKMarkUpString])
-        return SKHighlightNote;
-    else if ([[self type] isEqualToString:SKUnderlineString])
-        return SKUnderlineNote;
-    else if ([[self type] isEqualToString:SKStrikeOutString])
-        return SKStrikeOutNote;
-    else if ([[self type] isEqualToString:SKLineString])
-        return SKLineNote;
-    return 0;
-}
-
 - (PDFBorderStyle)borderStyle {
     return [[self border] style];
 }


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

Reply via email to