Revision: 22618
          http://sourceforge.net/p/bibdesk/svn/22618
Author:   hofman
Date:     2018-09-16 21:18:47 +0000 (Sun, 16 Sep 2018)
Log Message:
-----------
compare bib author instances when using group compare in condition

Modified Paths:
--------------
    trunk/bibdesk/BDSKCondition.h
    trunk/bibdesk/BDSKCondition.m

Modified: trunk/bibdesk/BDSKCondition.h
===================================================================
--- trunk/bibdesk/BDSKCondition.h       2018-09-16 12:40:23 UTC (rev 22617)
+++ trunk/bibdesk/BDSKCondition.h       2018-09-16 21:18:47 UTC (rev 22618)
@@ -91,7 +91,7 @@
 };
 
 @protocol BDSKSmartGroup;
-@class BibItem;
+@class BibItem, BibAuthor;
 
 @interface BDSKCondition : NSObject <NSCopying, NSCoding> {
        NSString *key;
@@ -105,6 +105,7 @@
     BDSKPeriod periodValue;
     NSDate *dateValue;
     NSDate *toDateValue;
+    BibAuthor *authorValue;
     id<BDSKSmartGroup> group;
        NSDate *cachedStartDate;
        NSDate *cachedEndDate;

Modified: trunk/bibdesk/BDSKCondition.m
===================================================================
--- trunk/bibdesk/BDSKCondition.m       2018-09-16 12:40:23 UTC (rev 22617)
+++ trunk/bibdesk/BDSKCondition.m       2018-09-16 21:18:47 UTC (rev 22618)
@@ -38,6 +38,7 @@
 
 #import "BDSKCondition.h"
 #import "BibItem.h"
+#import "BibAuthor.h"
 #import "NSString_BDSKExtensions.h"
 #import "NSDate_BDSKExtensions.h"
 #import "BDSKTypeManager.h"
@@ -46,6 +47,7 @@
 
 
 @interface BDSKCondition (Private)
+- (BOOL)item:(BibItem *)item isContainedInGroupForField:(NSString *)field;
 - (NSDate *)cachedEndDate;
 - (void)setCachedEndDate:(NSDate *)newCachedDate;
 - (NSDate *)cachedStartDate;
@@ -153,6 +155,7 @@
     cacheTimer = nil;
     BDSKDESTROY(key);
     BDSKDESTROY(stringValue);
+    BDSKDESTROY(authorValue);
     BDSKDESTROY(cachedStartDate);
     BDSKDESTROY(cachedEndDate);
     [super dealloc];
@@ -251,17 +254,19 @@
         
         if (stringComparison == BDSKGroupContain || stringComparison == 
BDSKGroupNotContain) {
             if ([key isEqualToString:BDSKAllFieldsString]) {
+                if (authorValue == nil)
+                    authorValue = [[BibAuthor authorWithName:stringValue] 
retain];
                 BOOL isContain = stringComparison == BDSKGroupContain;
                 for (NSString *field in [item allFieldNames]) {
-                    if ([field isInvalidGroupField] == NO && [item 
isContainedInGroupNamed:stringValue forField:field])
+                    if ([field isInvalidGroupField] == NO && [self item:item 
isContainedInGroupForField:field])
                         return isContain;
                 }
                 return NO == isContain;
             } else {
-                if (stringComparison == BDSKGroupContain) 
-                    return ([item isContainedInGroupNamed:stringValue 
forField:key]);
+                if (stringComparison == BDSKGroupContain)
+                    return [self item:item isContainedInGroupForField:key];
                 if (stringComparison == BDSKGroupNotContain) 
-                    return ([item isContainedInGroupNamed:stringValue 
forField:key] == NO);
+                    return NO == [self item:item 
isContainedInGroupForField:key];
             }
         }
         
@@ -490,6 +495,7 @@
     if (stringValue != newValue) {
         [stringValue release];
         stringValue = [(newValue ?: @"") retain];
+        BDSKDESTROY(authorValue);
     }
 }
 
@@ -657,6 +663,16 @@
 
 @implementation BDSKCondition (Private)
 
+- (BOOL)item:(BibItem *)item isContainedInGroupForField:(NSString *)field {
+    id value = stringValue;
+    if ([field isPersonField]) {
+        if (authorValue == nil)
+            authorValue = [[BibAuthor authorWithName:stringValue] retain];
+        value = authorValue;
+    }
+    return [item isContainedInGroupNamed:value forField:field];
+}
+
 #pragma mark Cached dates
 
 - (NSDate *)cachedEndDate {

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