Ignore:
Timestamp:
Oct 11, 2009, 11:16:46 PM (13 years ago)
Author:
livings124
Message:

phase one of moving quicklook into the controller - it's not as pretty code-wise but the behavior is a lot more consistent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r9297 r9298  
    8787- (NSArray *) peerSortDescriptors;
    8888
    89 - (NSArray *) quickLookURLs;
    90 - (BOOL) canQuickLook;
    9189- (BOOL) canQuickLookFile: (FileListNode *) item;
    9290
     
    815813    [view setHidden: NO];
    816814   
     815    #warning take a look at
    817816    if ([NSApp isOnSnowLeopardOrBetter] && (fCurrentTabTag == TAB_FILES_TAG || oldTabTag == TAB_FILES_TAG)
    818817        && ([QLPreviewPanelSL sharedPreviewPanelExists] && [[QLPreviewPanelSL sharedPreviewPanel] isVisible]))
     
    11211120}*/
    11221121
    1123 #warning change to QLPreviewPanel
    1124 - (BOOL) acceptsPreviewPanelControl: (id) panel
    1125 {
    1126     return fCurrentTabTag == TAB_FILES_TAG && [self canQuickLook];
    1127 }
    1128 
    1129 - (void) beginPreviewPanelControl: (id) panel
    1130 {
    1131     fPreviewPanel = [panel retain];
    1132     [fPreviewPanel setDelegate: self];
    1133     [fPreviewPanel setDataSource: self];
    1134 }
    1135 
    1136 - (void) endPreviewPanelControl: (id) panel
    1137 {
    1138     [fPreviewPanel release];
    1139     fPreviewPanel = nil;
    1140 }
    1141 
    1142 - (NSInteger) numberOfPreviewItemsInPreviewPanel: (id) panel
    1143 {
    1144     return [[self quickLookURLs] count];
    1145 }
    1146 
    1147 - (id /*<QLPreviewItem>*/) previewPanel: (id)panel previewItemAtIndex: (NSInteger) index
    1148 {
    1149     return [[self quickLookURLs] objectAtIndex: index];
    1150 }
    1151 
    1152 - (BOOL) previewPanel: (id) panel handleEvent: (NSEvent *) event
    1153 {
    1154     if ([event type] == NSKeyDown)
    1155     {
    1156         [super keyDown: event];
    1157         return YES;
    1158     }
     1122- (NSArray *) quickLookURLs
     1123{
     1124    FileOutlineView * fileOutlineView = [fFileController outlineView];
     1125    Torrent * torrent = [fTorrents objectAtIndex: 0];
     1126    NSString * folder = [torrent downloadFolder];
     1127    NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
     1128    NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [indexes count]];
     1129   
     1130    for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
     1131    {
     1132        FileListNode * item = [fileOutlineView itemAtRow: i];
     1133        if ([self canQuickLookFile: item])
     1134            [urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item fullPath]]]];
     1135    }
     1136   
     1137    return urlArray;
     1138}
     1139
     1140- (BOOL) canQuickLook
     1141{
     1142    if (fCurrentTabTag != TAB_FILES_TAG || ![NSApp isOnSnowLeopardOrBetter])
     1143        return NO;
     1144   
     1145    if ([fTorrents count] != 1)
     1146        return NO;
     1147   
     1148    Torrent * torrent = [fTorrents objectAtIndex: 0];
     1149    if (![torrent isFolder])
     1150        return NO;
     1151   
     1152    FileOutlineView * fileOutlineView = [fFileController outlineView];
     1153    NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
     1154   
     1155    for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
     1156        if ([self canQuickLookFile: [fileOutlineView itemAtRow: i]])
     1157            return YES;
    11591158   
    11601159    return NO;
    11611160}
    11621161
    1163 - (NSRect) previewPanel: (id) panel sourceFrameOnScreenForPreviewItem: (id /*<QLPreviewItem>*/) item
     1162#warning uncomment (in header too)
     1163- (NSRect) quickLookSourceFrameForPreviewItem: (id /*<QLPreviewItem>*/) item
    11641164{
    11651165    FileOutlineView * fileOutlineView = [fFileController outlineView];
     
    16531653}
    16541654
    1655 - (NSArray *) quickLookURLs
    1656 {
    1657     FileOutlineView * fileOutlineView = [fFileController outlineView];
    1658     Torrent * torrent = [fTorrents objectAtIndex: 0];
    1659     NSString * folder = [torrent downloadFolder];
    1660     NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
    1661     NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [indexes count]];
    1662    
    1663     for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    1664     {
    1665         FileListNode * item = [fileOutlineView itemAtRow: i];
    1666         if ([self canQuickLookFile: item])
    1667             [urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item fullPath]]]];
    1668     }
    1669    
    1670     return urlArray;
    1671 }
    1672 
    1673 - (BOOL) canQuickLook
    1674 {
    1675     if (![NSApp isOnSnowLeopardOrBetter])
    1676         return NO;
    1677    
    1678     FileOutlineView * fileOutlineView = [fFileController outlineView];
    1679     NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
    1680    
    1681     for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    1682         if ([self canQuickLookFile: [fileOutlineView itemAtRow: i]])
    1683             return YES;
    1684    
    1685     return NO;
    1686 }
    1687 
    16881655- (BOOL) canQuickLookFile: (FileListNode *) item
    16891656{
     
    16931660        return NO;
    16941661   
    1695     return [item isFolder] || [torrent fileProgress: item] == 1.0;
     1662    return [item isFolder] || [torrent fileProgress: item] >= 1.0;
    16961663}
    16971664
Note: See TracChangeset for help on using the changeset viewer.