Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMListViewController.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 350 - (hide annotations) (download)
Sun May 16 02:50:00 2010 UTC (13 years, 11 months ago) by masakih
File size: 6230 byte(s)
著作権表示、免責表示を追加。
1 masaki 21 //
2     // XspfMListViewController.m
3     // XspfManager
4     //
5     // Created by Hori,Masaki on 09/11/07.
6     //
7    
8 masakih 350 /*
9     Copyright (c) 2009-2010, masakih
10     All rights reserved.
11     ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満たす場合に限り、再頒布および使用が許可されます。
12    
13     1, ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責条項を含めること。
14     2, バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の著作権表示、本条件一覧、および下記免責条項を含めること。
15     3, 書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売促進に、コントリビューターの名前を使用してはならない。
16     本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適合性に関する暗黙の保証も含め、またそれに限定されない、いかなる保証もありません。著作権者もコントリビューターも、事由のいかんを問わず、 損害発生の原因いかんを問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その他の)不法行為であるかを問わず、仮にそのような損害が発生する可能性を知らされていたとしても、本ソフトウェアの使用によって発生した(代替品または代用サービスの調達、使用の喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害について、一切責任を負わないものとします。
17     -------------------------------------------------------------------
18     Copyright (c) 2009-2010, masakih
19     All rights reserved.
20    
21     Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22    
23     1, Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
24     2, Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
25     3, The names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
26     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27     */
28    
29 masaki 21 #import "XspfMListViewController.h"
30    
31 masaki 192 #import "XspfManager.h"
32 masaki 21
33 masaki 212 #import "XspfMTableView.h"
34    
35 masaki 238 #import "XspfMXspfObject.h"
36 masaki 192
37 masaki 205
38 masaki 21 @implementation XspfMListViewController
39    
40 masaki 24 - (id)init
41     {
42     [super initWithNibName:@"ListView" bundle:nil];
43    
44     return self;
45     }
46 masaki 212 - (void)awakeFromNib
47     {
48     [tableView setDoubleAction:@selector(openXspf:)];
49     [tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
50     }
51 masaki 24
52 masaki 238 - (NSMenu *)contextMenuForObject:(XspfMXspfObject *)object
53 masaki 212 {
54 masaki 258 NSMenu *objMenu = [[NSApp delegate] menuForXspfObject:object];
55     return objMenu;
56 masaki 205 }
57    
58 masaki 212 - (NSMenu *)tableView:(XspfMTableView *)table menuForEvent:(NSEvent *)event
59 masaki 32 {
60 masaki 212 NSPoint mouse = [table convertPoint:[event locationInWindow] fromView:nil];
61     NSInteger row = [table rowAtPoint:mouse];
62     if(row == NSNotFound || row == -1) return nil;
63 masaki 205
64 masaki 238 XspfMXspfObject *object = [[[self representedObject] arrangedObjects] objectAtIndex:row];
65 masaki 212 return [self contextMenuForObject:object];
66 masaki 32 }
67 masaki 192 - (void)tableView:(NSTableView *)table sortDescriptorsDidChange:(NSArray *)oldDescriptors
68     {
69 masaki 204 // HMLog(HMLogLevelDebug, @"Enter %@, desc-> %@", NSStringFromSelector(_cmd), [table sortDescriptors]);
70 masaki 192 id controller = [self representedObject];
71     [controller willChangeValueForKey:@"selectionIndexes"];
72     [controller didChangeValueForKey:@"selectionIndexes"];
73     }
74    
75    
76 masaki 111 - (NSDragOperation)tableView:(NSTableView*)table
77     validateDrop:(id <NSDraggingInfo>)info
78     proposedRow:(NSInteger)row
79     proposedDropOperation:(NSTableViewDropOperation)dropOperation
80     {
81     id pb = [info draggingPasteboard];
82     id plist = [pb propertyListForType:NSFilenamesPboardType];
83    
84     NSWorkspace *ws = [NSWorkspace sharedWorkspace];
85     NSError *error = nil;
86     for(NSString *filePath in plist) {
87     NSString *type = [ws typeOfFile:filePath error:&error];
88     if(![ws type:type conformsToType:@"com.masakih.xspf"]) {
89     return NSDragOperationNone;
90     }
91     }
92     [table setDropRow:row dropOperation:NSTableViewDropAbove];
93    
94     return NSDragOperationCopy;
95     }
96    
97     - (BOOL)tableView:(NSTableView*)table
98     acceptDrop:(id <NSDraggingInfo>)info
99     row:(NSInteger)row
100     dropOperation:(NSTableViewDropOperation)dropOperation
101     {
102     id pb = [info draggingPasteboard];
103     id plist = [pb propertyListForType:NSFilenamesPboardType];
104    
105 masaki 184 [[NSApp delegate] registerFilePaths:plist];
106 masaki 111
107     return YES;
108     }
109    
110 masaki 304
111     // QLPreviewPanel support
112     - (NSRect)selectionItemRect
113     {
114     NSInteger col = [tableView columnWithIdentifier:@"title"];
115     NSInteger row = [tableView selectedRow];
116     NSRect rect = [tableView frameOfCellAtColumn:col row:row];
117 masaki 308
118     if(!NSIntersectsRect([tableView visibleRect], rect)) {
119     return NSZeroRect;
120     }
121    
122 masaki 304 rect = [tableView convertRectToBase:rect];
123     rect.origin = [[tableView window] convertBaseToScreen:rect.origin];
124     rect.size.width = rect.size.height;
125     return rect;
126     }
127 masaki 21 @end

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