Revision: 27691
http://sourceforge.net/p/bibdesk/svn/27691
Author: hofman
Date: 2022-07-05 09:34:36 +0000 (Tue, 05 Jul 2022)
Log Message:
-----------
first try updating only category and/or smart groups when needed after item
changes
Modified Paths:
--------------
trunk/bibdesk/BibDocument_Groups.h
trunk/bibdesk/BibDocument_Groups.m
trunk/bibdesk/BibDocument_UI.m
Modified: trunk/bibdesk/BibDocument_Groups.h
===================================================================
--- trunk/bibdesk/BibDocument_Groups.h 2022-07-05 06:30:17 UTC (rev 27690)
+++ trunk/bibdesk/BibDocument_Groups.h 2022-07-05 09:34:36 UTC (rev 27691)
@@ -55,6 +55,7 @@
- (void)updateSmartGroups;
- (void)updateFilteringGroups;
+- (BOOL)updateCategoryGroups:(BOOL)updateCategoryGroups
smartGroups:(BOOL)updateSmartGroups;
- (void)displaySelectedGroups;
- (BOOL)addPublications:(NSArray *)pubs toGroup:(BDSKCategoryGroup *)group;
Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m 2022-07-05 06:30:17 UTC (rev 27690)
+++ trunk/bibdesk/BibDocument_Groups.m 2022-07-05 09:34:36 UTC (rev 27691)
@@ -576,6 +576,40 @@
[self reloadParentGroup:nil];
}
+- (BOOL)updateCategoryGroups:(BOOL)updateCategoryGroups
smartGroups:(BOOL)updateSmartGroups {
+ NSMutableArray *parentsToReload = [NSMutableArray array];
+ BOOL isSelected = NO;
+
+ if (updateSmartGroups) {
+ [[groups smartGroups]
makeObjectsPerformSelector:@selector(invalidateCount)];
+ isSelected = [self hasGroupTypeSelected:BDSKSmartGroupType];
+ if ([groupOutlineView isItemExpanded:[groups smartParent]] &&
[sortGroupsKey isEqualToString:BDSKDocumentCountKey]) {
+ [[groups smartParent] resort];
+ [parentsToReload addObject:[groups smartParent]];
+ }
+ }
+
+ if (updateCategoryGroups) {
+ isSelected = isSelected || [self
hasGroupTypeSelected:BDSKCategoryGroupType];
+ for (BDSKCategoryParentGroup *parent in [groups categoryParents]) {
+ [self willRemoveGroups:[parent children]];
+ [self rebuildCategoryGroups:parent];
+ if ([groupOutlineView isItemExpanded:parent])
+ [parentsToReload addObject:parent];
+ }
+ }
+
+ if ([parentsToReload count] == 1)
+ [self reloadParentGroup:[parentsToReload firstObject]];
+ else if ([parentsToReload count])
+ [self reloadParentGroup:nil];
+ else if (isSelected)
+ [self displaySelectedGroups];
+ else
+ return NO;
+ return YES;
+}
+
- (void)displaySelectedGroups{
NSArray *selectedGroups = [self selectedGroups];
NSArray *array;
Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m 2022-07-05 06:30:17 UTC (rev 27690)
+++ trunk/bibdesk/BibDocument_UI.m 2022-07-05 09:34:36 UTC (rev 27691)
@@ -1375,40 +1375,30 @@
[self previewURLs:nil];
}
- if((docFlags.itemChangeMask & BDSKItemChangedGroupFieldMask) != 0){
- // this handles all UI updates if we call it, so don't bother with any
others
- [self updateFilteringGroups];
- } else {
- BOOL needsReload = displayingLocal;
- // allow updating a smart group if it's selected
- if ((docFlags.itemChangeMask & BDSKItemChangedSmartGroupMask) != 0) {
- [[groups smartGroups]
makeObjectsPerformSelector:@selector(invalidateCount)];
- [self updateSmartGroups];
- needsReload = needsReload && NO == [self
hasGroupTypeSelected:BDSKSmartGroupType];
- }
- if (needsReload) {
- if ((docFlags.itemChangeMask & BDSKItemChangedSearchKeyMask) != 0)
{
- // this handles all UI updates if we call it, so don't bother
with any others
- [self search:nil];
- } else if ((docFlags.itemChangeMask & BDSKItemChangedSortKeyMask)
!= 0) {
- // groups and quicksearch won't update for us
- [self sortPubsByKey:nil];
- } else {
- NSArray *colIDs = [tableView tableColumnIdentifiers];
- for (BibItem *aPub in changedPublications) {
- NSUInteger row = [shownPublications indexOfObject:aPub];
- if (row == NSNotFound) continue;
- [[tableView rowViewAtRow:row makeIfNecessary:NO]
setColor:[aPub color]];
- [colIDs enumerateObjectsUsingBlock:^(NSString *colID,
NSUInteger column, BOOL *stop){
- NSTableCellView *view = [tableView viewAtColumn:column
row:row makeIfNecessary:NO];
- if (view)
- [self updateView:view forField:colID ofItem:aPub];
- }];
- }
+ BOOL didReload = [self updateCategoryGroups:(docFlags.itemChangeMask &
BDSKItemChangedGroupFieldMask) != 0 smartGroups:(docFlags.itemChangeMask &
BDSKItemChangedSmartGroupMask) != 0];
+
+ if (didReload == NO && displayingLocal) {
+ if ((docFlags.itemChangeMask & BDSKItemChangedSearchKeyMask) != 0) {
+ // this handles all UI updates if we call it, so don't bother with
any others
+ [self search:nil];
+ } else if ((docFlags.itemChangeMask & BDSKItemChangedSortKeyMask) !=
0) {
+ // groups and quicksearch won't update for us
+ [self sortPubsByKey:nil];
+ } else {
+ NSArray *colIDs = [tableView tableColumnIdentifiers];
+ for (BibItem *aPub in changedPublications) {
+ NSUInteger row = [shownPublications indexOfObject:aPub];
+ if (row == NSNotFound) continue;
+ [[tableView rowViewAtRow:row makeIfNecessary:NO]
setColor:[aPub color]];
+ [colIDs enumerateObjectsUsingBlock:^(NSString *colID,
NSUInteger column, BOOL *stop){
+ NSTableCellView *view = [tableView viewAtColumn:column
row:row makeIfNecessary:NO];
+ if (view)
+ [self updateView:view forField:colID ofItem:aPub];
+ }];
}
- if (changedIsSelected)
- [self updatePreviews];
}
+ if (changedIsSelected)
+ [self updatePreviews];
}
[changedPublications removeAllObjects];
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