Added more protocols to clarify types for certain editors

This commit is contained in:
Michael Starke
2022-03-01 10:59:04 +01:00
parent 101cf7f6bd
commit a790103cd2
8 changed files with 32 additions and 10 deletions

View File

@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
/// View controller to show and edit KPKAttributes of KPKEntries.
/// Set the represented object to the KPKAttribute the editor shoudl show/edit
/// The editor can be set to edit or view
@interface MPEntryAttributeViewController : NSViewController <MPInspectorEditor, HNHUITextFieldDelegate>
@interface MPEntryAttributeViewController : NSViewController <MPAttributeInspectorEditor, HNHUITextFieldDelegate>
@property (strong) IBOutlet NSTextField *keyTextField;
@property (strong) IBOutlet HNHUISecureTextField *valueTextField;

View File

@@ -27,7 +27,6 @@ NSString *nameForDefaultKey(NSString *key) {
@interface MPEntryAttributeViewController () {
BOOL _isDefaultAttribute;
}
@property (readonly, nullable, strong) KPKAttribute *representedAttribute;
@end

View File

@@ -79,7 +79,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
MPTagsTokenFieldDelegate *_tagTokenFieldDelegate;
MPAddCustomFieldContextMenuDelegate *_addCustomFieldContextMenuDelegate;
NSMutableArray<NSViewController<MPInspectorEditor> *> *_attributeEditorViewControllers;
NSMutableArray<NSViewController<MPInspectorEditor> *> *_customAttributeEditorViewControllers;
MPEntryAttributeViewController *_titleEditorViewController;
MPEntryAttributeViewController *_usernameEditorViewController;
@@ -122,7 +122,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
_customFieldTableDelegate.viewController = self;
_addCustomFieldContextMenuDelegate.viewController = self;
_attributeEditorViewControllers = [[NSMutableArray alloc] init];
_customAttributeEditorViewControllers = [[NSMutableArray alloc] init];
_activeTab = MPEntryTabGeneral;
}
return self;

View File

@@ -11,6 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
/// View controller to edit password attributes of entries.
@interface MPEntryPasswordAttributeViewController : MPEntryAttributeViewController
@end

View File

@@ -16,8 +16,6 @@
@property (strong) IBOutlet NSButton *togglePasswordButton;
@property (strong) IBOutlet NSButton *generatePasswordButton;
@property (strong, nullable, readonly) KPKAttribute *representedAttribute;
@end
@implementation MPEntryPasswordAttributeViewController

View File

@@ -7,6 +7,10 @@
//
#import <Foundation/Foundation.h>
@class KPKAttribute;
@class KPKEntry;
@class KPKTimeInfo;
@class KPKNode;
NS_ASSUME_NONNULL_BEGIN
@@ -14,12 +18,33 @@ NS_ASSUME_NONNULL_BEGIN
/// Individual editors shoudl adopt different APIs to accomodate their needs
/// The preferred way to set model data is to use the representedObject
@protocol MPInspectorEditor <NSObject>
@required
@property (nonatomic) BOOL isEditor;
- (void)commitChanges;
@end
/// NodeInspectorEditors require the represented object to be a KPKNode
@protocol KPKNodeInspectorEditor <MPInspectorEditor>
@required
@property (nonatomic, nullable, readonly, strong) KPKNode *representedNode;
@end
/// EntryInspectorEditors require the represented object to be a KPKEnty
@protocol MPEntryInspectorEditor <MPInspectorEditor>
@required
@property (nonatomic, nullable, readonly, strong) KPKEntry *representedEntry;
@end
/// AttributeInspectorEditors require the represented object to be a KPKAttribute
@protocol MPAttributeInspectorEditor <MPInspectorEditor>
@required
@property (nonatomic, nullable, readonly, strong) KPKAttribute *representedAttribute;
@end
/// TimeInfoInpspectorEditors require the represented object to be a KPKTimeInfo
@protocol MPTimeInfoInpspectorEditor <MPInspectorEditor>
@required
@property (nonatomic, nullable, readonly, strong) KPKTimeInfo *representedTimeInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface MPNodeExpirationViewController : NSViewController <MPInspectorEditor>
@interface MPNodeExpirationViewController : NSViewController <MPTimeInfoInpspectorEditor>
@end

View File

@@ -13,7 +13,6 @@
@interface MPNodeExpirationViewController ()
@property (nonatomic, readonly, strong) KPKTimeInfo *representedTimeInfo;
@property (strong) IBOutlet NSButton *expiredCheckButton;
@property (strong) IBOutlet NSButton *pickExpireDateButton;