Revision: 27693
          http://sourceforge.net/p/bibdesk/svn/27693
Author:   hofman
Date:     2022-07-05 14:32:26 +0000 (Tue, 05 Jul 2022)
Log Message:
-----------
Revert last commits: reloading smart groups just when smart groups are changed. 
Something did not go right.

Modified Paths:
--------------
    trunk/bibdesk/BibDocument.h
    trunk/bibdesk/BibDocument_Groups.h
    trunk/bibdesk/BibDocument_Groups.m
    trunk/bibdesk/BibDocument_UI.m

Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2022-07-05 13:55:04 UTC (rev 27692)
+++ trunk/bibdesk/BibDocument.h 2022-07-05 14:32:26 UTC (rev 27693)
@@ -257,7 +257,7 @@
     } docState;
     
     struct _docFlags {
-        unsigned int        itemChangeMask:5;
+        unsigned int        itemChangeMask:4;
         unsigned int        sortDescending:1;
         unsigned int        previousSortDescending:1;
         unsigned int        tmpSortDescending:1;

Modified: trunk/bibdesk/BibDocument_Groups.h
===================================================================
--- trunk/bibdesk/BibDocument_Groups.h  2022-07-05 13:55:04 UTC (rev 27692)
+++ trunk/bibdesk/BibDocument_Groups.h  2022-07-05 14:32:26 UTC (rev 27693)
@@ -55,7 +55,6 @@
 
 - (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 13:55:04 UTC (rev 27692)
+++ trunk/bibdesk/BibDocument_Groups.m  2022-07-05 14:32:26 UTC (rev 27693)
@@ -415,7 +415,7 @@
 
 // reload (a section of) the outlineview and preserve the selection
 - (void)reloadParentGroup:(BDSKParentGroup *)parentGroup {
-    if ([parentGroup isKindOfClass:[BDSKParentGroup class]] && 
[groupOutlineView isItemExpanded:parentGroup] == NO)
+    if (parentGroup && [groupOutlineView isItemExpanded:parentGroup] == NO)
         return;
     
     // this is a hack to keep us from getting selection change notifications 
while sorting (which updates the TeX and attributed text previews)
@@ -426,14 +426,10 @@
     
     NSArray *selectedGroups = [self selectedGroups];
 
-    if (parentGroup == nil) {
+    if (parentGroup)
+        [groupOutlineView reloadItem:parentGroup reloadChildren:YES];
+    else
         [groupOutlineView reloadData];
-    } else if ([parentGroup isKindOfClass:[BDSKParentGroup class]]) {
-        [groupOutlineView reloadItem:parentGroup reloadChildren:YES];
-    } else {
-        for (BDSKParentGroup *parent in (NSArray *)parentGroup)
-            [groupOutlineView reloadItem:parent reloadChildren:YES];
-    }
     
     // select the current groups, if still around. Otherwise select Library
     BOOL didSelect = [self selectGroups:selectedGroups];
@@ -580,40 +576,6 @@
     [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:(id)parentsToReload];
-    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 13:55:04 UTC (rev 27692)
+++ trunk/bibdesk/BibDocument_UI.m      2022-07-05 14:32:26 UTC (rev 27693)
@@ -97,10 +97,9 @@
 
 enum {
     BDSKItemChangedGroupFieldMask = 1 << 0,
-    BDSKItemChangedSmartGroupMask = 1 << 1,
-    BDSKItemChangedSearchKeyMask  = 1 << 2,
-    BDSKItemChangedSortKeyMask    = 1 << 3,
-    BDSKItemChangedFilesMask      = 1 << 4
+    BDSKItemChangedSearchKeyMask  = 1 << 1,
+    BDSKItemChangedSortKeyMask    = 1 << 2,
+    BDSKItemChangedFilesMask      = 1 << 3
 };
 
 #pragma mark -
@@ -1348,19 +1347,6 @@
         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)
@@ -1367,38 +1353,45 @@
         return;
     
     BOOL changedIsSelected = [[NSSet setWithArray:[self selectedPublications]] 
intersectsSet:changedPublications];
-    BOOL displayingLocal = NO == [self 
hasGroupTypeSelected:BDSKExternalGroupType];
     
-    if ((docFlags.itemChangeMask & BDSKItemChangedFilesMask) != 0 && 
displayingLocal && changedIsSelected) {
+    if ((docFlags.itemChangeMask & BDSKItemChangedFilesMask) != 0 &&
+        NO == [self hasGroupTypeSelected:BDSKExternalGroupType] &&
+        changedIsSelected) {
         [self updateFileViews];
         if (docFlags.controllingQLPreviewPanel || 
docFlags.controllingFVPreviewPanel)
             [self previewURLs:nil];
     }
     
-    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((docFlags.itemChangeMask & BDSKItemChangedGroupFieldMask) != 0){
+        // this handles all UI updates if we call it, so don't bother with any 
others
+        [self updateFilteringGroups];
+    } else {
+        // 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 & 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];
@@ -1497,8 +1490,6 @@
     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

Reply via email to