mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 20:49:35 +00:00
Subbed Kdb3 Entry attachment handling.
This commit is contained in:
18
MacPass/Kdb3Entry+KVOAdditions.h
Normal file
18
MacPass/Kdb3Entry+KVOAdditions.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Kdb3Entry+KVOAdditions.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 19.07.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Kdb3Node.h"
|
||||
|
||||
@interface Kdb3Entry (KVOAdditions)
|
||||
|
||||
- (NSUInteger)countOfBinaries;
|
||||
- (id)objectInBinariesAtIndex:(NSUInteger)index;
|
||||
- (void)removeObjectFromBinariesAtIndex:(NSUInteger)index;
|
||||
- (void)insertObject:(id)binary inBinariesAtIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
31
MacPass/Kdb3Entry+KVOAdditions.m
Normal file
31
MacPass/Kdb3Entry+KVOAdditions.m
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Kdb3Entry+KVOAdditions.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 19.07.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Kdb3Entry+KVOAdditions.h"
|
||||
|
||||
@implementation Kdb3Entry (KVOAdditions)
|
||||
|
||||
- (NSUInteger)countOfBinaries {
|
||||
return (self.binary != nil ? 1 : 0);
|
||||
}
|
||||
- (id)objectInBinariesAtIndex:(NSUInteger)index {
|
||||
if(self.binary) {
|
||||
return @"Dummy";
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
- (void)removeObjectFromBinariesAtIndex:(NSUInteger)index {
|
||||
return; // Stubb
|
||||
}
|
||||
- (void)insertObject:(id)binary inBinariesAtIndex:(NSUInteger)index {
|
||||
return; //Stubb
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -12,6 +12,7 @@
|
||||
#import "MPSelectedAttachmentTableCellView.h"
|
||||
|
||||
#import "Kdb4Node.h"
|
||||
#import "Kdb3Node.h"
|
||||
|
||||
#import "HNHTableRowView.h"
|
||||
|
||||
@@ -20,9 +21,16 @@
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
|
||||
NSTableView *tableView = [notification object];
|
||||
NSIndexSet *allColumns = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[tableView tableColumns] count])];
|
||||
Kdb4Entry *entryv4 = (Kdb4Entry *)self.viewController.selectedEntry;
|
||||
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [entryv4.binaries count] )];
|
||||
[tableView reloadDataForRowIndexes:indexSet columnIndexes:allColumns];
|
||||
if([self.viewController.selectedEntry isKindOfClass:[Kdb4Entry class]]) {
|
||||
Kdb4Entry *entryv4 = (Kdb4Entry *)self.viewController.selectedEntry;
|
||||
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [entryv4.binaries count] )];
|
||||
[tableView reloadDataForRowIndexes:indexSet columnIndexes:allColumns];
|
||||
}
|
||||
if([self.viewController.selectedEntry isKindOfClass:[Kdb3Entry class]]) {
|
||||
Kdb3Entry *entryv3 = (Kdb3Entry *)self.viewController.selectedEntry;
|
||||
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, (entryv3.binary ? 1 : 0 ))];
|
||||
[tableView reloadDataForRowIndexes:indexSet columnIndexes:allColumns];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
@@ -50,7 +58,9 @@
|
||||
[[view imageView] setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[binaryRef.key pathExtension]]];
|
||||
}
|
||||
else {
|
||||
// Create view to support only one binary!
|
||||
Kdb3Entry *entry= (Kdb3Entry *)self.viewController.selectedEntry;
|
||||
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"binaryDesc" options:nil];
|
||||
[[view imageView] setImage:[[NSWorkspace sharedWorkspace] iconForFileType:[entry.binaryDesc pathExtension]]];
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#import "NSData+Gzip.h"
|
||||
|
||||
#import "Kdb3Node.h"
|
||||
#import "Kdb3Entry+KVOAdditions.h"
|
||||
#import "Kdb4Node.h"
|
||||
#import "Kdb4Entry+KVOAdditions.h"
|
||||
|
||||
@@ -31,6 +32,7 @@
|
||||
}
|
||||
entry.binary = binaryData;
|
||||
entry.binaryDesc = fileName;
|
||||
[entry insertObject:@"" inBinariesAtIndex:1];
|
||||
}
|
||||
if( [anEntry isKindOfClass:[Kdb4Entry class]]) {
|
||||
Kdb4Entry *entry = (Kdb4Entry *)anEntry;
|
||||
|
||||
@@ -185,7 +185,7 @@ enum {
|
||||
[_attachmentsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"binaries" options:nil];
|
||||
}
|
||||
else {
|
||||
/* Use binary from Kdb3Entry */
|
||||
[_attachmentsController bind:NSContentArrayBinding toObject:self.selectedEntry withKeyPath:@"binaries" options:nil];
|
||||
}
|
||||
}
|
||||
else if([_attachmentsController content] != nil){
|
||||
@@ -384,7 +384,7 @@ enum {
|
||||
- (IBAction)removeAttachment:(id)sender {
|
||||
MPDocument *document = [[self windowController] document];
|
||||
if(document.version == MPDatabaseVersion3) {
|
||||
// Uhhhh :D
|
||||
// Handle entry
|
||||
}
|
||||
if(document.version == MPDatabaseVersion4) {
|
||||
Kdb4Entry *entry = (Kdb4Entry *)self.selectedEntry;
|
||||
|
||||
Reference in New Issue
Block a user