From: <ho...@us...> - 2009-11-29 17:09:14
|
Revision: 16204 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=16204&view=rev Author: hofman Date: 2009-11-29 17:09:08 +0000 (Sun, 29 Nov 2009) Log Message: ----------- Initialize groups with zero count, the count will be updated when needed anyway. Modified Paths: -------------- trunk/bibdesk/BDSKCategoryGroup.h trunk/bibdesk/BDSKCategoryGroup.m trunk/bibdesk/BDSKExternalGroup.m trunk/bibdesk/BDSKGroup.h trunk/bibdesk/BDSKGroup.m trunk/bibdesk/BDSKParentGroup.h trunk/bibdesk/BDSKParentGroup.m trunk/bibdesk/BDSKSmartGroup.h trunk/bibdesk/BDSKSmartGroup.m trunk/bibdesk/BDSKStaticGroup.m trunk/bibdesk/BibDocument+Scripting.m trunk/bibdesk/BibDocument_DataSource.m trunk/bibdesk/BibDocument_Groups.m Modified: trunk/bibdesk/BDSKCategoryGroup.h =================================================================== --- trunk/bibdesk/BDSKCategoryGroup.h 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKCategoryGroup.h 2009-11-29 17:09:08 UTC (rev 16204) @@ -45,14 +45,13 @@ } /*! - @method initWithName:key:count: + @method initWithName:key: @abstract Initializes and returns a new group instance with a name and count. @discussion This is the designated initializer. @param aName The name for the group, use nil for the "empty" group. @param aKey The key for the group. - @param count The count for the group. */ -- (id)initWithName:(id)aName key:(NSString *)aKey count:(NSInteger)aCount; +- (id)initWithName:(id)aName key:(NSString *)aKey; /*! @method key Modified: trunk/bibdesk/BDSKCategoryGroup.m =================================================================== --- trunk/bibdesk/BDSKCategoryGroup.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKCategoryGroup.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -50,29 +50,29 @@ @implementation BDSKCategoryGroup // designated initializer -- (id)initWithName:(id)aName key:(NSString *)aKey count:(NSInteger)aCount { +- (id)initWithName:(id)aName key:(NSString *)aKey { if (aName == nil) { NSZone *zone = [self zone]; [self release]; self = [BDSKEmptyGroup allocWithZone:zone]; aName = [aKey isPersonField] ? [BibAuthor emptyAuthor] : @""; } - if (self = [super initWithName:aName count:aCount]) { + if (self = [super initWithName:aName]) { key = [aKey copy]; } return self; } // super's designated initializer -- (id)initWithName:(id)aName count:(NSInteger)aCount { - self = [self initWithName:aName key:nil count:aCount]; +- (id)initWithName:(id)aName { + self = [self initWithName:aName key:nil]; return self; } - (id)initWithDictionary:(NSDictionary *)groupDict { NSString *aName = [[groupDict objectForKey:@"group name"] stringByUnescapingGroupPlistEntities]; NSString *aKey = [[groupDict objectForKey:@"key"] stringByUnescapingGroupPlistEntities]; - self = [self initWithName:aName key:aKey count:0]; + self = [self initWithName:aName key:aKey]; return self; } @@ -95,7 +95,7 @@ } - (id)copyWithZone:(NSZone *)aZone { - return [[[self class] allocWithZone:aZone] initWithName:name key:key count:count]; + return [[[self class] allocWithZone:aZone] initWithName:name key:key]; } - (void)dealloc { Modified: trunk/bibdesk/BDSKExternalGroup.m =================================================================== --- trunk/bibdesk/BDSKExternalGroup.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKExternalGroup.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -46,15 +46,11 @@ @implementation BDSKExternalGroup -// old designated initializer -- (id)initWithName:(NSString *)aName count:(NSInteger)aCount { - return [self initWithName:aName]; -} - +// designated initializer - (id)initWithName:(NSString *)aName { NSAssert(aName != nil, @"External group requires a name"); - if (self = [super initWithName:aName count:0]) { + if (self = [super initWithName:aName]) { publications = nil; macroResolver = [[BDSKMacroResolver alloc] initWithOwner:self]; searchIndexes = [BDSKItemSearchIndexes new]; Modified: trunk/bibdesk/BDSKGroup.h =================================================================== --- trunk/bibdesk/BDSKGroup.h 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKGroup.h 2009-11-29 17:09:08 UTC (rev 16204) @@ -51,13 +51,12 @@ } /*! - @method initWithName:count: + @method initWithName: @abstract Initializes and returns a new group instance with a name and count. @discussion This is the designated initializer. @param aName The name for the group. - @param count The count for the group. */ -- (id)initWithName:(id)aName count:(NSInteger)aCount; +- (id)initWithName:(id)aName; - (id)initWithDictionary:(NSDictionary *)groupDict; - (NSDictionary *)dictionaryValue; Modified: trunk/bibdesk/BDSKGroup.m =================================================================== --- trunk/bibdesk/BDSKGroup.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKGroup.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -67,14 +67,14 @@ // super's designated initializer - (id)init { - return [self initWithName:NSLocalizedString(@"Group", @"Default group name") count:0]; + return [self initWithName:NSLocalizedString(@"Group", @"Default group name")]; } // designated initializer -- (id)initWithName:(id)aName count:(NSInteger)aCount { +- (id)initWithName:(id)aName { if (self = [super init]) { name = [aName copy]; - count = aCount; + count = 0; document = nil; uniqueID = createUniqueID(); } @@ -83,7 +83,7 @@ - (id)initWithDictionary:(NSDictionary *)groupDict { NSString *aName = [[groupDict objectForKey:@"group name"] stringByUnescapingGroupPlistEntities]; - self = [self initWithName:aName count:0]; + self = [self initWithName:aName]; return self; } @@ -111,7 +111,7 @@ // NSCopying protocol, may be used by the duplicate script command - (id)copyWithZone:(NSZone *)aZone { - return [[[self class] allocWithZone:aZone] initWithName:name count:count]; + return [[[self class] allocWithZone:aZone] initWithName:name]; } - (void)dealloc { @@ -265,7 +265,7 @@ } - (id)init { - self = [super initWithName:BDSKLibraryLocalizedString count:0]; + self = [super initWithName:BDSKLibraryLocalizedString]; return self; } Modified: trunk/bibdesk/BDSKParentGroup.h =================================================================== --- trunk/bibdesk/BDSKParentGroup.h 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKParentGroup.h 2009-11-29 17:09:08 UTC (rev 16204) @@ -47,8 +47,6 @@ NSArray *sortDescriptors; } -- (id)initWithName:(NSString *)aName; - - (NSUInteger)numberOfChildren; - (id)childAtIndex:(NSUInteger)anIndex; - (NSArray *)children; Modified: trunk/bibdesk/BDSKParentGroup.m =================================================================== --- trunk/bibdesk/BDSKParentGroup.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKParentGroup.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -52,16 +52,12 @@ @implementation BDSKParentGroup - (id)initWithName:(NSString *)aName { - if (self = [super initWithName:aName count:0]) { + if (self = [super initWithName:aName]) { children = [[NSMutableArray alloc] init]; } return self; } -- (id)initWithName:(NSString *)aName count:(NSInteger)count { - return [self initWithName:aName]; -} - - (NSUInteger)hash { return BDSKHash(self); } - (BOOL)isEqual:(id)other { return self == other; } Modified: trunk/bibdesk/BDSKSmartGroup.h =================================================================== --- trunk/bibdesk/BDSKSmartGroup.h 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKSmartGroup.h 2009-11-29 17:09:08 UTC (rev 16204) @@ -54,14 +54,13 @@ - (id)initWithFilter:(BDSKFilter *)aFilter; /*! - @method initWithName:count:filter: + @method initWithName:filter: @abstract Initializes and returns a new group instance with a name, count and filter. @discussion This is the designated initializer. @param aName The name for the smart group. - @param count The count for the smart group. @param aFilter The filter for the smart group with. */ -- (id)initWithName:(id)aName count:(NSInteger)aCount filter:(BDSKFilter *)aFilter; +- (id)initWithName:(id)aName filter:(BDSKFilter *)aFilter; /*! @method filter Modified: trunk/bibdesk/BDSKSmartGroup.m =================================================================== --- trunk/bibdesk/BDSKSmartGroup.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKSmartGroup.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -45,16 +45,16 @@ @implementation BDSKSmartGroup // super's designated initializer -- (id)initWithName:(id)aName count:(NSInteger)aCount { +- (id)initWithName:(id)aName { BDSKFilter *aFilter = [[BDSKFilter alloc] init]; - self = [self initWithName:aName count:aCount filter:aFilter]; + self = [self initWithName:aName filter:aFilter]; [aFilter release]; return self; } // designated initializer -- (id)initWithName:(id)aName count:(NSInteger)aCount filter:(BDSKFilter *)aFilter { - if (self = [super initWithName:aName count:aCount]) { +- (id)initWithName:(id)aName filter:(BDSKFilter *)aFilter { + if (self = [super initWithName:aName]) { filter = [aFilter copy]; [filter setGroup:self]; } @@ -67,14 +67,14 @@ aName = [[[aFilter conditions] objectAtIndex:0] value]; if ([NSString isEmptyString:aName]) aName = NSLocalizedString(@"Smart Group", @"Default name for smart group"); - self = [self initWithName:aName count:0 filter:aFilter]; + self = [self initWithName:aName filter:aFilter]; return self; } - (id)initWithDictionary:(NSDictionary *)groupDict { NSString *aName = [[groupDict objectForKey:@"group name"] stringByUnescapingGroupPlistEntities]; BDSKFilter *aFilter = [[BDSKFilter alloc] initWithDictionary:groupDict]; - self = [self initWithName:aName count:0 filter:aFilter]; + self = [self initWithName:aName filter:aFilter]; [aFilter release]; return self; } @@ -100,7 +100,7 @@ } - (id)copyWithZone:(NSZone *)aZone { - return [[[self class] allocWithZone:aZone] initWithName:name count:count filter:filter]; + return [[[self class] allocWithZone:aZone] initWithName:name filter:filter]; } - (void)dealloc { Modified: trunk/bibdesk/BDSKStaticGroup.m =================================================================== --- trunk/bibdesk/BDSKStaticGroup.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BDSKStaticGroup.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -62,8 +62,9 @@ // designated initializer - (id)initWithName:(id)aName publications:(NSArray *)array { - if (self = [super initWithName:aName count:[array count]]) { + if (self = [super initWithName:aName]) { publications = [[NSMutableArray alloc] initWithArray:array]; + [self setCount:[array count]]; } return self; } Modified: trunk/bibdesk/BibDocument+Scripting.m =================================================================== --- trunk/bibdesk/BibDocument+Scripting.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BibDocument+Scripting.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -293,7 +293,7 @@ if ([group isStatic]) { copiedGroup = [[BDSKStaticGroup alloc] initWithName:[group name] publications:([group document] == self ? [group publications] : nil)]; } else if ([group isSmart]) { - copiedGroup = [[BDSKSmartGroup alloc] initWithName:[group name] count:[group count] filter:[group filter]]; + copiedGroup = [[BDSKSmartGroup alloc] initWithName:[group name] filter:[group filter]]; } else if ([group isURL]) { copiedGroup = [[BDSKURLGroup alloc] initWithName:[group name] URL:[group URL]]; } else if ([group isScript]) { Modified: trunk/bibdesk/BibDocument_DataSource.m =================================================================== --- trunk/bibdesk/BibDocument_DataSource.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BibDocument_DataSource.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -1181,7 +1181,7 @@ NSArray *pubs = [groupedPublications copy]; // change the name of the group first, so we can preserve the selection; we need to old group info to move though id name = [[self currentGroupField] isPersonField] ? (id)[BibAuthor authorWithName:newName andPub:[[group name] publication]] : (id)newName; - BDSKCategoryGroup *oldGroup = [[[BDSKCategoryGroup alloc] initWithName:[group name] key:[(BDSKCategoryGroup *)group key] count:[group count]] autorelease]; + BDSKCategoryGroup *oldGroup = [[[BDSKCategoryGroup alloc] initWithName:[group name] key:[(BDSKCategoryGroup *)group key]] autorelease]; [(BDSKCategoryGroup *)group setName:name]; [self movePublications:pubs fromGroup:oldGroup toGroupNamed:newName]; [pubs release]; Modified: trunk/bibdesk/BibDocument_Groups.m =================================================================== --- trunk/bibdesk/BibDocument_Groups.m 2009-11-29 13:20:31 UTC (rev 16203) +++ trunk/bibdesk/BibDocument_Groups.m 2009-11-29 17:09:08 UTC (rev 16204) @@ -477,12 +477,11 @@ // use BDSKTextWithIconCell keys for (id groupName in (NSSet *)(setAndBag.set)) { NSUInteger idx = [oldGroupNames indexOfObject:groupName]; - if (idx == NSNotFound) { - group = [[BDSKCategoryGroup alloc] initWithName:groupName key:groupField count:CFBagGetCountOfValue(setAndBag.bag, groupName)]; - } else { + if (idx == NSNotFound) + group = [[BDSKCategoryGroup alloc] initWithName:groupName key:groupField]; + else group = [[oldGroups objectAtIndex:idx] retain]; - [group setCount:CFBagGetCountOfValue(setAndBag.bag, groupName)]; - } + [group setCount:CFBagGetCountOfValue(setAndBag.bag, groupName)]; [mutableGroups addObject:group]; [group release]; } @@ -490,12 +489,11 @@ // add the "empty" group at index 0; this is a group of pubs whose value is empty for this field, so they // will not be contained in any of the other groups for the currently selected group field (hence multiple selection is desirable) if (emptyCount > 0) { - if ([oldGroups count] && [[oldGroups objectAtIndex:0] isEmpty]) { + if ([oldGroups count] && [[oldGroups objectAtIndex:0] isEmpty]) group = [[oldGroups objectAtIndex:0] retain]; - [group setCount:emptyCount]; - } else { - group = [[BDSKCategoryGroup alloc] initWithName:nil key:groupField count:emptyCount]; - } + else + group = [[BDSKCategoryGroup alloc] initWithName:nil key:groupField]; + [group setCount:emptyCount]; [mutableGroups insertObject:group atIndex:0]; [group release]; } @@ -1127,7 +1125,7 @@ name = [NSString stringWithFormat:@"%@%lu", baseName, (unsigned long)i++]; if (isAuthor) name = [BibAuthor authorWithName:name andPub:nil]; - group = [[[BDSKCategoryGroup alloc] initWithName:name key:currentGroupField count:[pubs count]] autorelease]; + group = [[[BDSKCategoryGroup alloc] initWithName:name key:currentGroupField] autorelease]; // first merge in shared groups if ([self hasExternalGroupsSelected]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |