mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-15 16:12:16 +00:00
Changed templates and trash to simple property setter instead of custom functions
This commit is contained in:
@@ -84,11 +84,11 @@
|
|||||||
metaData.recycleBinEnabled = self.trashEnabled;
|
metaData.recycleBinEnabled = self.trashEnabled;
|
||||||
NSMenuItem *trashMenuItem = [self.selectRecycleBinGroupPopUpButton selectedItem];
|
NSMenuItem *trashMenuItem = [self.selectRecycleBinGroupPopUpButton selectedItem];
|
||||||
KPKGroup *trashGroup = [trashMenuItem representedObject];
|
KPKGroup *trashGroup = [trashMenuItem representedObject];
|
||||||
[_document useGroupAsTrash:trashGroup];
|
_document.trash = trashGroup;
|
||||||
|
|
||||||
NSMenuItem *templateMenuItem = [self.templateGroupPopUpButton selectedItem];
|
NSMenuItem *templateMenuItem = [self.templateGroupPopUpButton selectedItem];
|
||||||
KPKGroup *templateGroup = [templateMenuItem representedObject];
|
KPKGroup *templateGroup = [templateMenuItem representedObject];
|
||||||
[_document useGroupAsTemplate:templateGroup];
|
_document.templates = templateGroup;
|
||||||
|
|
||||||
BOOL protectNotes = [self.protectNotesCheckButton state] == NSOnState;
|
BOOL protectNotes = [self.protectNotesCheckButton state] == NSOnState;
|
||||||
BOOL protectPassword = [self.protectPasswortCheckButton state] == NSOnState;
|
BOOL protectPassword = [self.protectPasswortCheckButton state] == NSOnState;
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
|||||||
@property (nonatomic, readonly, assign) BOOL encrypted;
|
@property (nonatomic, readonly, assign) BOOL encrypted;
|
||||||
|
|
||||||
@property (strong, readonly, nonatomic) KPKTree *tree;
|
@property (strong, readonly, nonatomic) KPKTree *tree;
|
||||||
@property (weak, readonly, nonatomic) KPKGroup *root;
|
@property (nonatomic, weak, readonly) KPKGroup *root;
|
||||||
@property (weak, readonly) KPKGroup *trash;
|
@property (nonatomic, weak) KPKGroup *trash;
|
||||||
@property (weak, readonly) KPKGroup *templates;
|
@property (nonatomic, weak) KPKGroup *templates;
|
||||||
|
|
||||||
@property (nonatomic, strong, readonly) KPKCompositeKey *compositeKey;
|
@property (nonatomic, strong, readonly) KPKCompositeKey *compositeKey;
|
||||||
//@property (nonatomic, copy) NSString *password;
|
//@property (nonatomic, copy) NSString *password;
|
||||||
@@ -114,8 +114,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
|||||||
- (NSArray *)allEntries;
|
- (NSArray *)allEntries;
|
||||||
- (NSArray *)allGroups;
|
- (NSArray *)allGroups;
|
||||||
|
|
||||||
- (void)useGroupAsTrash:(KPKGroup *)group;
|
|
||||||
- (void)useGroupAsTemplate:(KPKGroup *)group;
|
|
||||||
/**
|
/**
|
||||||
* Determines, whether the given item is inside the trash.
|
* Determines, whether the given item is inside the trash.
|
||||||
* The trash group itself is not considered as trashed.
|
* The trash group itself is not considered as trashed.
|
||||||
|
|||||||
@@ -308,6 +308,41 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
|
|||||||
return self.tree.root;
|
return self.tree.root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (KPKGroup *)trash {
|
||||||
|
static KPKGroup *_trash = nil;
|
||||||
|
if(self.useTrash) {
|
||||||
|
BOOL trashValid = [_trash.uuid isEqual:self.tree.metaData.recycleBinUuid];
|
||||||
|
if(!trashValid) {
|
||||||
|
_trash = [self findGroup:self.tree.metaData.recycleBinUuid];
|
||||||
|
}
|
||||||
|
return _trash;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (KPKGroup *)templates {
|
||||||
|
static KPKGroup *_templates = nil;
|
||||||
|
BOOL templateValid = [_templates.uuid isEqual:self.tree.metaData.entryTemplatesGroup];
|
||||||
|
if(!templateValid) {
|
||||||
|
_templates = [self findGroup:self.tree.metaData.entryTemplatesGroup];
|
||||||
|
}
|
||||||
|
return _templates;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTrash:(KPKGroup *)trash {
|
||||||
|
if(self.useTrash) {
|
||||||
|
if(![self.tree.metaData.recycleBinUuid isEqual:trash.uuid]) {
|
||||||
|
self.tree.metaData.recycleBinUuid = trash.uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTemplates:(KPKGroup *)templates {
|
||||||
|
if(![self.tree.metaData.entryTemplatesGroup isEqual:templates.uuid]) {
|
||||||
|
self.tree.metaData.entryTemplatesGroup = templates.uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setSelectedGroup:(KPKGroup *)selectedGroup {
|
- (void)setSelectedGroup:(KPKGroup *)selectedGroup {
|
||||||
if(_selectedGroup != selectedGroup) {
|
if(_selectedGroup != selectedGroup) {
|
||||||
_selectedGroup = selectedGroup;
|
_selectedGroup = selectedGroup;
|
||||||
@@ -368,27 +403,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
|
|||||||
return self.tree.metaData.recycleBinEnabled;
|
return self.tree.metaData.recycleBinEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (KPKGroup *)trash {
|
|
||||||
static KPKGroup *_trash = nil;
|
|
||||||
if(self.useTrash) {
|
|
||||||
BOOL trashValid = [_trash.uuid isEqual:self.tree.metaData.recycleBinUuid];
|
|
||||||
if(!trashValid) {
|
|
||||||
_trash = [self findGroup:self.tree.metaData.recycleBinUuid];
|
|
||||||
}
|
|
||||||
return _trash;
|
|
||||||
}
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (KPKGroup *)templates {
|
|
||||||
static KPKGroup *_templates = nil;
|
|
||||||
BOOL templateValid = [_templates.uuid isEqual:self.tree.metaData.entryTemplatesGroup];
|
|
||||||
if(!templateValid) {
|
|
||||||
_templates = [self findGroup:self.tree.metaData.entryTemplatesGroup];
|
|
||||||
}
|
|
||||||
return _templates;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isItemTrashed:(id)item {
|
- (BOOL)isItemTrashed:(id)item {
|
||||||
BOOL validItem = [item isKindOfClass:[KPKEntry class]] || [item isKindOfClass:[KPKGroup class]];
|
BOOL validItem = [item isKindOfClass:[KPKEntry class]] || [item isKindOfClass:[KPKGroup class]];
|
||||||
if(!item) {
|
if(!item) {
|
||||||
@@ -409,20 +423,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)useGroupAsTrash:(KPKGroup *)group {
|
|
||||||
if(self.useTrash) {
|
|
||||||
if(![self.tree.metaData.recycleBinUuid isEqual:group.uuid]) {
|
|
||||||
self.tree.metaData.recycleBinUuid = group.uuid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)useGroupAsTemplate:(KPKGroup *)group {
|
|
||||||
if(![self.tree.metaData.entryTemplatesGroup isEqual:group.uuid]) {
|
|
||||||
self.tree.metaData.entryTemplatesGroup = group.uuid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark Data manipulation
|
#pragma mark Data manipulation
|
||||||
- (KPKEntry *)createEntry:(KPKGroup *)parent {
|
- (KPKEntry *)createEntry:(KPKGroup *)parent {
|
||||||
if(!parent) {
|
if(!parent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user