Refacoted window and view controller to use windowNibName and nibName. Fixes #164

This commit is contained in:
michael starke
2014-08-11 20:44:40 +02:00
parent 4cbb23bed5
commit 0ac4b6f440
23 changed files with 95 additions and 66 deletions

View File

@@ -48,8 +48,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
@implementation MPOutlineViewController
- (id)init {
return [[MPOutlineViewController alloc] initWithNibName:@"OutlineView" bundle:nil];
- (NSString *)nibName {
return @"OutlineView";
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
@@ -78,6 +78,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
[self.outlineView setFloatsGroupRows:NO];
[self.outlineView registerForDraggedTypes:@[ KPKGroupUTI, KPKEntryUTI ]];
[self.outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[self.outlineView setDoubleAction:@selector(_doubleClickedGroup:)];
[self.bottomBar setBorderType:HNHBorderTop|HNHBorderHighlight];
[self.addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]];
@@ -140,7 +141,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
#pragma mark Notifications
- (void)regsiterNotificationsForDocument:(MPDocument *)document {
// Nothing to do anymore
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document];
}
- (void)clearSelection {
@@ -156,6 +157,11 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
document.selectedItem = document.selectedGroup;
}
# pragma mark MPDocument Notifications
- (void)_didAddGroup:(NSNotification *)notification {
//TODO: find group to expand!
}
- (id)itemUnderMouse {
NSPoint mouseLocation = [[self.outlineView window] mouseLocationOutsideOfEventStream];
NSPoint localPoint = [self.outlineView convertPoint:mouseLocation fromView:[[self.outlineView window] contentView]];
@@ -187,6 +193,10 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
[[[self windowController] document] deleteGroup:[self _clickedOrSelectedGroup]];
}
- (void)_doubleClickedGroup:(id)sender {
[[self windowController] showInspector:sender];
}
#pragma mark NSOutlineViewDelegate
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
NSTableCellView *view;