From: <ho...@us...> - 2011-05-21 11:55:27
|
Revision: 17899 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=17899&view=rev Author: hofman Date: 2011-05-21 11:55:20 +0000 (Sat, 21 May 2011) Log Message: ----------- save subsort key in xattr and prefs when relevant Modified Paths: -------------- trunk/bibdesk/BDSKStringConstants.h trunk/bibdesk/BDSKStringConstants.m trunk/bibdesk/BibDocument.m Modified: trunk/bibdesk/BDSKStringConstants.h =================================================================== --- trunk/bibdesk/BDSKStringConstants.h 2011-05-21 11:39:51 UTC (rev 17898) +++ trunk/bibdesk/BDSKStringConstants.h 2011-05-21 11:55:20 UTC (rev 17899) @@ -134,6 +134,8 @@ extern NSString *BDSKColumnWidthsKey; extern NSString *BDSKDefaultSortedTableColumnKey; extern NSString *BDSKDefaultSortedTableColumnIsDescendingKey; +extern NSString *BDSKDefaultSubsortedTableColumnKey; +extern NSString *BDSKDefaultSubsortedTableColumnIsDescendingKey; extern NSString *BDSKSortGroupsKey; extern NSString *BDSKSortGroupsDescendingKey; Modified: trunk/bibdesk/BDSKStringConstants.m =================================================================== --- trunk/bibdesk/BDSKStringConstants.m 2011-05-21 11:39:51 UTC (rev 17898) +++ trunk/bibdesk/BDSKStringConstants.m 2011-05-21 11:55:20 UTC (rev 17899) @@ -101,6 +101,8 @@ NSString *BDSKColumnWidthsKey = @"Column Widths by Name"; NSString *BDSKDefaultSortedTableColumnKey = @"Default table column to sort new documents"; NSString *BDSKDefaultSortedTableColumnIsDescendingKey = @"Default table column sort order"; +NSString *BDSKDefaultSubsortedTableColumnKey = @"Default table column to subsort new documents"; +NSString *BDSKDefaultSubsortedTableColumnIsDescendingKey = @"Default table column subsort order"; NSString *BDSKSortGroupsKey = @"BDSKSortGroupsKey"; NSString *BDSKSortGroupsDescendingKey = @"BDSKSortGroupsDescendingKey"; Modified: trunk/bibdesk/BibDocument.m =================================================================== --- trunk/bibdesk/BibDocument.m 2011-05-21 11:39:51 UTC (rev 17898) +++ trunk/bibdesk/BibDocument.m 2011-05-21 11:55:20 UTC (rev 17899) @@ -493,9 +493,13 @@ tableColumnWidths = [[xattrDefaults objectForKey:BDSKColumnWidthsKey] retain]; [tableView setupTableColumnsWithIdentifiers:[xattrDefaults objectForKey:BDSKShownColsNamesKey] ?: [sud objectForKey:BDSKShownColsNamesKey]]; sortKey = [[xattrDefaults objectForKey:BDSKDefaultSortedTableColumnKey] ?: [sud objectForKey:BDSKDefaultSortedTableColumnKey] retain]; - previousSortKey = [sortKey retain]; - docFlags.sortDescending = [xattrDefaults boolForKey:BDSKDefaultSortedTableColumnIsDescendingKey defaultValue:[sud boolForKey:BDSKDefaultSortedTableColumnIsDescendingKey]]; - docFlags.previousSortDescending = docFlags.sortDescending; + docFlags.sortDescending = [xattrDefaults boolForKey:BDSKDefaultSortedTableColumnIsDescendingKey defaultValue:[sud boolForKey:BDSKDefaultSortedTableColumnIsDescendingKey]]; + previousSortKey = [[xattrDefaults objectForKey:BDSKDefaultSubsortedTableColumnKey] ?: [sud objectForKey:BDSKDefaultSubsortedTableColumnKey] retain]; + docFlags.previousSortDescending = [xattrDefaults boolForKey:BDSKDefaultSubsortedTableColumnIsDescendingKey defaultValue:[sud boolForKey:BDSKDefaultSubsortedTableColumnIsDescendingKey]]; + if (previousSortKey == nil) { + previousSortKey = [sortKey retain]; + docFlags.previousSortDescending = docFlags.sortDescending; + } [tableView setHighlightedTableColumn:[tableView tableColumnWithIdentifier:sortKey]]; [sortGroupsKey autorelease]; @@ -702,15 +706,30 @@ NSMutableDictionary *dictionary = [[self mainWindowSetupDictionaryFromExtendedAttributes] mutableCopy]; NSString *savedSortKey = nil; - if (isImportOrderOrRelevance(sortKey) == NO) + BOOL savedSortDescending = docFlags.sortDescending; + NSString *savedSubsortKey = nil; + BOOL savedSubsortDescending = docFlags.previousSortDescending; + if (isImportOrderOrRelevance(sortKey) == NO) { savedSortKey = sortKey; - else if (isImportOrderOrRelevance(previousSortKey) == NO) + 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:docFlags.sortDescending forKey:BDSKDefaultSortedTableColumnIsDescendingKey]; + [dictionary setBoolValue:savedSortDescending forKey:BDSKDefaultSortedTableColumnIsDescendingKey]; + [dictionary setObject:savedSubsortKey ?: BDSKTitleString forKey:BDSKDefaultSubsortedTableColumnKey]; + [dictionary setBoolValue:savedSortDescending forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey]; [dictionary setObject:sortGroupsKey forKey:BDSKSortGroupsKey]; [dictionary setBoolValue:docFlags.sortGroupsDescending forKey:BDSKSortGroupsDescendingKey]; [dictionary setRectValue:[documentWindow frame] forKey:BDSKDocumentWindowFrameKey]; @@ -2538,13 +2557,31 @@ // @@ if we switch to NSArrayController, we should just archive the sort descriptors (see BDSKFileContentSearchController) NSUserDefaults*sud = [NSUserDefaults standardUserDefaults]; NSString *savedSortKey = nil; - if (isImportOrderOrRelevance(sortKey) == NO) + BOOL savedSortDescending = docFlags.sortDescending; + NSString *savedSubsortKey = nil; + BOOL savedSubsortDescending = docFlags.previousSortDescending; + if (isImportOrderOrRelevance(sortKey) == NO) { savedSortKey = sortKey; - else if (isImportOrderOrRelevance(previousSortKey) == NO) + savedSortDescending = docFlags.sortDescending; + } else if (isImportOrderOrRelevance(previousSortKey) == NO) { savedSortKey = previousSortKey; - if (savedSortKey) + savedSortDescending = docFlags.previousSortDescending; + } + if (isImportOrderOrRelevance(previousSortKey) == NO) { + savedSubsortKey = sortKey; + savedSubsortDescending = docFlags.sortDescending; + } else { + savedSubsortKey = savedSortKey; + savedSubsortDescending = savedSortDescending; + } + if (savedSortKey) { [sud setObject:savedSortKey forKey:BDSKDefaultSortedTableColumnKey]; - [sud setBool:docFlags.sortDescending forKey:BDSKDefaultSortedTableColumnIsDescendingKey]; + [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]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |