Revision: 17919
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=17919&view=rev
Author:   hofman
Date:     2011-06-02 10:12:55 +0000 (Thu, 02 Jun 2011)

Log Message:
-----------
add import order or relevance as extra sort key rather than using the normal 
ones, so we can more easily reinstate and save the normal ones and don't lose 
the subsort.

Modified Paths:
--------------
    trunk/bibdesk/BibDocument.h
    trunk/bibdesk/BibDocument.m
    trunk/bibdesk/BibDocument_Actions.m
    trunk/bibdesk/BibDocument_DataSource.m
    trunk/bibdesk/BibDocument_Groups.m
    trunk/bibdesk/BibDocument_Menus.m
    trunk/bibdesk/BibDocument_Search.m
    trunk/bibdesk/BibDocument_UI.m

Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument.h 2011-06-02 10:12:55 UTC (rev 17919)
@@ -173,6 +173,7 @@
 
     NSString *sortKey;
     NSString *previousSortKey;
+    NSString *tmpSortKey;
     NSString *sortGroupsKey;
     
 #pragma mark Menu variables
@@ -241,6 +242,7 @@
         unsigned int        itemChangeMask:4;
         unsigned int        sortDescending:1;
         unsigned int        previousSortDescending:1;
+        unsigned int        tmpSortDescending:1;
         unsigned int        sortGroupsDescending:1;
         unsigned int        dragFromExternalGroups:1;
         unsigned int        isDocumentClosed:1;

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument.m 2011-06-02 10:12:55 UTC (rev 17919)
@@ -222,10 +222,12 @@
         tableColumnWidths = nil;
         sortKey = nil;
         previousSortKey = nil;
+        tmpSortKey = nil;
         sortGroupsKey = nil;
         currentGroupField = nil;
         docFlags.sortDescending = NO;
         docFlags.previousSortDescending = NO;
+        docFlags.tmpSortDescending = NO;
         docFlags.sortGroupsDescending = NO;
         docFlags.didImport = NO;
         docFlags.itemChangeMask = 0;
@@ -313,6 +315,7 @@
     BDSKDESTROY(tableColumnWidths);
     BDSKDESTROY(sortKey);
     BDSKDESTROY(previousSortKey);
+    BDSKDESTROY(tmpSortKey);
     BDSKDESTROY(sortGroupsKey);
     BDSKDESTROY(currentGroupField);
     BDSKDESTROY(searchGroupViewController);
@@ -693,10 +696,6 @@
     return mainWindowSetupDictionary;
 }
 
-static inline BOOL isImportOrderOrRelevance(NSString *key) {
-    return [key isEqualToString:BDSKImportOrderString] || [key 
isEqualToString:BDSKRelevanceString];
-}
-
 - (void)saveWindowSetupInExtendedAttributesAtURL:(NSURL *)anURL 
forEncoding:(NSStringEncoding)encoding {
     
     NSString *path = [anURL path];
@@ -705,31 +704,14 @@
         // We could set each of these as a separate attribute name on the 
file, but then we'd need to muck around with prepending 
net.sourceforge.bibdesk. to each key, and that seems messy.
         NSMutableDictionary *dictionary = [[self 
mainWindowSetupDictionaryFromExtendedAttributes] mutableCopy];
         
-        NSString *savedSortKey = nil;
-        BOOL savedSortDescending = docFlags.sortDescending;
-        NSString *savedSubsortKey = nil;
-        BOOL savedSubsortDescending = docFlags.previousSortDescending;
-        if (isImportOrderOrRelevance(sortKey) == NO) {
-            savedSortKey = sortKey;
-            savedSortDescending = docFlags.sortDescending;
-        } else if (isImportOrderOrRelevance(previousSortKey) == NO)  {
-            savedSortKey = previousSortKey;
-            savedSortDescending = docFlags.previousSortDescending;
-        }
-        if (isImportOrderOrRelevance(previousSortKey) == NO) {
-            savedSubsortKey = previousSortKey;
-            savedSubsortDescending = docFlags.previousSortDescending;
-        } else {
-            savedSubsortKey = savedSortKey;
-            savedSubsortDescending = savedSortDescending;
-        }
-        
         [dictionary setObject:[[[tableView tableColumnIdentifiers] 
arrayByRemovingObject:BDSKImportOrderString] 
arrayByRemovingObject:BDSKRelevanceString] forKey:BDSKShownColsNamesKey];
         [dictionary setObject:[self currentTableColumnWidthsAndIdentifiers] 
forKey:BDSKColumnWidthsKey];
-        [dictionary setObject:savedSortKey ?: BDSKTitleString 
forKey:BDSKDefaultSortedTableColumnKey];
-        [dictionary setBoolValue:savedSortDescending 
forKey:BDSKDefaultSortedTableColumnIsDescendingKey];
-        [dictionary setObject:savedSubsortKey ?: BDSKTitleString 
forKey:BDSKDefaultSubsortedTableColumnKey];
-        [dictionary setBoolValue:savedSortDescending 
forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey];
+        [dictionary setObject:sortKey ?: BDSKTitleString 
forKey:BDSKDefaultSortedTableColumnKey];
+        [dictionary setBoolValue:docFlags.sortDescending 
forKey:BDSKDefaultSortedTableColumnIsDescendingKey];
+        if (previousSortKey) {
+            [dictionary setObject:previousSortKey 
forKey:BDSKDefaultSubsortedTableColumnKey];
+            [dictionary setBoolValue:docFlags.previousSortDescending 
forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey];
+        }
         [dictionary setObject:sortGroupsKey forKey:BDSKSortGroupsKey];
         [dictionary setBoolValue:docFlags.sortGroupsDescending 
forKey:BDSKSortGroupsDescendingKey];
         [dictionary setRectValue:[documentWindow frame] 
forKey:BDSKDocumentWindowFrameKey];
@@ -2486,36 +2468,30 @@
     if (key == nil && sortKey == nil)
         return;
     
-    NSTableColumn *tableColumn = [tableView tableColumnWithIdentifier:key ?: 
sortKey];
-    
     if (key == nil) {
         // a nil argument means resort the current column in the same order
-    } else if ([sortKey isEqualToString:key]) {
-        // User clicked same column, change sort order
-        docFlags.sortDescending = !docFlags.sortDescending;
-    } else {
-        // User clicked new column, change old/new column headers,
-        // save new sorting selector, and re-sort the array.
-        if (sortKey)
-            [tableView setIndicatorImage:nil inTableColumn:[tableView 
tableColumnWithIdentifier:sortKey]];
-        if (isImportOrderOrRelevance(sortKey)) {
-            // this is probably after removing an ImportOrder or Relevance 
column, try to reinstate the previous sort order
-            if ([key isEqualToString:previousSortKey])
-                docFlags.sortDescending = docFlags.previousSortDescending;
-            else
-                docFlags.sortDescending = [key 
isEqualToString:BDSKRelevanceString];
-        } else {
-            if ([previousSortKey isEqualToString:sortKey] == NO) {
-                [previousSortKey release];
-                previousSortKey = [sortKey retain];
-            }
+    } else if ([key isEqualToString:BDSKImportOrderString] == NO && [key 
isEqualToString:BDSKRelevanceString] == NO) {
+        if ([sortKey isEqualToString:key] == NO) {
+            [previousSortKey release];
+            previousSortKey = [sortKey retain];
             docFlags.previousSortDescending = docFlags.sortDescending;
-            docFlags.sortDescending = [key 
isEqualToString:BDSKRelevanceString];
+            [sortKey release];
+            sortKey = [key retain];
+            docFlags.sortDescending = NO;
+        } else if (tmpSortKey == nil) {
+            // User clicked same column, change sort order, 
+            // however if tmpSortKey was set this is probably after removing 
an ImportOrder or Relevance column, and we should reinstate the previous sort 
order
+            docFlags.sortDescending = !docFlags.sortDescending;
         }
-        [sortKey release];
-        sortKey = [key retain];
-        [tableView setHighlightedTableColumn:tableColumn]; 
-       }
+        BDSKDESTROY(tmpSortKey);
+    } else if ([tmpSortKey isEqualToString:key]) {
+        // User clicked same column, change sort order
+        docFlags.tmpSortDescending = !docFlags.tmpSortDescending;
+    } else {
+        [tmpSortKey release];
+        tmpSortKey = [key retain];
+        docFlags.tmpSortDescending = [key isEqualToString:BDSKRelevanceString];
+    }
     
     if (previousSortKey == nil) {
         previousSortKey = [sortKey retain];
@@ -2523,9 +2499,24 @@
     }
     
     NSString *userInfo = [[self fileURL] path];
-    NSArray *sortDescriptors = [NSArray 
arrayWithObjects:[BDSKTableSortDescriptor 
tableSortDescriptorForIdentifier:sortKey ascending:!docFlags.sortDescending 
userInfo:userInfo], [BDSKTableSortDescriptor 
tableSortDescriptorForIdentifier:previousSortKey 
ascending:!docFlags.previousSortDescending userInfo:userInfo], nil];
+    NSMutableArray *sortDescriptors = [NSMutableArray array];
+    if (tmpSortKey)
+        [sortDescriptors addObject:[BDSKTableSortDescriptor 
tableSortDescriptorForIdentifier:tmpSortKey 
ascending:!docFlags.tmpSortDescending userInfo:userInfo]];
+    [sortDescriptors addObject:[BDSKTableSortDescriptor 
tableSortDescriptorForIdentifier:sortKey ascending:!docFlags.sortDescending 
userInfo:userInfo]];
+    [sortDescriptors addObject:[BDSKTableSortDescriptor 
tableSortDescriptorForIdentifier:previousSortKey 
ascending:!docFlags.previousSortDescending userInfo:userInfo]];
     [tableView setSortDescriptors:sortDescriptors]; // just using this to 
store them; it's really a no-op
     
+    // Set the graphic for the new column header
+    NSTableColumn *oldTC = [tableView highlightedTableColumn];
+    NSTableColumn *newTC = [tableView tableColumnWithIdentifier:(tmpSortKey ?: 
sortKey)];
+    BOOL sortDescending = tmpSortKey == nil ? docFlags.sortDescending : 
docFlags.tmpSortDescending;
+    if ([oldTC isEqual:newTC] == NO) {
+        [tableView setHighlightedTableColumn:newTC];
+        if (oldTC)
+            [tableView setIndicatorImage:nil inTableColumn:oldTC];
+    }
+    [tableView setIndicatorImage:[NSImage imageNamed:(sortDescending ? 
@"NSDescendingSortIndicator" : @"NSAscendingSortIndicator")] 
inTableColumn:newTC];
+    
     // @@ DON'T RETURN WITHOUT RESETTING THIS!
     // this is a hack to keep us from getting selection change notifications 
while sorting (which updates the TeX and attributed text previews)
     docFlags.ignoreSelectionChange = YES;
@@ -2537,18 +2528,14 @@
     
     // sort by new primary column, subsort with previous primary column
     [shownPublications mergeSortUsingDescriptors:sortDescriptors];
-
-    // Set the graphic for the new column header
-    [tableView setIndicatorImage: [NSImage imageNamed:(docFlags.sortDescending 
? @"NSDescendingSortIndicator" : @"NSAscendingSortIndicator")]
-                   inTableColumn: tableColumn];
-
+    
     // have to reload so the rows get set up right, but a full updateStatus 
flashes the preview, which is annoying (and the preview won't change if we're 
maintaining the selection)
     [tableView reloadData];
-
+    
     // fix the selection
     [self selectPublications:pubsToSelect];
     [tableView scrollRowToCenter:[tableView selectedRow]]; // just go to the 
last one
-
+    
     // reset
     docFlags.ignoreSelectionChange = NO;
 }
