Files
MacPass/MacPass/Kdb4Tree+NewTree.m
michael starke 515190a74e Added humanized Date formatting (simple)
Fixed errors that would occur if undo was mixed with emptying the trash
Updated localizations
Added localized descriptions
Fixed #31 Database name is displayed, if none is given fallback is used
2013-07-10 03:37:31 +02:00

124 lines
3.7 KiB
Objective-C

//
// Kdb4Tree+NewTree.m
// MacPass
//
// Created by Michael Starke on 21.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "Kdb4Tree+NewTree.h"
@implementation Kdb4Tree (NewTree)
+ (Kdb4Tree *)templateTree {
NSDate *currentTime = [NSDate date];
Kdb4Tree *tree = [[Kdb4Tree alloc] init];
tree.generator = @"MacPass";
tree.databaseName = NSLocalizedString(@"DATABASE", "");
tree.databaseNameChanged = currentTime;
tree.databaseDescription = @"";
tree.databaseDescriptionChanged = currentTime;
tree.defaultUserName = @"";
tree.defaultUserNameChanged = currentTime;
tree.maintenanceHistoryDays = 365;
tree.color = @"";
tree.masterKeyChanged = currentTime;
tree.masterKeyChangeRec = -1;
tree.masterKeyChangeForce = -1;
tree.protectTitle = NO;
tree.protectUserName = NO;
tree.protectPassword = YES;
tree.protectUrl = NO;
tree.protectNotes = NO;
tree.recycleBinEnabled = YES;
tree.recycleBinUuid = [UUID nullUuid];
tree.recycleBinChanged = currentTime;
tree.entryTemplatesGroup = [UUID nullUuid];
tree.entryTemplatesGroupChanged = currentTime;
tree.historyMaxItems = 10;
tree.historyMaxSize = 6 * 1024 * 1024; // 6 MB
tree.lastSelectedGroup = [UUID nullUuid];
tree.lastTopVisibleGroup = [UUID nullUuid];
KdbGroup *parentGroup = [tree createGroup:nil];
parentGroup.name = NSLocalizedString(@"GENERAL", "General");
parentGroup.image = 48;
tree.root = parentGroup;
KdbGroup *group = [tree createGroup:parentGroup];
group.name = NSLocalizedString(@"WINDOWS", "Windows");
group.image = 38;
[parentGroup addGroup:group];
group = [tree createGroup:parentGroup];
group.name = NSLocalizedString(@"NETWORK", "Network");
group.image = 3;
[parentGroup addGroup:group];
group = [tree createGroup:parentGroup];
group.name = NSLocalizedString(@"INTERNET", "Internet");
group.image = 1;
[parentGroup addGroup:group];
group = [tree createGroup:parentGroup];
group.name = NSLocalizedString(@"EMAIL", "EMail");
group.image = 19;
[parentGroup addGroup:group];
group = [tree createGroup:parentGroup];
group.name = NSLocalizedString(@"HOMEBANKING", "Homebanking");
group.image = 37;
[parentGroup addGroup:group];
return tree;
}
+ (Kdb4Tree *)demoTree {
NSDate *currentTime = [NSDate date];
Kdb4Tree *tree = [[Kdb4Tree alloc] init];
tree.generator = @"MacPass";
tree.databaseName = @"Icon Demonstation";
tree.databaseNameChanged = currentTime;
tree.databaseDescription = @"This database just has all default icons as groups in the tree";
tree.databaseDescriptionChanged = currentTime;
tree.defaultUserName = @"";
tree.defaultUserNameChanged = currentTime;
tree.maintenanceHistoryDays = 365;
tree.color = @"";
tree.masterKeyChanged = currentTime;
tree.masterKeyChangeRec = -1;
tree.masterKeyChangeForce = -1;
tree.protectTitle = NO;
tree.protectUserName = NO;
tree.protectPassword = YES;
tree.protectUrl = NO;
tree.protectNotes = NO;
tree.recycleBinEnabled = YES;
tree.recycleBinUuid = [UUID nullUuid];
tree.recycleBinChanged = currentTime;
tree.entryTemplatesGroup = [UUID nullUuid];
tree.entryTemplatesGroupChanged = currentTime;
tree.historyMaxItems = 10;
tree.historyMaxSize = 6 * 1024 * 1024; // 6 MB
tree.lastSelectedGroup = [UUID nullUuid];
tree.lastTopVisibleGroup = [UUID nullUuid];
KdbGroup *parentGroup = [tree createGroup:nil];
parentGroup.name = @"General";
parentGroup.image = 48;
tree.root = parentGroup;
for(NSUInteger iImageIndex = 0; iImageIndex < 69; iImageIndex++) {
KdbGroup *group = [tree createGroup:parentGroup];
group.name = [NSString stringWithFormat:@"Group %ld", iImageIndex];
group.image = iImageIndex;
[parentGroup addGroup:group];
}
return tree;
}
@end