Multiple changes to -selectCommit: from PBGitHistoryController.

- Change return type from void to BOOL to convey if selecting succeeded 
  or not.

- Return NO if the cliArgs from sharedApplicationController contain "--commit",
  since then we need to just show the commit stage. Updating the commit list
  selection is not necessary. In fact, it will confuse order among consequent 
  calls.

- If the oldIndex equals NSNotFound, try to get the index of the currently 
  selected object by finding it among the content object of the commitController.
  
  If we find it we save the result in an ivar called selectedCommit so that 
  subsequent calls will always have this available as an alternative back-up
  plan.
This commit is contained in:
André Berg
2010-04-05 21:24:00 +02:00
parent c85fa2f216
commit 4ed7911c6f
2 changed files with 21 additions and 6 deletions
+3 -2
View File
@@ -71,11 +71,12 @@
- (IBAction) setDetailedView:(id)sender;
- (IBAction) setTreeView:(id)sender;
- (IBAction) setBranchFilter:(id)sender;
- (void) selectCommit: (NSString*) commit;
- (IBAction) refresh:(id)sender;
- (IBAction) toggleQLPreviewPanel:(id)sender;
- (IBAction) openSelectedFile:(id)sender;
- (BOOL) selectCommit: (NSString*) commit;
- (void) updateQuicklookForce: (BOOL) force;
+18 -4
View File
@@ -424,18 +424,32 @@
return selectedCommits;
}
- (void) selectCommit:(NSString *)commitSHA
- (BOOL) selectCommit:(NSString *)commitSHA
{
ApplicationController * appController = [ApplicationController sharedApplicationController];
if (appController.launchedFromGitx && [appController.cliArgs isEqualToString:@"--commit"]) {
return NO;
}
NSLog(@"[%@ %s]: SHA = %@", [self class], _cmd, commitSHA);
if (!forceSelectionUpdate && [[selectedCommit realSha] isEqualToString:commitSHA])
return;
return NO;
NSInteger oldIndex = [[commitController selectionIndexes] firstIndex];
if (oldIndex == NSNotFound) {
oldIndex = [[commitController content] indexOfObject:selectedCommit];
}
NSArray *selectedCommits = [self selectedObjectsForSHA:commitSHA];
selectedCommit = [selectedCommits objectAtIndex:0];
[commitController setSelectedObjects:selectedCommits];
if (repository.currentBranchFilter != kGitXSelectedBranchFilter)
[self scrollSelectionToTopOfViewFrom:oldIndex];
if (repository.currentBranchFilter != kGitXSelectedBranchFilter) {
NSLog(@"[%@ %s] currentBranchFilter = %@", [self class], _cmd, PBStringFromBranchFilterType(repository.currentBranchFilter));
[self scrollSelectionToTopOfViewFrom:oldIndex];
}
return YES;
}
- (BOOL) hasNonlinearPath