Files
MacPass/MacPass/KdbGroup+MPAdditions.m
michael starke 8a21b194df Entry positions are now editable in groups
Added undo wrapper for moving to new group and moving to new indexes for Entries
2013-05-18 01:21:31 +02:00

43 lines
1.1 KiB
Objective-C

//
// KdbGroup+MPAdditions.m
// MacPass
//
// Created by michael starke on 19.02.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "KdbGroup+MPAdditions.h"
@implementation KdbGroup (MPAdditions)
- (NSArray *)childGroups {
NSMutableArray *childGroups = [NSMutableArray arrayWithCapacity:[self.groups count]];
for(KdbGroup *childGroup in self.groups) {
[childGroups addObjectsFromArray:[childGroup childGroups]];
}
return childGroups;
}
- (NSArray *)childEntries {
NSMutableArray *childEntries = [NSMutableArray arrayWithCapacity:[self.groups count] + [self.entries count]];
[childEntries addObjectsFromArray:self.entries];
for( KdbGroup *childGroup in self.groups) {
[childEntries addObjectsFromArray:[childGroup childEntries]];
}
return childEntries;
}
- (void)moveEntry:(KdbEntry *)entry toIndex:(NSUInteger)index {
if([entries count] > index) {
return;
}
NSUInteger oldIndex = [entries indexOfObject:entry];
if(oldIndex == NSNotFound) {
return;
}
[entries exchangeObjectAtIndex:oldIndex withObjectAtIndex:index];
}
@end