mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-19 17:59:27 +00:00
More progress on Editing
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MPActionHelper.h"
|
||||
#import "MPDocument+HistoryBrowsing.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPEntryInspectorViewController.h"
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//
|
||||
|
||||
#import "MPAttachmentTableDataSource.h"
|
||||
#import "MPDocument+Attachment.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
@implementation MPAttachmentTableDataSource
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#import "MPAutotypeDaemon.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
#import "MPDocument+Autotype.h"
|
||||
#import "MPAutotypeCommand.h"
|
||||
#import "MPAutotypeContext.h"
|
||||
#import "MPAutotypePaste.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPDocument+Search.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
@class HNHGradientView;
|
||||
@class MPDocument;
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#import "KPKTree.h"
|
||||
#import "KPKMetaData.h"
|
||||
|
||||
#import "MPDocument+HistoryBrowsing.h"
|
||||
#import "MPDocument+Search.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPFlagsHelper.h"
|
||||
#import "MPEntrySearchContext.h"
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// MPDocument+Attachment.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 25.02.14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
@interface MPDocument (Attachments)
|
||||
|
||||
- (void)addAttachment:(NSURL *)location toEntry:(KPKEntry *)anEntry;
|
||||
|
||||
@end
|
||||
@@ -20,7 +20,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "MPDocument+Attachment.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKBinary.h"
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// MPDocument+Autotype.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 01/11/13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
@interface MPDocument (Autotype)
|
||||
|
||||
/**
|
||||
* Tests the given item for a possible wrong autotype format
|
||||
* MacPass 0.4 and 0.4.1 did store wrong Autotype sequences and thus mangled database files
|
||||
*
|
||||
* @param item Item to test for malformation. Allowed Items are KPKNode, KPKEntry, KPKGroup and KPKAutotype
|
||||
*
|
||||
* @return YES if the given item is considered a possible candidate. NO in all other cases
|
||||
*/
|
||||
+ (BOOL)isCandidateForMalformedAutotype:(id)item;
|
||||
|
||||
/**
|
||||
* Returns an NSArray containing all Autotype Contexts that match the given window title.
|
||||
* If no entry is set, all entries in the document will be searched
|
||||
*
|
||||
* @param windowTitle Window title to search matches for
|
||||
* @param entry Entry to use for lookup. If nil lookup will be performed in complete document
|
||||
*
|
||||
* @return NSArray of MPAutotypeContext objects matching the window title.
|
||||
*/
|
||||
- (NSArray *)autotypContextsForWindowTitle:(NSString *)windowTitle preferredEntry:(KPKEntry *)entryOrNil;
|
||||
/**
|
||||
* Checks if the document has malformed autotype items
|
||||
*
|
||||
* @return YES if any malformed items are found
|
||||
*/
|
||||
- (BOOL)hasMalformedAutotypeItems;
|
||||
|
||||
- (NSArray *)malformedAutotypeItems;
|
||||
|
||||
@end
|
||||
@@ -20,7 +20,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#import "MPDocument+Autotype.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPAutotypeContext.h"
|
||||
|
||||
#import "KPKGroup.h"
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// MPDocument+EditingSession.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 30/05/14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
@class MPEditingSession;
|
||||
|
||||
@interface MPDocument (EditingSession)
|
||||
|
||||
- (BOOL)hasActiveSession;
|
||||
- (void)cancelEditingSession;
|
||||
- (void)commitEditingSession;
|
||||
|
||||
@end
|
||||
@@ -6,43 +6,53 @@
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument+EditingSession.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPEditingSession.h"
|
||||
|
||||
#import "KPKNode.h"
|
||||
#import "MPEditingSession.h"
|
||||
|
||||
NSString *const MPDocumentDidBeginEditingSelectedItem = @"com.hicknhack.macpass.MPDocumentDidBeginEditingSelectedItem";
|
||||
NSString *const MPDocumentDidCancelChangesToSelectedItem = @"com.hicknhack.macpass.MPDocumentDidCancelChangesToSelectedItem";
|
||||
NSString *const MPDocumentDidCommitChangesToSelectedItem = @"com.hicknhack.macpass.MPDocumentDidCommitChangesToSelectedItem";
|
||||
|
||||
@implementation MPDocument (EditingSession)
|
||||
|
||||
- (BOOL)hasActiveSession {
|
||||
- (BOOL)isEditing {
|
||||
return (self.editingSession != nil);
|
||||
}
|
||||
|
||||
- (void)commitEditingSession {
|
||||
[self _commitEditingSession:self.editingSession];
|
||||
}
|
||||
|
||||
- (void)cancelEditingSession {
|
||||
[self _cancelEditingSession:self.editingSession];
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
- (void)_commitEditingSession:(MPEditingSession *)session {
|
||||
if(nil == session) {
|
||||
- (void)commitChangesToSelectedItem:(id)sender {
|
||||
if(nil == self.editingSession) {
|
||||
return; // No session to commit
|
||||
}
|
||||
[[self.undoManager prepareWithInvocationTarget:self] _cancelEditingSession:session];
|
||||
if(session.hasChanges) {
|
||||
}
|
||||
/* Force any lingering updates to be written */
|
||||
/* FIXME explore potential usage of:
|
||||
* NSObject(NSEditorRegistration)
|
||||
* NSObject(NSEditor)
|
||||
*/
|
||||
[((NSWindowController *)self.windowControllers.firstObject).window makeFirstResponder:nil];
|
||||
|
||||
/* update the data */
|
||||
[self.editingSession.source updateToNode:self.editingSession.node];
|
||||
[self.undoManager setActionName:NSLocalizedString(@"UPDATE_ENTRY", "")];
|
||||
self.editingSession = nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidCommitChangesToSelectedItem object:self];
|
||||
}
|
||||
|
||||
- (void)_cancelEditingSession:(MPEditingSession *)session {
|
||||
if(nil == session) {
|
||||
- (void)cancelChangesToSelectedItem:(id)sender {
|
||||
if(nil == self.editingSession) {
|
||||
return; // No session to cancel
|
||||
}
|
||||
[[self.undoManager prepareWithInvocationTarget:self] _commitEditingSession:session];
|
||||
if(session.hasChanges) {
|
||||
[session.node updateToNode:session.rollbackNode];
|
||||
self.editingSession = nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidCancelChangesToSelectedItem object:self];
|
||||
}
|
||||
|
||||
- (void)beginEditingSelectedItem:(id)sender {
|
||||
if(nil == self.selectedItem) {
|
||||
return;
|
||||
}
|
||||
self.editingSession = [[MPEditingSession alloc] initWithSource:self.selectedItem];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidBeginEditingSelectedItem object:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// MPDocument+HistoryBrowsing.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 26.02.14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
FOUNDATION_EXPORT NSString *const MPDocumentDidEnterHistoryNotification;
|
||||
FOUNDATION_EXPORT NSString *const MPDocumentDidExitHistoryNotification;
|
||||
|
||||
@interface MPDocument (HistoryBrowsing)
|
||||
|
||||
- (IBAction)showHistory:(id)sender;
|
||||
- (IBAction)exitHistory:(id)sender;
|
||||
|
||||
@end
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument+HistoryBrowsing.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
NSString *const MPDocumentDidEnterHistoryNotification = @"MPDocumentDidEnterHistoryNotification";
|
||||
NSString *const MPDocumentDidExitHistoryNotification = @"MPDocumentDidExitHistoryNotification";
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// MPDocument+Search.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 25.02.14.
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
@class MPEntrySearchContext;
|
||||
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidEnterSearchNotification;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchFlags;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidExitSearchNotification;
|
||||
/**
|
||||
* Posted by the document, when the search results have been updated. This is only called when searching.
|
||||
* If the search is exited, it will be notified by MPDocumentDidExitSearchNotification
|
||||
* The userInfo dictionary has one key kMPDocumentSearchResultsKey with an NSArray of KPKEntries matching the search.
|
||||
*/
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchResults;
|
||||
|
||||
/* keys used in userInfo dictionaries on notifications */
|
||||
FOUNDATION_EXTERN NSString *const kMPDocumentSearchResultsKey;
|
||||
|
||||
@interface MPDocument (Search)
|
||||
|
||||
- (void)enterSearchWithContext:(MPEntrySearchContext *)context;
|
||||
|
||||
/* Should be called by the NSSearchTextField to update the search string */
|
||||
- (IBAction)updateSearch:(id)sender;
|
||||
/* exits searching mode */
|
||||
- (IBAction)exitSearch:(id)sender;
|
||||
/* called by the filter toggle buttons */
|
||||
- (IBAction)toggleSearchFlags:(id)sender;
|
||||
|
||||
@end
|
||||
@@ -6,7 +6,6 @@
|
||||
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocument+Search.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
|
||||
|
||||
@@ -175,3 +175,109 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
- (IBAction)duplicateEntryWithOptions:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
@interface MPDocument (Attachments)
|
||||
|
||||
- (void)addAttachment:(NSURL *)location toEntry:(KPKEntry *)anEntry;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Autotype
|
||||
|
||||
@interface MPDocument (Autotype)
|
||||
|
||||
/**
|
||||
* Tests the given item for a possible wrong autotype format
|
||||
* MacPass 0.4 and 0.4.1 did store wrong Autotype sequences and thus mangled database files
|
||||
*
|
||||
* @param item Item to test for malformation. Allowed Items are KPKNode, KPKEntry, KPKGroup and KPKAutotype
|
||||
*
|
||||
* @return YES if the given item is considered a possible candiate. NO in all other cases
|
||||
*/
|
||||
+ (BOOL)isCandidateForMalformedAutotype:(id)item;
|
||||
|
||||
/**
|
||||
* Returns an NSArray containing all Autotype Contexts that match the given window title.
|
||||
* If no entry is set, all entries in the document will be searched
|
||||
*
|
||||
* @param windowTitle Window title to search matches for
|
||||
* @param entry Entry to use for lookup. If nil lookup will be performed in complete document
|
||||
*
|
||||
* @return NSArray of MPAutotypeContext objects matching the window title.
|
||||
*/
|
||||
- (NSArray *)autotypContextsForWindowTitle:(NSString *)windowTitle preferredEntry:(KPKEntry *)entryOrNil;
|
||||
/**
|
||||
* Checks if the document has malformed autotype items
|
||||
*
|
||||
* @return YES if any malformed items are found
|
||||
*/
|
||||
- (BOOL)hasMalformedAutotypeItems;
|
||||
|
||||
- (NSArray *)malformedAutotypeItems;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Edit Sessiong
|
||||
|
||||
APPKIT_EXTERN NSString *const MPDocumentDidBeginEditingSelectedItem;
|
||||
APPKIT_EXTERN NSString *const MPDocumentDidCancelChangesToSelectedItem;
|
||||
APPKIT_EXTERN NSString *const MPDocumentDidCommitChangesToSelectedItem;
|
||||
|
||||
@interface MPDocument (EditingSession)
|
||||
|
||||
- (BOOL)isEditing;
|
||||
|
||||
#pragma mark Edit Actions
|
||||
- (IBAction)beginEditingSelectedItem:(id)sender;
|
||||
- (IBAction)cancelChangesToSelectedItem:(id)sender;
|
||||
- (IBAction)commitChangesToSelectedItem:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark History Browsing
|
||||
|
||||
FOUNDATION_EXPORT NSString *const MPDocumentDidEnterHistoryNotification;
|
||||
FOUNDATION_EXPORT NSString *const MPDocumentDidExitHistoryNotification;
|
||||
|
||||
@interface MPDocument (HistoryBrowsing)
|
||||
|
||||
- (IBAction)showHistory:(id)sender;
|
||||
- (IBAction)exitHistory:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Search
|
||||
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidEnterSearchNotification;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchFlags;
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidExitSearchNotification;
|
||||
/**
|
||||
* Posted by the document, when the search results have been updated. This is only called when searching.
|
||||
* If the search is exited, it will be notified by MPDocumentDidExitSearchNotification
|
||||
* The userInfo dictionary has one key kMPDocumentSearchResultsKey with an NSArray of KPKEntries mathching the search.
|
||||
*/
|
||||
FOUNDATION_EXTERN NSString *const MPDocumentDidChangeSearchResults;
|
||||
|
||||
/* keys used in userInfo dictionaries on notifications */
|
||||
FOUNDATION_EXTERN NSString *const kMPDocumentSearchResultsKey;
|
||||
|
||||
@interface MPDocument (Search)
|
||||
|
||||
- (void)enterSearchWithContext:(MPEntrySearchContext *)context;
|
||||
|
||||
/* Should be called by the NSSearchTextField to update the search string */
|
||||
- (IBAction)updateSearch:(id)sender;
|
||||
/* exits searching mode */
|
||||
- (IBAction)exitSearch:(id)sender;
|
||||
/* called by the filter toggle buttons */
|
||||
- (IBAction)toggleSearchFlags:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocument+Search.h"
|
||||
#import "MPAppDelegate.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPDatabaseVersion.h"
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
#import "MPOutlineViewController.h"
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocument+Search.h"
|
||||
#import "MPDocument+Autotype.h"
|
||||
#import "MPDocument+HistoryBrowsing.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
|
||||
#import "MPPasteBoardController.h"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#import "MPFixAutotypeWindowController.h"
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocument+Autotype.h"
|
||||
#import "MPIconHelper.h"
|
||||
|
||||
#import "KPKNode.h"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#import "MPIconHelper.h"
|
||||
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPDocument+Search.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
NSString *const MPToolbarItemLock = @"TOOLBAR_LOCK";
|
||||
NSString *const MPToolbarItemAddGroup = @"TOOLBAR_ADD_GROUP";
|
||||
|
||||
Reference in New Issue
Block a user