From 2470f70391316dea31534660b7266da49c7980ca Mon Sep 17 00:00:00 2001 From: michael starke Date: Sat, 8 Jun 2013 11:14:18 +0200 Subject: [PATCH] Introduced auto-expansion on Outlineview --- MacPass/EntryView.xib | 2 +- MacPass/MPOutlineViewController.m | 14 +++++++++----- MacPass/MPOutlineViewDelegate.m | 5 +++++ MacPass/MacPass-Info.plist | 2 +- MacPass/OutlineView.xib | 5 ++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index 45730f72..a25ed655 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -348,7 +348,7 @@ _NS:9 - 154160 + 133680 diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 94708051..c27281d8 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -76,6 +76,8 @@ [self.outlineView setMenu:[self _contextMenu]]; [self.outlineView setAllowsEmptySelection:YES]; [self.outlineView setFloatsGroupRows:NO]; + [self.outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; + NSView *myView = [self view]; self.showConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[myView(>=100,<=250)]" @@ -96,10 +98,8 @@ [_treeController setChildrenKeyPath:@"groups"]; [_treeController bind:NSContentBinding toObject:document withKeyPath:@"root" options:nil]; [_outlineView bind:NSContentBinding toObject:_treeController withKeyPath:@"arrangedObjects" options:nil]; - - [self.outlineView reloadData]; - //MPDocument *document = [[NSDocumentController sharedDocumentController] currentDocument]; - [self.outlineView expandItem:document.root expandChildren:NO]; + NSTreeNode *node = [_outlineView itemAtRow:0]; + [_outlineView expandItem:node expandChildren:NO]; } - (void)clearSelection { @@ -131,8 +131,12 @@ if(!group) { group = document.root; } + BOOL isFistGroup = [document.root.groups count] == 0; [document createGroup:group]; - [self.outlineView reloadData]; + if(isFistGroup) { + NSTreeNode *node = [_outlineView itemAtRow:0]; + [_outlineView expandItem:node expandChildren:NO]; + } } - (void)createEntry:(id)sender { diff --git a/MacPass/MPOutlineViewDelegate.m b/MacPass/MPOutlineViewDelegate.m index 6495dfe7..ba8644bb 100644 --- a/MacPass/MPOutlineViewDelegate.m +++ b/MacPass/MPOutlineViewDelegate.m @@ -71,4 +71,9 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; [[NSNotificationCenter defaultCenter] postNotificationName:MPOutlineViewDidChangeGroupSelection object:self userInfo:nil]; } +- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item { + KdbGroup *group = [item representedObject]; + return (nil != group.parent); +} + @end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 099d4615..db46af8a 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 8DB + 905 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/OutlineView.xib b/MacPass/OutlineView.xib index 23c964d2..92327155 100644 --- a/MacPass/OutlineView.xib +++ b/MacPass/OutlineView.xib @@ -2,9 +2,9 @@ 1080 - 12D78 + 12E55 3084 - 1187.37 + 1187.39 626.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -200,7 +200,6 @@ {{1, 119}, {238, 15}} - _NS:60 NO 1