mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-19 08:29:30 +00:00
KeePassKit API changes, undo/redo only for move/add/editing session
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
@@ -7,26 +7,27 @@
|
||||
//
|
||||
|
||||
#import "MPInspectorViewController.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPDatePickingViewController.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPEditingSession.h"
|
||||
#import "MPEntryInspectorViewController.h"
|
||||
#import "MPGroupInspectorViewController.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPNotifications.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPIconSelectViewController.h"
|
||||
#import "MPDatePickingViewController.h"
|
||||
#import "MPNotifications.h"
|
||||
#import "MPPopupImageView.h"
|
||||
|
||||
#import "NSDate+Humanized.h"
|
||||
#import "KPKNode+IconImage.h"
|
||||
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKGroup.h"
|
||||
#import "KPKTimeInfo.h"
|
||||
#import "KPKTree.h"
|
||||
#import "KPKMetaData.h"
|
||||
#import "KPKGroup.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKNode.h"
|
||||
#import "KPKTimeInfo.h"
|
||||
#import "KPKNode+IconImage.h"
|
||||
|
||||
#import "HNHGradientView.h"
|
||||
#import "MPPopupImageView.h"
|
||||
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
@@ -105,6 +106,12 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
[groupTabItem setInitialFirstResponder:groupView];
|
||||
|
||||
[[self view] layout];
|
||||
|
||||
/* Init edit and cancel buttons */
|
||||
[self.editButton setAction:@selector(beginEditingSelectedItem:)];
|
||||
[self.cancelEditButton setAction:@selector(cancelChangesToSelectedItem:)];
|
||||
[self.cancelEditButton setHidden:YES];
|
||||
|
||||
[self _updateBindings:nil];
|
||||
}
|
||||
|
||||
@@ -114,6 +121,21 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
name:MPDocumentCurrentItemChangedNotification
|
||||
object:document];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didBeginEditingSelectedItem:)
|
||||
name:MPDocumentDidBeginEditingSelectedItem
|
||||
object:document];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didCancelOrCommitChangesToSelectedItem:)
|
||||
name:MPDocumentDidCommitChangesToSelectedItem
|
||||
object:document];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didCancelOrCommitChangesToSelectedItem:)
|
||||
name:MPDocumentDidCancelChangesToSelectedItem
|
||||
object:document];
|
||||
|
||||
[self.entryViewController regsiterNotificationsForDocument:document];
|
||||
|
||||
[self.entryViewController setupBindings:document];
|
||||
@@ -163,38 +185,6 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Click Edit Button
|
||||
- (void)toggleEdit:(id)sender {
|
||||
BOOL didCancel = sender == self.cancelEditButton;
|
||||
MPDocument *document = [[self windowController] document];
|
||||
|
||||
if(document.selectedItem) {
|
||||
|
||||
/* TODO UndoManager handling */
|
||||
[self.editButton setTitle:NSLocalizedString(@"EDIT_ITEM", "")];
|
||||
[self.cancelEditButton setHidden:YES];
|
||||
[self.entryViewController endEditing];
|
||||
|
||||
/*
|
||||
We need to be careful to only undo the things we actually changed
|
||||
otherwise we undo older actions
|
||||
*/
|
||||
if(didCancel) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
//[document.selectedItem beginEditSession];
|
||||
[self.editButton setTitle:NSLocalizedString(@"SAVE_CHANGES", "")];
|
||||
[self.cancelEditButton setHidden:NO];
|
||||
[self.entryViewController beginEditing];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Popup
|
||||
- (IBAction)pickIcon:(id)sender {
|
||||
@@ -312,7 +302,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
- (void)_didChangeCurrentItem:(NSNotification *)notification {
|
||||
MPDocument *document = [notification object];
|
||||
if(!document.selectedItem) {
|
||||
/* show empty tab and hide edit button */
|
||||
/* show emty tab and hide edit button */
|
||||
self.activeTab = MPEmptyTab;
|
||||
}
|
||||
else {
|
||||
@@ -330,4 +320,20 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
/* disable the entry text fields whenever the entry selection changes */
|
||||
//[self.entryViewController endEditing];
|
||||
}
|
||||
@end
|
||||
|
||||
- (void)_didBeginEditingSelectedItem:(NSNotification *)notification {
|
||||
MPDocument *document = [notification object];
|
||||
[self.editButton setAction:@selector(commitChangesToSelectedItem:)];
|
||||
[self.editButton setTitle:NSLocalizedString(@"DONE", "")];
|
||||
[self.cancelEditButton setHidden:NO];
|
||||
[self _updateBindings:document.editingSession.node];
|
||||
}
|
||||
|
||||
- (void)_didCancelOrCommitChangesToSelectedItem:(NSNotification *)notification {
|
||||
MPDocument *document = [notification object];
|
||||
[self.editButton setTitle:NSLocalizedString(@"EDIT", "")];
|
||||
[self.cancelEditButton setHidden:YES];
|
||||
[self.editButton setAction:@selector(beginEditingSelectedItem:)];
|
||||
[self _updateBindings:document.selectedItem];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user