mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
CommitView: Intelligently add files
Rather than rereading our status every time we add something, calculate where a file should go.
This commit is contained in:
+29
-18
@@ -100,9 +100,8 @@
|
||||
PBChangedFile *file =[[PBChangedFile alloc] initWithPath:line andRepository:repository];
|
||||
file.status = NEW;
|
||||
file.cached = NO;
|
||||
[files addObject: file];
|
||||
[unstagedFilesController addObject:file];
|
||||
}
|
||||
self.files = files;
|
||||
[self doneProcessingIndex];
|
||||
}
|
||||
|
||||
@@ -116,10 +115,9 @@
|
||||
|
||||
PBChangedFile *file = [[PBChangedFile alloc] initWithPath:[components objectAtIndex:1] andRepository:repository];
|
||||
file.status = MODIFIED;
|
||||
file.cached =NO;
|
||||
[files addObject: file];
|
||||
file.cached = NO;
|
||||
[unstagedFilesController addObject: file];
|
||||
}
|
||||
self.files = files;
|
||||
[self doneProcessingIndex];
|
||||
}
|
||||
|
||||
@@ -135,7 +133,7 @@
|
||||
PBChangedFile *file = [[PBChangedFile alloc] initWithPath:[components objectAtIndex:1] andRepository:repository];
|
||||
file.status = MODIFIED;
|
||||
file.cached = YES;
|
||||
[files addObject: file];
|
||||
[cachedFilesController addObject: file];
|
||||
}
|
||||
self.files = files;
|
||||
[self doneProcessingIndex];
|
||||
@@ -199,20 +197,33 @@
|
||||
- (void) cellClicked:(NSCell*) sender
|
||||
{
|
||||
NSTableView *tableView = (NSTableView *)[sender controlView];
|
||||
if([tableView numberOfSelectedRows] == 1)
|
||||
{
|
||||
NSUInteger selectionIndex = [[tableView selectedRowIndexes] firstIndex];
|
||||
PBChangedFile *selectedItem = [[(([tableView tag] == 0) ? unstagedFilesController : cachedFilesController) arrangedObjects] objectAtIndex:selectionIndex];
|
||||
if (selectedItem.cached == NO) {
|
||||
[selectedItem stageChanges];
|
||||
|
||||
}
|
||||
else {
|
||||
[selectedItem unstageChanges];
|
||||
}
|
||||
[self refresh: self];
|
||||
if([tableView numberOfSelectedRows] != 1)
|
||||
return;
|
||||
|
||||
NSUInteger selectionIndex = [[tableView selectedRowIndexes] firstIndex];
|
||||
NSArrayController *controller, *otherController;
|
||||
if ([tableView tag] == 0) {
|
||||
controller = unstagedFilesController;
|
||||
otherController = cachedFilesController;
|
||||
}
|
||||
else {
|
||||
controller = cachedFilesController;
|
||||
otherController = unstagedFilesController;
|
||||
}
|
||||
|
||||
PBChangedFile *selectedItem = [[controller arrangedObjects] objectAtIndex:selectionIndex];
|
||||
[controller removeObject:selectedItem];
|
||||
if (selectedItem.cached == NO)
|
||||
[selectedItem stageChanges];
|
||||
else
|
||||
[selectedItem unstageChanges];
|
||||
|
||||
// Add the file to the other controller if it's not there yet
|
||||
for (PBChangedFile *object in [otherController arrangedObjects])
|
||||
if ([[object path] isEqualToString:[selectedItem path]])
|
||||
return;
|
||||
|
||||
[otherController addObject:selectedItem];
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(int)rowIndex
|
||||
|
||||
+4
-4
@@ -897,9 +897,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
|
||||
<object class="_NSManagedProxy" key="_NSManagedProxy"/>
|
||||
<bool key="NSAvoidsEmptySelection">YES</bool>
|
||||
<bool key="NSPreservesSelection">YES</bool>
|
||||
<bool key="NSSelectsInsertedObjects">YES</bool>
|
||||
<bool key="NSFilterRestrictsInsertion">YES</bool>
|
||||
<bool key="NSClearsFilterPredicateOnInsertion">YES</bool>
|
||||
<bool key="NSAutomaticallyRearrangesObjects">YES</bool>
|
||||
</object>
|
||||
<object class="NSArrayController" id="667905213">
|
||||
<object class="NSMutableArray" key="NSDeclaredKeys">
|
||||
@@ -913,9 +912,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
|
||||
<object class="_NSManagedProxy" key="_NSManagedProxy"/>
|
||||
<bool key="NSAvoidsEmptySelection">YES</bool>
|
||||
<bool key="NSPreservesSelection">YES</bool>
|
||||
<bool key="NSSelectsInsertedObjects">YES</bool>
|
||||
<bool key="NSFilterRestrictsInsertion">YES</bool>
|
||||
<bool key="NSClearsFilterPredicateOnInsertion">YES</bool>
|
||||
<bool key="NSAutomaticallyRearrangesObjects">YES</bool>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1007648253">
|
||||
<string key="NSClassName">PBWebChangesController</string>
|
||||
@@ -1592,6 +1590,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>cachedFilesController</string>
|
||||
<string>controller</string>
|
||||
<string>previousFile</string>
|
||||
<string>unstagedFilesController</string>
|
||||
<string>view</string>
|
||||
</object>
|
||||
@@ -1599,6 +1598,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSArrayController</string>
|
||||
<string>PBGitCommitController</string>
|
||||
<string>id</string>
|
||||
<string>NSArrayController</string>
|
||||
<string>WebView</string>
|
||||
</object>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
IBOutlet NSArrayController *unstagedFilesController;
|
||||
IBOutlet NSArrayController *cachedFilesController;
|
||||
IBOutlet PBGitCommitController *controller;
|
||||
|
||||
id previousFile;
|
||||
}
|
||||
|
||||
- (void) showDiff:(PBChangedFile *)file;
|
||||
|
||||
@@ -43,6 +43,10 @@ static PBChangedFile *lastFileSelected = nil;
|
||||
|
||||
PBChangedFile *file = [[object selectedObjects] objectAtIndex:0];
|
||||
|
||||
if (previousFile == file)
|
||||
return;
|
||||
|
||||
previousFile = file;
|
||||
if ([view isLoading]) {
|
||||
lastFileSelected = file;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user