@@ -2556,32 +2543,14 @@
 - (void)saveSortOrder{ 
     // @@ if we switch to NSArrayController, we should just archive the sort 
descriptors (see BDSKFileContentSearchController)
     NSUserDefaults*sud = [NSUserDefaults standardUserDefaults];
-    NSString *savedSortKey = nil;
-    BOOL savedSortDescending = docFlags.sortDescending;
-    NSString *savedSubsortKey = nil;
-    BOOL savedSubsortDescending = docFlags.previousSortDescending;
-    if (isImportOrderOrRelevance(sortKey) == NO) {
-        savedSortKey = sortKey;
-        savedSortDescending = docFlags.sortDescending;
-    } else if (isImportOrderOrRelevance(previousSortKey) == NO) {
-        savedSortKey = previousSortKey;
-        savedSortDescending = docFlags.previousSortDescending;
+    if (sortKey) {
+        [sud setObject:sortKey forKey:BDSKDefaultSortedTableColumnKey];
+        [sud setBool:docFlags.sortDescending 
forKey:BDSKDefaultSortedTableColumnIsDescendingKey];
     }
-    if (isImportOrderOrRelevance(previousSortKey) == NO) {
-        savedSubsortKey = sortKey;
-        savedSubsortDescending = docFlags.sortDescending;
-    } else {
-        savedSubsortKey = savedSortKey;
-        savedSubsortDescending = savedSortDescending;
+    if (previousSortKey) {
+        [sud setObject:previousSortKey 
forKey:BDSKDefaultSubsortedTableColumnKey];
+        [sud setBool:docFlags.previousSortDescending 
forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey];
     }
-    if (savedSortKey) {
-        [sud setObject:savedSortKey forKey:BDSKDefaultSortedTableColumnKey];
-        [sud setBool:savedSortDescending 
forKey:BDSKDefaultSortedTableColumnIsDescendingKey];
-    }
-    if (savedSubsortKey) {
-        [sud setObject:savedSortKey forKey:BDSKDefaultSubsortedTableColumnKey];
-        [sud setBool:savedSortDescending 
forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey];
-    }
     [sud setObject:sortGroupsKey forKey:BDSKSortGroupsKey];
     [sud setBool:docFlags.sortGroupsDescending 
forKey:BDSKSortGroupsDescendingKey];    
 }  

Modified: trunk/bibdesk/BibDocument_Actions.m
===================================================================
--- trunk/bibdesk/BibDocument_Actions.m 2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument_Actions.m 2011-06-02 10:12:55 UTC (rev 17919)
@@ -1701,17 +1701,18 @@
     
     CFIndex idx = [shownPublications count];
     id object1 = nil, object2 = nil;
+    NSString *key = tmpSortKey ?: sortKey;
     
-    BDSKASSERT(sortKey);
+    BDSKASSERT(key);
     
     NSMutableIndexSet *rowsToSelect = [NSMutableIndexSet indexSet];
     CFIndex countOfItems = 0;
-    BOOL isURL = [sortKey isGeneralURLField];
+    BOOL isURL = [key isGeneralURLField];
     
     // Compare objects in the currently sorted table column using the isEqual: 
method to test adjacent cells in order to check for duplicates based on a 
specific sort key.  BibTool does this, but its effectiveness is obviously 
limited by the key used 
<http://lml.ls.fi.upm.es/manuales/bibtool/m_2_11_1.html>.
     while(idx--){
         object1 = object2;
-        object2 = isURL ? [[shownPublications objectAtIndex:idx] 
valueOfField:sortKey] : [[shownPublications objectAtIndex:idx] 
displayValueOfField:sortKey];
+        object2 = isURL ? [[shownPublications objectAtIndex:idx] 
valueOfField:key] : [[shownPublications objectAtIndex:idx] 
displayValueOfField:key];
         if([object1 isEqual:object2]){
             [rowsToSelect addIndexesInRange:NSMakeRange(idx, 2)];
             countOfItems++;

Modified: trunk/bibdesk/BibDocument_DataSource.m
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.m      2011-06-02 06:35:17 UTC (rev 
17918)
+++ trunk/bibdesk/BibDocument_DataSource.m      2011-06-02 10:12:55 UTC (rev 
17919)
@@ -806,17 +806,17 @@
 
 // used for status bar
 - (void)tableView:(NSTableView *)tv typeSelectHelper:(BDSKTypeSelectHelper 
*)typeSelectHelper updateSearchString:(NSString *)searchString{
-    if(searchString == nil || sortKey == nil)
+    if(searchString == nil || (sortKey == nil && tmpSortKey == nil))
         [self updateStatus]; // resets the status line to its default value
     else if([tv isEqual:tableView]) 
-        [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"Finding 
item with %@: \"%@\"", @"Status message:Finding item with [sorting field]: 
\"[search string]\""), [sortKey localizedFieldName], searchString]];
+        [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"Finding 
item with %@: \"%@\"", @"Status message:Finding item with [sorting field]: 
\"[search string]\""), [(tmpSortKey ?: sortKey) localizedFieldName], 
searchString]];
 }
 
 - (void)tableView:(NSTableView *)tv typeSelectHelper:(BDSKTypeSelectHelper 
*)typeSelectHelper didFailToFindMatchForSearchString:(NSString *)searchString{
-    if(sortKey == nil)
+    if(sortKey == nil && tmpSortKey == nil)
         [self updateStatus]; // resets the status line to its default value
     else if([tv isEqual:tableView]) 
-        [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"No item 
with %@: \"%@\"", @"Status message:No item with [sorting field]: \"[search 
string]\""), [sortKey localizedFieldName], searchString]];
+        [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"No item 
with %@: \"%@\"", @"Status message:No item with [sorting field]: \"[search 
string]\""), [(tmpSortKey ?: sortKey) localizedFieldName], searchString]];
 }
 
 // This is where we build the list of possible items which the user can select 
by typing the first few letters. You should return an array of NSStrings.
@@ -831,15 +831,16 @@
         
         NSUInteger i, count = [shownPublications count];
         NSMutableArray *a = [NSMutableArray arrayWithCapacity:count];
-
+        NSString *key = tmpSortKey ?: sortKey;
+        
         // table datasource returns an NSImage for URL fields, so we'll ignore 
those columns
-        if(nil != sortKey && [sortKey isGeneralURLField] == NO){
+        if(nil != key && [key isGeneralURLField] == NO){
             BibItem *pub;
             id value;
             
             for (i = 0; i < count; i++){
                 pub = [shownPublications objectAtIndex:i];
-                value = [pub displayValueOfField:sortKey];
+                value = [pub displayValueOfField:key];
                 
                 // use @"" for nil values; ensure typeahead index matches 
shownPublications index
                 [a addObject:value ? [value description] : @""];
@@ -1416,14 +1417,14 @@
 
 // used for status bar
 - (void)outlineView:(NSOutlineView *)ov typeSelectHelper:(BDSKTypeSelectHelper 
*)typeSelectHelper updateSearchString:(NSString *)searchString{
-    if (searchString == nil || sortKey == nil)
+    if (searchString == nil || (sortKey == nil && tmpSortKey == nil))
         [self updateStatus]; // resets the status line to its default value
     else if ([ov isEqual:groupOutlineView]) 
         [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"Finding 
group: \"%@\"", @"Status message:Finding group: \"[search string]\""), 
searchString]];
 }
 
 - (void)outlineView:(NSOutlineView *)ov typeSelectHelper:(BDSKTypeSelectHelper 
*)typeSelectHelper didFailToFindMatchForSearchString:(NSString *)searchString{
-    if (sortKey == nil)
+    if (sortKey == nil && tmpSortKey == nil)
         [self updateStatus]; // resets the status line to its default value
     else if ([ov isEqual:groupOutlineView]) 
         [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"No 
group: \"%@\"", @"Status message:No group: \"[search string]\""), 
searchString]];

Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m  2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument_Groups.m  2011-06-02 10:12:55 UTC (rev 17919)
@@ -355,14 +355,8 @@
         
         [tableView setAlternatingRowBackgroundColors:[NSColor 
controlAlternatingRowBackgroundColors]];
         [tableView removeTableColumnWithIdentifier:BDSKImportOrderString];
