Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMListViewController.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 205 - (hide annotations) (download)
Mon Jan 4 06:55:07 2010 UTC (14 years, 3 months ago) by masaki
File size: 2488 byte(s)
[New] ラベル選択用メニューアイテムを作成。
1 masaki 21 //
2     // XspfMListViewController.m
3     // XspfManager
4     //
5     // Created by Hori,Masaki on 09/11/07.
6     // Copyright 2009 masakih. All rights reserved.
7     //
8    
9     #import "XspfMListViewController.h"
10    
11 masaki 192 #import "XspfManager.h"
12 masaki 21
13 masaki 205 #import "XspfMLabelMenuItem.h"
14 masaki 192
15 masaki 205
16 masaki 21 @implementation XspfMListViewController
17    
18 masaki 24 - (id)init
19     {
20     [super initWithNibName:@"ListView" bundle:nil];
21    
22     return self;
23     }
24    
25 masaki 205 - (NSMenu *)contextMenu
26     {
27     NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"title"] autorelease];
28    
29     NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:@"Label is Menu" action:Nil keyEquivalent:@""] autorelease];
30     [menu addItem:item];
31    
32     item = [[[XspfMLabelMenuItem alloc] initWithTitle:@"Label:" action:Nil keyEquivalent:@""] autorelease];
33     [menu addItem:item];
34     [(XspfMLabelMenuItem *)item setIntegerValue:4];
35    
36     item = [[[NSMenuItem alloc] initWithTitle:@"This is MenuMMMMMMMMMMMMMMMMMMMMMM" action:Nil keyEquivalent:@""] autorelease];
37     [menu addItem:item];
38    
39     return menu;
40     }
41    
42 masaki 32 - (void)awakeFromNib
43     {
44     [tableView setDoubleAction:@selector(openXspf:)];
45 masaki 111 [tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
46 masaki 205
47     [tableView setMenu:[self contextMenu]];
48 masaki 32 }
49    
50 masaki 111
51 masaki 192 - (void)tableView:(NSTableView *)table sortDescriptorsDidChange:(NSArray *)oldDescriptors
52     {
53 masaki 204 // HMLog(HMLogLevelDebug, @"Enter %@, desc-> %@", NSStringFromSelector(_cmd), [table sortDescriptors]);
54 masaki 192 id controller = [self representedObject];
55     [controller willChangeValueForKey:@"selectionIndexes"];
56     [controller didChangeValueForKey:@"selectionIndexes"];
57     }
58    
59    
60 masaki 111 - (NSDragOperation)tableView:(NSTableView*)table
61     validateDrop:(id <NSDraggingInfo>)info
62     proposedRow:(NSInteger)row
63     proposedDropOperation:(NSTableViewDropOperation)dropOperation
64     {
65     id pb = [info draggingPasteboard];
66     id plist = [pb propertyListForType:NSFilenamesPboardType];
67    
68     NSWorkspace *ws = [NSWorkspace sharedWorkspace];
69     NSError *error = nil;
70     for(NSString *filePath in plist) {
71     NSString *type = [ws typeOfFile:filePath error:&error];
72     if(![ws type:type conformsToType:@"com.masakih.xspf"]) {
73     return NSDragOperationNone;
74     }
75     }
76     [table setDropRow:row dropOperation:NSTableViewDropAbove];
77    
78     return NSDragOperationCopy;
79     }
80    
81     - (BOOL)tableView:(NSTableView*)table
82     acceptDrop:(id <NSDraggingInfo>)info
83     row:(NSInteger)row
84     dropOperation:(NSTableViewDropOperation)dropOperation
85     {
86     id pb = [info draggingPasteboard];
87     id plist = [pb propertyListForType:NSFilenamesPboardType];
88    
89 masaki 184 [[NSApp delegate] registerFilePaths:plist];
90 masaki 111
91     return YES;
92     }
93    
94 masaki 21 @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26