2007-09-16 01:02:06 +00:00
|
|
|
/******************************************************************************
|
2012-01-14 17:12:04 +00:00
|
|
|
* Copyright (c) 2007-2012 Transmission authors and contributors
|
2007-09-16 01:02:06 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-26 00:29:36 +00:00
|
|
|
#import "InfoWindowController.h"
|
2009-09-10 00:15:35 +00:00
|
|
|
#import "FileListNode.h"
|
2007-09-16 01:02:06 +00:00
|
|
|
#import "FileNameCell.h"
|
2009-09-10 00:15:35 +00:00
|
|
|
#import "FileOutlineView.h"
|
2007-09-16 01:02:06 +00:00
|
|
|
#import "FilePriorityCell.h"
|
|
|
|
#import "Torrent.h"
|
|
|
|
|
|
|
|
@implementation FileOutlineView
|
|
|
|
|
|
|
|
- (void) awakeFromNib
|
|
|
|
{
|
|
|
|
FileNameCell * nameCell = [[FileNameCell alloc] init];
|
|
|
|
[[self tableColumnWithIdentifier: @"Name"] setDataCell: nameCell];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
FilePriorityCell * priorityCell = [[FilePriorityCell alloc] init];
|
|
|
|
[[self tableColumnWithIdentifier: @"Priority"] setDataCell: priorityCell];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
[self setAutoresizesOutlineColumn: NO];
|
|
|
|
[self setIndentationPerLevel: 14.0];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-01-12 05:09:03 +00:00
|
|
|
fMouseRow = -1;
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) mouseDown: (NSEvent *) event
|
|
|
|
{
|
|
|
|
[[self window] makeKeyWindow];
|
|
|
|
[super mouseDown: event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *) menuForEvent: (NSEvent *) event
|
|
|
|
{
|
2010-02-07 17:37:01 +00:00
|
|
|
const NSInteger row = [self rowAtPoint: [self convertPoint: [event locationInWindow] fromView: nil]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
if (row >= 0)
|
|
|
|
{
|
|
|
|
if (![self isRowSelected: row])
|
|
|
|
[self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self deselectAll: self];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
return [self menu];
|
|
|
|
}
|
|
|
|
|
2008-05-21 22:09:05 +00:00
|
|
|
- (NSRect) iconRectForRow: (int) row
|
|
|
|
{
|
2008-06-30 19:52:18 +00:00
|
|
|
FileNameCell * cell = (FileNameCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Name"] row: row];
|
|
|
|
NSRect iconRect = [cell imageRectForBounds: [self rectOfRow: row]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-02-07 17:37:01 +00:00
|
|
|
iconRect.origin.x += [self indentationPerLevel] * (CGFloat)([self levelForRow: row] + 1);
|
2008-06-30 19:52:18 +00:00
|
|
|
return iconRect;
|
2008-05-21 22:09:05 +00:00
|
|
|
}
|
|
|
|
|
2008-01-12 03:39:26 +00:00
|
|
|
- (void) updateTrackingAreas
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-01-15 03:33:44 +00:00
|
|
|
[super updateTrackingAreas];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-12-26 07:25:17 +00:00
|
|
|
for (NSTrackingArea * area in [self trackingAreas])
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2017-07-08 14:38:47 +00:00
|
|
|
if ([area owner] == self && [area userInfo][@"Row"])
|
2008-01-12 03:39:26 +00:00
|
|
|
[self removeTrackingArea: area];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-01-12 03:53:41 +00:00
|
|
|
NSRange visibleRows = [self rowsInRect: [self visibleRect]];
|
2008-01-12 03:54:00 +00:00
|
|
|
if (visibleRows.length == 0)
|
|
|
|
return;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2016-01-07 17:21:12 +00:00
|
|
|
NSPoint mouseLocation = [self convertPoint: [[self window] mouseLocationOutsideOfEventStream] fromView: nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2016-09-11 10:22:49 +00:00
|
|
|
for (NSInteger row = visibleRows.location, col = [self columnWithIdentifier: @"Priority"]; (NSUInteger)row < NSMaxRange(visibleRows); row++)
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-01-12 03:39:26 +00:00
|
|
|
FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: col row: row];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-08 15:02:00 +00:00
|
|
|
NSDictionary * userInfo = @{@"Row": @(row)};
|
2008-01-12 03:39:26 +00:00
|
|
|
[cell addTrackingAreasForView: self inRect: [self frameOfCellAtColumn: col row: row] withUserInfo: userInfo
|
|
|
|
mouseLocation: mouseLocation];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-07 17:37:01 +00:00
|
|
|
- (NSInteger) hoveredRow
|
2008-03-25 03:17:35 +00:00
|
|
|
{
|
|
|
|
return fMouseRow;
|
|
|
|
}
|
|
|
|
|
2008-01-12 03:39:26 +00:00
|
|
|
- (void) mouseEntered: (NSEvent *) event
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2008-01-12 03:39:26 +00:00
|
|
|
NSNumber * row;
|
2017-07-08 14:38:47 +00:00
|
|
|
if ((row = ((NSDictionary *)[event userData])[@"Row"]))
|
2008-01-12 03:39:26 +00:00
|
|
|
{
|
2008-03-25 03:17:35 +00:00
|
|
|
fMouseRow = [row intValue];
|
2008-03-25 14:10:05 +00:00
|
|
|
[self setNeedsDisplayInRect: [self frameOfCellAtColumn: [self columnWithIdentifier: @"Priority"] row: fMouseRow]];
|
2008-01-12 03:39:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) mouseExited: (NSEvent *) event
|
|
|
|
{
|
|
|
|
NSNumber * row;
|
2017-07-08 14:38:47 +00:00
|
|
|
if ((row = ((NSDictionary *)[event userData])[@"Row"]))
|
2008-01-12 03:39:26 +00:00
|
|
|
{
|
2008-03-25 14:10:05 +00:00
|
|
|
[self setNeedsDisplayInRect: [self frameOfCellAtColumn: [self columnWithIdentifier: @"Priority"] row: [row intValue]]];
|
2008-01-12 03:39:26 +00:00
|
|
|
fMouseRow = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@end
|