-        if ([previousSortKey isEqualToString:BDSKImportOrderString]) {
-            [previousSortKey release];
-            previousSortKey = [BDSKTitleString retain];
-            docFlags.previousSortDescending = NO;
-        }
-        if ([sortKey isEqualToString:BDSKImportOrderString]) {
-            newSortKey = [[previousSortKey retain] autorelease];
-        }
+        if ([tmpSortKey isEqualToString:BDSKImportOrderString])
+            newSortKey = sortKey;
         [self hideSearchGroupView];
         [self hideWebGroupView];
     }

Modified: trunk/bibdesk/BibDocument_Menus.m
===================================================================
--- trunk/bibdesk/BibDocument_Menus.m   2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument_Menus.m   2011-06-02 10:12:55 UTC (rev 17919)
@@ -422,7 +422,7 @@
 }
 
 - (BOOL) validateSelectPossibleDuplicatesMenuItem:(NSMenuItem *)menuItem{
-    [menuItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"Select 
Duplicates by %@", @"Menu item title"), [sortKey localizedFieldName]]];
+    [menuItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"Select 
Duplicates by %@", @"Menu item title"), [(tmpSortKey ?: sortKey) 
localizedFieldName]]];
     return ([self hasExternalGroupsSelected] == NO);
 }
 

Modified: trunk/bibdesk/BibDocument_Search.m
===================================================================
--- trunk/bibdesk/BibDocument_Search.m  2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument_Search.m  2011-06-02 10:12:55 UTC (rev 17919)
@@ -221,13 +221,8 @@
         [searchButtonBar setAction:NULL];
         [searchButtonBar 
selectButtonWithRepresentedObject:BDSKAllFieldsString];
         
-        if ([previousSortKey isEqualToString:BDSKRelevanceString]) {
-            [previousSortKey release];
-            previousSortKey = [BDSKTitleString retain];
-            docFlags.previousSortDescending = NO;
-        }
-        if ([sortKey isEqualToString:BDSKRelevanceString])
-            [self sortPubsByKey:[[previousSortKey retain] autorelease]];
+        if ([tmpSortKey isEqualToString:BDSKRelevanceString])
+            [self sortPubsByKey:sortKey];
     }
 }
 

Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m      2011-06-02 06:35:17 UTC (rev 17918)
+++ trunk/bibdesk/BibDocument_UI.m      2011-06-02 10:12:55 UTC (rev 17919)
@@ -867,23 +867,23 @@
     [self setImported:isDelete == NO forPublications:pubs inGroup:nil];
 }
 
-static BOOL sortKeyDependsOnKey(NSString *sortKey, NSString *key) {
+static BOOL sortKeyDependsOnKey(NSString *aSortKey, NSString *key) {
     if (key == nil)
         return YES;
-    else if([sortKey isEqualToString:BDSKTitleString])
+    else if([aSortKey isEqualToString:BDSKTitleString])
         return [key isEqualToString:BDSKTitleString] || [key 
isEqualToString:BDSKChapterString] || [key isEqualToString:BDSKPagesString] || 
[key isEqualToString:BDSKPubTypeString];
-    else if([sortKey isEqualToString:BDSKContainerString])
+    else if([aSortKey isEqualToString:BDSKContainerString])
         return [key isEqualToString:BDSKJournalString] || [key 
isEqualToString:BDSKBooktitleString] || [key isEqualToString:BDSKVolumeString] 
|| [key isEqualToString:BDSKSeriesString] || [key 
isEqualToString:BDSKPubTypeString];
-    else if([sortKey isEqualToString:BDSKPubDateString])
+    else if([aSortKey isEqualToString:BDSKPubDateString])
         return [key isEqualToString:BDSKYearString] || [key 
isEqualToString:BDSKMonthString];
-    else if([sortKey isEqualToString:BDSKFirstAuthorString] || [sortKey 
isEqualToString:BDSKSecondAuthorString] || [sortKey 
isEqualToString:BDSKThirdAuthorString] || [sortKey 
isEqualToString:BDSKLastAuthorString])
+    else if([aSortKey isEqualToString:BDSKFirstAuthorString] || [aSortKey 
isEqualToString:BDSKSecondAuthorString] || [aSortKey 
isEqualToString:BDSKThirdAuthorString] || [aSortKey 
isEqualToString:BDSKLastAuthorString])
         return [key isEqualToString:BDSKAuthorString];
-    else if([sortKey isEqualToString:BDSKFirstAuthorEditorString] || [sortKey 
isEqualToString:BDSKSecondAuthorEditorString] || [sortKey 
isEqualToString:BDSKThirdAuthorEditorString] || [sortKey 
isEqualToString:BDSKLastAuthorEditorString])
+    else if([aSortKey isEqualToString:BDSKFirstAuthorEditorString] || 
[aSortKey isEqualToString:BDSKSecondAuthorEditorString] || [aSortKey 
isEqualToString:BDSKThirdAuthorEditorString] || [aSortKey 
isEqualToString:BDSKLastAuthorEditorString])
         return [key isEqualToString:BDSKAuthorString] || [key 
isEqualToString:BDSKEditorString];
-    else if([sortKey isEqualToString:BDSKColorString] || [sortKey 
isEqualToString:BDSKColorLabelString])
+    else if([aSortKey isEqualToString:BDSKColorString] || [aSortKey 
isEqualToString:BDSKColorLabelString])
         return [key isEqualToString:BDSKColorString] || [key 
isEqualToString:BDSKColorLabelString];
     else
-        return [sortKey isEqualToString:key];
+        return [aSortKey isEqualToString:key];
 }
 
 static BOOL searchKeyDependsOnKey(NSString *searchKey, NSString *key) {
@@ -1021,7 +1021,7 @@
     
     if ([changedKey isEqualToString:[self currentGroupField]] || changedKey == 
nil)
         docFlags.itemChangeMask |= BDSKItemChangedGroupFieldMask;
-    if (sortKeyDependsOnKey(sortKey, changedKey) || 
sortKeyDependsOnKey(previousSortKey, changedKey))
+    if ((tmpSortKey && sortKeyDependsOnKey(tmpSortKey, changedKey)) || 
sortKeyDependsOnKey(sortKey, changedKey) || 
sortKeyDependsOnKey(previousSortKey, changedKey))
         docFlags.itemChangeMask |= BDSKItemChangedSortKeyMask;
     if ([self isDisplayingSearchButtons] && 
searchKeyDependsOnKey([searchButtonBar representedObjectOfSelectedButton], 
changedKey))
         docFlags.itemChangeMask |= BDSKItemChangedSearchKeyMask;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to