Revision: 27689
http://sourceforge.net/p/bibdesk/svn/27689
Author: hofman
Date: 2022-07-04 15:10:01 +0000 (Mon, 04 Jul 2022)
Log Message:
-----------
only reload smart groups when any of its conditions depend on the change
Modified Paths:
--------------
trunk/bibdesk/BibDocument.h
trunk/bibdesk/BibDocument_UI.m
Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2022-07-04 14:09:13 UTC (rev 27688)
+++ trunk/bibdesk/BibDocument.h 2022-07-04 15:10:01 UTC (rev 27689)
@@ -257,7 +257,7 @@
} docState;
struct _docFlags {
- unsigned int itemChangeMask:4;
+ unsigned int itemChangeMask:5;
unsigned int sortDescending:1;
unsigned int previousSortDescending:1;
unsigned int tmpSortDescending:1;
Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m 2022-07-04 14:09:13 UTC (rev 27688)
+++ trunk/bibdesk/BibDocument_UI.m 2022-07-04 15:10:01 UTC (rev 27689)
@@ -97,9 +97,10 @@
enum {
BDSKItemChangedGroupFieldMask = 1 << 0,
- BDSKItemChangedSearchKeyMask = 1 << 1,
- BDSKItemChangedSortKeyMask = 1 << 2,
- BDSKItemChangedFilesMask = 1 << 3
+ BDSKItemChangedSmartGroupMask = 1 << 1,
+ BDSKItemChangedSearchKeyMask = 1 << 2,
+ BDSKItemChangedSortKeyMask = 1 << 3,
+ BDSKItemChangedFilesMask = 1 << 4
};
#pragma mark -
@@ -1347,6 +1348,19 @@
return NO;
}
+static BOOL smartGroupsDependOnKey(NSArray *smartGroupKeys, NSString *key) {
+ if ([smartGroupKeys count] == 0)
+ return NO;
+ else if ([smartGroupKeys containsObject:BDSKDateModifiedString] ||
[smartGroupKeys containsObject:BDSKAllFieldsString])
+ return YES;
+ else if (key == nil || [smartGroupKeys containsObject:key])
+ return YES;
+ else if ([key isEqualToString:BDSKColorString])
+ return [smartGroupKeys containsObject:BDSKColorLabelString];
+ else
+ return NO;
+}
+
- (void)handlePrivateBibItemChanged{
// we can be called from a queue after the document was closed
if (docFlags.isDocumentClosed)
@@ -1353,10 +1367,9 @@
return;
BOOL changedIsSelected = [[NSSet setWithArray:[self selectedPublications]]
intersectsSet:changedPublications];
+ BOOL displayingLocal = NO == [self
hasGroupTypeSelected:BDSKExternalGroupType];
- if ((docFlags.itemChangeMask & BDSKItemChangedFilesMask) != 0 &&
- NO == [self hasGroupTypeSelected:BDSKExternalGroupType] &&
- changedIsSelected) {
+ if ((docFlags.itemChangeMask & BDSKItemChangedFilesMask) != 0 &&
displayingLocal && changedIsSelected) {
[self updateFileViews];
if (docFlags.controllingQLPreviewPanel ||
docFlags.controllingFVPreviewPanel)
[self previewURLs:nil];
@@ -1366,10 +1379,14 @@
// 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
- [[groups smartGroups]
makeObjectsPerformSelector:@selector(invalidateCount)];
- [self updateSmartGroups];
- if (NO == [self hasGroupTypeSelected:BDSKExternalGroupType |
BDSKSmartGroupType]) {
+ 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];
@@ -1490,6 +1507,8 @@
if (docFlags.isDocumentClosed == NO) {
if (groupFieldsDependOnKey([self currentGroupFields], changedKey))
docFlags.itemChangeMask |= BDSKItemChangedGroupFieldMask;
+ if (smartGroupsDependOnKey([[groups smartGroups]
valueForKeyPath:@"distinctUnionOfArrays.filter.conditions.key"], changedKey))
+ docFlags.itemChangeMask |= BDSKItemChangedSmartGroupMask;
if (sortKeyDependsOnKey(sortKey, changedKey) ||
sortKeyDependsOnKey(previousSortKey, changedKey))
docFlags.itemChangeMask |= BDSKItemChangedSortKeyMask;
if ([self displaysControlView:BDSKControlViewSearch] &&
searchKeyDependsOnKey([searchButtonBar selectedIdentifier], changedKey))
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