Revision: 27591
http://sourceforge.net/p/bibdesk/svn/27591
Author: hofman
Date: 2022-06-09 09:23:37 +0000 (Thu, 09 Jun 2022)
Log Message:
-----------
get type of URL field values to sort rather than comparing URLs by type, so we
calculate the type only once per item
Modified Paths:
--------------
trunk/bibdesk/BDSKFieldCollection.h
trunk/bibdesk/BDSKFieldCollection.m
trunk/bibdesk/BibItem.m
trunk/bibdesk/NSSortDescriptor_BDSKExtensions.m
trunk/bibdesk/NSString_BDSKExtensions.h
trunk/bibdesk/NSString_BDSKExtensions.m
trunk/bibdesk/NSURL_BDSKExtensions.h
trunk/bibdesk/NSURL_BDSKExtensions.m
Modified: trunk/bibdesk/BDSKFieldCollection.h
===================================================================
--- trunk/bibdesk/BDSKFieldCollection.h 2022-06-09 09:07:29 UTC (rev 27590)
+++ trunk/bibdesk/BDSKFieldCollection.h 2022-06-09 09:23:37 UTC (rev 27591)
@@ -43,7 +43,8 @@
BDSKStringFieldCollection,
BDSKPersonFieldCollection,
BDSKURLFieldCollection,
- BDSKGroupFieldCollection
+ BDSKGroupFieldCollection,
+ BDSKURLTypeFieldCollection
};
@class BibItem;
Modified: trunk/bibdesk/BDSKFieldCollection.m
===================================================================
--- trunk/bibdesk/BDSKFieldCollection.m 2022-06-09 09:07:29 UTC (rev 27590)
+++ trunk/bibdesk/BDSKFieldCollection.m 2022-06-09 09:23:37 UTC (rev 27591)
@@ -74,6 +74,14 @@
value = (id)[item URLForField:key];
} else if (type == BDSKGroupFieldCollection) {
value = (id)[item groupArrayForField:key];
+ } else if (type == BDSKURLTypeFieldCollection) {
+ value = (id)[item URLForField:key];
+ if (value == nil)
+ return [NSString isEmptyString:[item stringValueOfField:key]]
? nil : @"";
+ else if ([value isFile])
+ return [[NSWorkspace sharedWorkspace] typeOfFile:[value path]
error:NULL];
+ else
+ return [NSString stringWithFormat:@"%@:%@", [value scheme],
[value pathExtension]];
} else {
value = (id)[item stringValueOfField:key];
if ([key isURLField] == NO && [key isBooleanField] == NO && [key
isTriStateField] == NO && [key isRatingField] == NO && [key isCitationField] ==
NO)
Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m 2022-06-09 09:07:29 UTC (rev 27590)
+++ trunk/bibdesk/BibItem.m 2022-06-09 09:23:37 UTC (rev 27591)
@@ -3019,7 +3019,7 @@
- (BDSKFieldCollection *)URLFields {
BDSKFieldCollection *collection = [[[BDSKFieldCollection alloc]
initWithItem:self] autorelease];
- [collection setType:BDSKURLFieldCollection];
+ [collection setType:BDSKURLTypeFieldCollection];
return collection;
}
Modified: trunk/bibdesk/NSSortDescriptor_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSSortDescriptor_BDSKExtensions.m 2022-06-09 09:07:29 UTC
(rev 27590)
+++ trunk/bibdesk/NSSortDescriptor_BDSKExtensions.m 2022-06-09 09:23:37 UTC
(rev 27591)
@@ -140,16 +140,11 @@
sortDescriptor = [[self alloc] initWithKey:tcID ascending:ascend
selector:@selector(numericCompare:)];
- }else if([tcID isRemoteURLField]){
+ }else if([tcID isRemoteURLField] || [tcID isLocalFileField]){
- // compare pathExtension for URL fields so the subsort is more useful
- sortDescriptor = [[self alloc] initWithKey:tcID ascending:ascend
selector:@selector(extensionCompare:)];
-
- }else if([tcID isLocalFileField]){
+ // compare UTI for file fields or scheme and extension for remote URL
fields so the subsort is more useful
+ sortDescriptor = [[self alloc] initWithKey:[@"URLFields."
stringByAppendingString:tcID] ascending:ascend
selector:@selector(caseInsensitiveCompare:)];
- // compare UTI for file fields so the subsort is more useful
- sortDescriptor = [[self alloc] initWithKey:[@"URLFields."
stringByAppendingString:tcID] ascending:ascend selector:@selector(UTICompare:)];
-
}else if([tcID isEqualToString:BDSKLocalFileString]){
sortDescriptor = [[self alloc]
initWithKey:@"countOfLocalFilesAsNumber" ascending:ascend
selector:@selector(compare:)];
Modified: trunk/bibdesk/NSString_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSString_BDSKExtensions.h 2022-06-09 09:07:29 UTC (rev
27590)
+++ trunk/bibdesk/NSString_BDSKExtensions.h 2022-06-09 09:23:37 UTC (rev
27591)
@@ -350,8 +350,6 @@
*/
- (NSComparisonResult)sortCompare:(NSString *)other;
-- (NSComparisonResult)extensionCompare:(NSString *)other;
-
/*!
@method triStateCompare:
@abstract For sorting triState string values
Modified: trunk/bibdesk/NSString_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSString_BDSKExtensions.m 2022-06-09 09:07:29 UTC (rev
27590)
+++ trunk/bibdesk/NSString_BDSKExtensions.m 2022-06-09 09:23:37 UTC (rev
27591)
@@ -973,17 +973,6 @@
return [self localizedCaseInsensitiveNumericCompare:other];
}
-- (NSComparisonResult)extensionCompare:(NSString *)other{
- NSString *myExtension = [self pathExtension];
- NSString *otherExtension = [other pathExtension];
- BOOL otherIsEmpty = [NSString isEmptyString:otherExtension];
- if ([myExtension isEqualToString:@""])
- return otherIsEmpty ? NSOrderedSame : NSOrderedDescending;
- if (otherIsEmpty)
- return NSOrderedAscending;
- return [myExtension caseInsensitiveCompare:otherExtension];
-}
-
- (NSComparisonResult)triStateCompare:(NSString *)other{
// we order increasingly as 0, -1, 1
NSInteger myValue = [self triStateValue];
Modified: trunk/bibdesk/NSURL_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSURL_BDSKExtensions.h 2022-06-09 09:07:29 UTC (rev
27590)
+++ trunk/bibdesk/NSURL_BDSKExtensions.h 2022-06-09 09:23:37 UTC (rev
27591)
@@ -58,8 +58,6 @@
- (BOOL)hasDomain:(NSString *)domain;
- (BOOL)hasFirstPathComponent:(NSString *)pathComponent;
-- (NSComparisonResult)UTICompare:(NSURL *)other;
-
- (NSArray *)SkimNotes;
- (NSString *)textSkimNotes;
- (NSAttributedString *)richTextSkimNotes;
Modified: trunk/bibdesk/NSURL_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSURL_BDSKExtensions.m 2022-06-09 09:07:29 UTC (rev
27590)
+++ trunk/bibdesk/NSURL_BDSKExtensions.m 2022-06-09 09:23:37 UTC (rev
27591)
@@ -270,16 +270,6 @@
return [[self path] precomposedStringWithCanonicalMapping];
}
-- (NSComparisonResult)UTICompare:(NSURL *)other {
- NSString *otherUTI = [[NSWorkspace sharedWorkspace] typeOfFile:[other
path] error:NULL];
- NSString *selfUTI = [[NSWorkspace sharedWorkspace] typeOfFile:[self path]
error:NULL];
- if (nil == selfUTI)
- return (nil == otherUTI ? NSOrderedSame : NSOrderedDescending);
- if (nil == otherUTI)
- return NSOrderedAscending;
- return [selfUTI caseInsensitiveCompare:otherUTI];
-}
-
- (BOOL)canConnect {
CFNetDiagnosticRef diagnostic =
CFNetDiagnosticCreateWithURL(kCFAllocatorDefault, (CFURLRef)self);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit