Revision: 17934
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=17934&view=rev
Author: hofman
Date: 2011-06-04 09:46:23 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
save sort order in prefs when sorting changes
Modified Paths:
--------------
trunk/bibdesk/BibDocument.h
trunk/bibdesk/BibDocument.m
trunk/bibdesk/BibDocument_Groups.m
Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2011-06-04 06:35:15 UTC (rev 17933)
+++ trunk/bibdesk/BibDocument.h 2011-06-04 09:46:23 UTC (rev 17934)
@@ -421,13 +421,6 @@
- (void)setDocumentStringEncoding:(NSStringEncoding)encoding;
/*!
- @method saveSortOrder
- @abstract Saves current sort order to preferences, to be restored on
next launch/document open.
- @discussion (comprehensive description)
-*/
-- (void)saveSortOrder;
-
-/*!
@method userChangedField:ofPublications:from:to:
@abstract Autofiles and generates citekey if we should and runs a script
hook
@discussion (comprehensive description)
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2011-06-04 06:35:15 UTC (rev 17933)
+++ trunk/bibdesk/BibDocument.m 2011-06-04 09:46:23 UTC (rev 17934)
@@ -648,7 +648,6 @@
if([drawerController isDrawerOpen])
[drawerController toggle:nil];
- [self saveSortOrder];
[self saveWindowSetupInExtendedAttributesAtURL:[self fileURL]
forEncoding:BDSKNoStringEncoding];
// reset the previewer; don't send [self updatePreviews:] here, as the
tableview will be gone by the time the queue posts the notification
@@ -2468,6 +2467,8 @@
if (key == nil && sortKey == nil)
return;
+ BOOL shouldSave = NO;
+
if (key == nil) {
// a nil argument means resort the current column in the same order
} else if ([key isEqualToString:BDSKImportOrderString] == NO && [key
isEqualToString:BDSKRelevanceString] == NO) {
@@ -2478,10 +2479,12 @@
[sortKey release];
sortKey = [key retain];
docFlags.sortDescending = NO;
+ shouldSave = YES;
} 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;
+ shouldSave = YES;
}
BDSKDESTROY(tmpSortKey);
} else if ([tmpSortKey isEqualToString:key]) {
@@ -2498,6 +2501,14 @@
docFlags.previousSortDescending = docFlags.sortDescending;
}
+ if (shouldSave) {
+ NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
+ [sud setObject:sortKey forKey:BDSKDefaultSortedTableColumnKey];
+ [sud setBool:docFlags.sortDescending
forKey:BDSKDefaultSortedTableColumnIsDescendingKey];
+ [sud setObject:previousSortKey
forKey:BDSKDefaultSubsortedTableColumnKey];
+ [sud setBool:docFlags.previousSortDescending
forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey];
+ }
+
NSMutableArray *sortDescriptors = [NSMutableArray arrayWithObjects:
[BDSKTableSortDescriptor tableSortDescriptorForIdentifier:sortKey
ascending:!docFlags.sortDescending],
[BDSKTableSortDescriptor
tableSortDescriptorForIdentifier:previousSortKey
ascending:!docFlags.previousSortDescending], nil];
@@ -2544,21 +2555,6 @@
docFlags.ignoreSelectionChange = NO;
}
-- (void)saveSortOrder{
- // @@ if we switch to NSArrayController, we should just archive the sort
descriptors (see BDSKFileContentSearchController)
- NSUserDefaults*sud = [NSUserDefaults standardUserDefaults];
- if (sortKey) {
- [sud setObject:sortKey forKey:BDSKDefaultSortedTableColumnKey];
- [sud setBool:docFlags.sortDescending
forKey:BDSKDefaultSortedTableColumnIsDescendingKey];
- }
- if (previousSortKey) {
- [sud setObject:previousSortKey
forKey:BDSKDefaultSubsortedTableColumnKey];
- [sud setBool:docFlags.previousSortDescending
forKey:BDSKDefaultSubsortedTableColumnIsDescendingKey];
- }
- [sud setObject:sortGroupsKey forKey:BDSKSortGroupsKey];
- [sud setBool:docFlags.sortGroupsDescending
forKey:BDSKSortGroupsDescendingKey];
-}
-
#pragma mark -
#pragma mark Selection
Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m 2011-06-04 06:35:15 UTC (rev 17933)
+++ trunk/bibdesk/BibDocument_Groups.m 2011-06-04 09:46:23 UTC (rev 17934)
@@ -1515,6 +1515,11 @@
}
}
+ if (key) {
+ [[NSUserDefaults standardUserDefaults] setObject:sortGroupsKey
forKey:BDSKSortGroupsKey];
+ [[NSUserDefaults standardUserDefaults]
setBool:docFlags.sortGroupsDescending forKey:BDSKSortGroupsDescendingKey];
+ }
+
// this is a hack to keep us from getting selection change notifications
while sorting (which updates the TeX and attributed text previews)
docFlags.ignoreGroupSelectionChange = YES;
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. Discover what all the cheering's about.
Get your free trial download today.
http://p.sf.net/sfu/quest-dev2dev2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit