Skip to content

Commit

Permalink
Committing David Schaefgen's patch to add display of extended text vi…
Browse files Browse the repository at this point in the history
…a tooltips and dragging of posts to tags. Also incremented version to 27.
  • Loading branch information
ldandersen committed Nov 7, 2004
1 parent 057c5c4 commit cf2cf53
Show file tree
Hide file tree
Showing 8 changed files with 700 additions and 24 deletions.
65 changes: 59 additions & 6 deletions Application/AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ - (void) setupTaglist {
[tagList setAction: @selector(makePostListFirstResponder) forKey: NSRightArrowFunctionKey];

[tagList initializeColumnsUsingHeaderCellClass: [SFHFMetalTableHeaderCell class] formatterClass: [DCAPITagFormatter class]];

[tagList registerForDraggedTypes: [NSArray arrayWithObject: DCAPIPostPboardType]];

SFHFMetalTableHeaderCell *cornerCell = [[SFHFMetalTableHeaderCell alloc] initTextCell: @" "];
SFHFCornerView *cornerControl = [[SFHFCornerView alloc] init];
Expand Down Expand Up @@ -636,21 +638,72 @@ - (void) tableView: (NSTableView *) view setObjectValue: (id) object forTableCol

- (BOOL) tableView: (NSTableView *) tableView writeRows: (NSArray *) rows toPasteboard: (NSPasteboard *) pboard {
if (tableView == postList) {
[pboard declareTypes: [NSArray arrayWithObjects: NSURLPboardType, NSStringPboardType, NSFilenamesPboardType, nil] owner: self];
[pboard declareTypes: [NSArray arrayWithObject: DCAPIPostPboardType] owner: self];

NSNumber *currentPostIndex = [rows objectAtIndex: 0];
DCAPIPost *currentPost = [[self filteredPosts] objectAtIndex: [currentPostIndex unsignedIntValue]];

NSURL *currentURL = [currentPost URL];
[pboard setString: [currentURL absoluteString] forType: NSStringPboardType];
[currentURL writeToPasteboard: pboard];


[pboard setData: [NSKeyedArchiver archivedDataWithRootObject: currentPost] forType: DCAPIPostPboardType];

return YES;
}

return NO;
}

- (NSDragOperation) tableView: (NSTableView *) tableView validateDrop: (id <NSDraggingInfo>) info proposedRow: (int) row proposedDropOperation: (NSTableViewDropOperation) operation {
if (tableView == tagList && postList == [info draggingSource] && operation == NSTableViewDropOn && row > 0 && row <= [[self tags] count]) {
return NSDragOperationLink;
}

return NSDragOperationNone;
}

- (BOOL) tableView: (NSTableView *) tableView acceptDrop: (id <NSDraggingInfo>) info row: (int) row dropOperation: (NSTableViewDropOperation) operation {
#warning modify if tableView:validateDrop:proposedRow:proposedOperation returns for more than just tag assignment
NSPasteboard *pboard = [info draggingPasteboard];
NSData *data = [pboard dataForType: DCAPIPostPboardType];

DCAPIPost *post = [NSKeyedUnarchiver unarchiveObjectWithData: data];
NSString *postTags = [post tagsAsString];
postTags = [postTags stringByAppendingFormat: @" %@", [[[self tags] objectAtIndex: row - 1] name]];
[post setTagsFromString: postTags];

[[self client] addPost: post];

[self refresh: self];

return YES;

return NO;
}


// ----- beg implementation for postList tooltips -----
- (NSString *)tableView:(SFHFTableView *)tableView tooltipForItem:(id)item {
if (tableView == postList) {
NSString *toolTip = [item extended];
if (toolTip) {
return toolTip;
} else {
return @"No extended description available";
}
}
return nil;
}

- (id)tableView:(SFHFTableView *)tableView itemAtRow:(int)row {
if (tableView == postList) {
DCAPIPost *post = [[self filteredPosts] objectAtIndex: row];
if (post) {
return post;
}
}

return nil;
}
// ----- end implementation for postList tooltips -----

- (IBAction) copyAsTag: (id) sender {
NSIndexSet *rows = [postList selectedRowIndexes];

Expand Down
5 changes: 4 additions & 1 deletion DCAPI/DCAPIPost.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "defines.h"


@interface DCAPIPost : NSObject {
@interface DCAPIPost : NSObject <NSCoding> {
NSURL *URL;
NSString *description;
NSString *extended;
Expand All @@ -37,4 +37,7 @@
- (BOOL) matchesSearch: (NSString *) keyword extended: (BOOL) searchExtended tags: (NSArray *) matchTags matchKeywordsAsTags: (BOOL) matchKeywordsAsTags URIs: (BOOL) searchURIs;
- (BOOL) matchesTags: (NSArray *) matchTags;

- (id) initWithCoder:(NSCoder *) coder;
- (void) encodeWithCoder:(NSCoder *) coder;

@end
20 changes: 20 additions & 0 deletions DCAPI/DCAPIPost.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ - (BOOL) matchesTags: (NSArray *) matchTags {
return NO;
}

- (id) initWithCoder:(NSCoder *) coder {
[super init];
[self setURL: [coder decodeObjectForKey: @"URL"]];
[self setDescription: [coder decodeObjectForKey: @"description"]];
[self setExtended: [coder decodeObjectForKey: @"extendend"]];
[self setDate: [coder decodeObjectForKey: @"date"]];
[self setTags: [coder decodeObjectForKey: @"tags"]];
[self setHash: [coder decodeObjectForKey: @"hash"]];
return self;
}

- (void) encodeWithCoder:(NSCoder *) coder {
[coder encodeObject: URL forKey: @"URL"];
[coder encodeObject: description forKey: @"description"];
[coder encodeObject: extended forKey: @"extended"];
[coder encodeObject: date forKey: @"date"];
[coder encodeObject: tags forKey: @"tags"];
[coder encodeObject: hash forKey: @"hash"];
}

- (void) dealloc {
[URL release];
[description release];
Expand Down
Loading

0 comments on commit cf2cf53

Please sign in to comment.