Revision: 28202 http://sourceforge.net/p/bibdesk/svn/28202 Author: hofman Date: 2023-04-03 14:25:40 +0000 (Mon, 03 Apr 2023) Log Message: ----------- only set undo action name when duplicating title to booktitle
Modified Paths: -------------- trunk/bibdesk/BDSKEditor.m trunk/bibdesk/BibDocument_Actions.m trunk/bibdesk/BibItem.h trunk/bibdesk/BibItem.m Modified: trunk/bibdesk/BDSKEditor.m =================================================================== --- trunk/bibdesk/BDSKEditor.m 2023-03-29 17:39:48 UTC (rev 28201) +++ trunk/bibdesk/BDSKEditor.m 2023-04-03 14:25:40 UTC (rev 28202) @@ -1121,8 +1121,8 @@ - (IBAction)duplicateTitleToBooktitle:(id)sender{ if ([self commitEditing]) { - [publication duplicateTitleToBooktitleOverwriting:YES]; - [[self undoManager] setActionName:NSLocalizedString(@"Duplicate Title", @"Undo action name")]; + if ([publication duplicateTitleToBooktitleOverwriting:YES]) + [[self undoManager] setActionName:NSLocalizedString(@"Duplicate Title", @"Undo action name")]; } } Modified: trunk/bibdesk/BibDocument_Actions.m =================================================================== --- trunk/bibdesk/BibDocument_Actions.m 2023-03-29 17:39:48 UTC (rev 28201) +++ trunk/bibdesk/BibDocument_Actions.m 2023-04-03 14:25:40 UTC (rev 28202) @@ -1650,14 +1650,15 @@ [alert beginSheetModalForWindow:documentWindow completionHandler:^(NSInteger returnCode){ if ([self commitPendingEdits]) { BOOL overwrite = (returnCode == NSAlertSecondButtonReturn); - NSSet *parentTypes = [NSSet setWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:BDSKTypesForDuplicateBooktitleKey]]; + BOOL didSet = NO; for (BibItem *aPub in [self selectedPublications]) { - if([parentTypes containsObject:[aPub pubType]]) - [aPub duplicateTitleToBooktitleOverwriting:overwrite]; + if ([parentTypes containsObject:[aPub pubType]] && [aPub duplicateTitleToBooktitleOverwriting:overwrite]) + didSet = YES; } - [[self undoManager] setActionName:([self numberOfSelectedPubs] > 1 ? NSLocalizedString(@"Duplicate Titles", @"Undo action name") : NSLocalizedString(@"Duplicate Title", @"Undo action name"))]; + if (didSet) + [[self undoManager] setActionName:([self numberOfSelectedPubs] > 1 ? NSLocalizedString(@"Duplicate Titles", @"Undo action name") : NSLocalizedString(@"Duplicate Title", @"Undo action name"))]; } else { NSBeep(); } Modified: trunk/bibdesk/BibItem.h =================================================================== --- trunk/bibdesk/BibItem.h 2023-03-29 17:39:48 UTC (rev 28201) +++ trunk/bibdesk/BibItem.h 2023-04-03 14:25:40 UTC (rev 28202) @@ -776,7 +776,7 @@ - (void)customFieldsDidChange:(NSNotification *)aNotification; -- (void)duplicateTitleToBooktitleOverwriting:(BOOL)overwrite; +- (BOOL)duplicateTitleToBooktitleOverwriting:(BOOL)overwrite; - (NSArray *)groupArrayForField:(NSString *)field; - (NSSet *)groupsForField:(NSString *)field; Modified: trunk/bibdesk/BibItem.m =================================================================== --- trunk/bibdesk/BibItem.m 2023-03-29 17:39:48 UTC (rev 28201) +++ trunk/bibdesk/BibItem.m 2023-04-03 14:25:40 UTC (rev 28202) @@ -969,16 +969,20 @@ return [[self valueOfField:BDSKBooktitleString] stringByRemovingTeXAndStopWords]; } -- (void)duplicateTitleToBooktitleOverwriting:(BOOL)overwrite{ +- (BOOL)duplicateTitleToBooktitleOverwriting:(BOOL)overwrite{ NSString *title = [self valueOfField:BDSKTitleString inherit:NO]; - if([NSString isEmptyString:title]) - return; + if ([NSString isEmptyString:title]) + return NO; NSString *booktitle = [self valueOfField:BDSKBooktitleString inherit:NO]; - if(![NSString isEmptyString:booktitle] && !overwrite) - return; - [self setField:BDSKBooktitleString toValue:title]; + + if (([NSString isEmptyString:booktitle] == NO && overwrite == NO) || [title isEqualToString:booktitle]) + return NO; + + [self setField:BDSKBooktitleString toValue:title]; + + return YES; } - (NSDate *)date{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit