source: trunk/macosx/FileOutlineView.m @ 12488

Last change on this file since 12488 was 12488, checked in by livings124, 11 years ago

#4245 Disable Quick Look space key in the inspector

  • Property Id set to /Users/mitchell/Desktop/Transmission/macosx/ActionMenuRatioToDisplayRatioTransformer.h
  • Property svn:keywords set to Date Rev Author Id
File size: 4.6 KB
Line 
1/******************************************************************************
2 * $Id: FileOutlineView.m 12488 2011-06-04 13:17:56Z livings124 $
3 *
4 * Copyright (c) 2007-2011 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "InfoWindowController.h"
26#import "FileListNode.h"
27#import "FileNameCell.h"
28#import "FileOutlineView.h"
29#import "FilePriorityCell.h"
30#import "Torrent.h"
31#import "NSApplicationAdditions.h"
32#import <Quartz/Quartz.h>
33
34@implementation FileOutlineView
35
36- (void) awakeFromNib
37{
38    FileNameCell * nameCell = [[FileNameCell alloc] init];
39    [[self tableColumnWithIdentifier: @"Name"] setDataCell: nameCell];
40    [nameCell release];
41   
42    FilePriorityCell * priorityCell = [[FilePriorityCell alloc] init];
43    [[self tableColumnWithIdentifier: @"Priority"] setDataCell: priorityCell];
44    [priorityCell release];
45   
46    [self setAutoresizesOutlineColumn: NO];
47    [self setIndentationPerLevel: 14.0];
48   
49    fMouseRow = -1;
50}
51
52- (void) dealloc
53{
54    [super dealloc];
55}
56
57- (void) mouseDown: (NSEvent *) event
58{
59    [[self window] makeKeyWindow];
60    [super mouseDown: event];
61}
62
63- (NSMenu *) menuForEvent: (NSEvent *) event
64{
65    const NSInteger row = [self rowAtPoint: [self convertPoint: [event locationInWindow] fromView: nil]];
66   
67    if (row >= 0)
68    {
69        if (![self isRowSelected: row])
70            [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
71    }
72    else
73        [self deselectAll: self];
74   
75    return [self menu];
76}
77
78- (NSRect) iconRectForRow: (int) row
79{
80    FileNameCell * cell = (FileNameCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Name"] row: row];
81    NSRect iconRect = [cell imageRectForBounds: [self rectOfRow: row]];
82   
83    iconRect.origin.x += [self indentationPerLevel] * (CGFloat)([self levelForRow: row] + 1);
84    return iconRect;
85}
86
87- (void) updateTrackingAreas
88{
89    [super updateTrackingAreas];
90   
91    for (NSTrackingArea * area in [self trackingAreas])
92    {
93        if ([area owner] == self && [[area userInfo] objectForKey: @"Row"])
94            [self removeTrackingArea: area];
95    }
96   
97    NSRange visibleRows = [self rowsInRect: [self visibleRect]];
98    if (visibleRows.length == 0)
99        return;
100   
101    NSPoint mouseLocation = [self convertPoint: [[self window] convertScreenToBase: [NSEvent mouseLocation]] fromView: nil];
102   
103    for (NSInteger row = visibleRows.location, col = [self columnWithIdentifier: @"Priority"]; row < NSMaxRange(visibleRows); row++)
104    {
105        FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: col row: row];
106       
107        NSDictionary * userInfo = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: row] forKey: @"Row"];
108        [cell addTrackingAreasForView: self inRect: [self frameOfCellAtColumn: col row: row] withUserInfo: userInfo
109                mouseLocation: mouseLocation];
110    }
111}
112
113- (NSInteger) hoveredRow
114{
115    return fMouseRow;
116}
117
118- (void) mouseEntered: (NSEvent *) event
119{
120    NSNumber * row;
121    if ((row = [(NSDictionary *)[event userData] objectForKey: @"Row"]))
122    {
123        fMouseRow = [row intValue];
124        [self setNeedsDisplayInRect: [self frameOfCellAtColumn: [self columnWithIdentifier: @"Priority"] row: fMouseRow]];
125    }
126}
127
128- (void) mouseExited: (NSEvent *) event
129{
130    NSNumber * row;
131    if ((row = [(NSDictionary *)[event userData] objectForKey: @"Row"]))
132    {
133        [self setNeedsDisplayInRect: [self frameOfCellAtColumn: [self columnWithIdentifier: @"Priority"] row: [row intValue]]];
134        fMouseRow = -1;
135    }
136}
137
138@end
Note: See TracBrowser for help on using the repository browser.