Changeset 9298


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

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r9283 r9298  
    2525#import <Cocoa/Cocoa.h>
    2626#import <transmission.h>
     27#import <Quartz/Quartz.h>
    2728#import <Growl/Growl.h>
    2829
     
    4748} addType;
    4849
    49 @interface Controller : NSObject <GrowlApplicationBridgeDelegate>
     50#warning uncomment
     51@interface Controller : NSObject <GrowlApplicationBridgeDelegate> //, QLPreviewPanelDataSource, QLPreviewPanelDelegate>
    5052{
    5153    tr_session                      * fLib;
     
    109111   
    110112    BOOL                            fSoundPlaying;
     113   
     114    #warning change to QLPreviewPanel
     115    id fPreviewPanel;
    111116}
    112117
  • trunk/macosx/Controller.m

    r9292 r9298  
    31183118}
    31193119
     3120#warning change from id to QLPreviewPanel
     3121- (BOOL) acceptsPreviewPanelControl: (id) panel
     3122{
     3123    return YES;
     3124}
     3125
     3126- (void) beginPreviewPanelControl: (id) panel
     3127{
     3128    fPreviewPanel = [panel retain];
     3129    [fPreviewPanel setDelegate: self];
     3130    [fPreviewPanel setDataSource: self];
     3131}
     3132
     3133- (void) endPreviewPanelControl: (id) panel
     3134{
     3135    [fPreviewPanel release];
     3136    fPreviewPanel = nil;
     3137}
     3138
     3139- (NSInteger) numberOfPreviewItemsInPreviewPanel: (id) panel
     3140{
     3141    if ([fInfoController canQuickLook])
     3142        return [[fInfoController quickLookURLs] count];
     3143    else
     3144        return [[self quickLookableTorrents] count];
     3145}
     3146
     3147- (id /*<QLPreviewItem>*/) previewPanel: (id) panel previewItemAtIndex: (NSInteger) index
     3148{
     3149    if ([fInfoController canQuickLook])
     3150        return [[fInfoController quickLookURLs] objectAtIndex: index];
     3151    else
     3152        return [[self quickLookableTorrents] objectAtIndex: index];
     3153}
     3154
     3155- (BOOL) previewPanel: (id) panel handleEvent: (NSEvent *) event
     3156{
     3157    /*if ([event type] == NSKeyDown)
     3158    {
     3159        [super keyDown: event];
     3160        return YES;
     3161    }*/
     3162   
     3163    return NO;
     3164}
     3165
     3166- (NSRect) previewPanel: (id) panel sourceFrameOnScreenForPreviewItem: (id /*<QLPreviewItem>*/) item
     3167{
     3168    if ([fInfoController canQuickLook])
     3169        return [fInfoController quickLookSourceFrameForPreviewItem: item];
     3170    else
     3171    {
     3172        const NSInteger row = [fTableView rowForItem: item];
     3173        if (row == -1)
     3174            return NSZeroRect;
     3175       
     3176        NSRect frame = [fTableView iconRectForRow: row];
     3177        frame.origin = [fTableView convertPoint: frame.origin toView: nil];
     3178        frame.origin = [fWindow convertBaseToScreen: frame.origin];
     3179        frame.origin.y -= frame.size.height;
     3180        return frame;
     3181    }
     3182}
     3183
     3184- (NSArray *) quickLookableTorrents
     3185{
     3186    NSArray * selectedTorrents = [fTableView selectedTorrents];
     3187    NSMutableArray * qlArray = [NSMutableArray arrayWithCapacity: [selectedTorrents count]];
     3188   
     3189    for (Torrent * torrent in selectedTorrents)
     3190        if (([torrent isFolder] || [torrent isComplete]) && [[NSFileManager defaultManager] fileExistsAtPath: [torrent dataLocation]])
     3191            [qlArray addObject: torrent];
     3192   
     3193    return qlArray;
     3194}
     3195
    31203196- (ButtonToolbarItem *) standardToolbarButtonWithIdentifier: (NSString *) ident
    31213197{
  • trunk/macosx/InfoWindowController.h

    r9267 r9298  
    2525#import <Cocoa/Cocoa.h>
    2626#import <transmission.h>
    27 #import <Quartz/Quartz.h>
    2827
    2928@class Torrent;
     
    3332@class PiecesView;
    3433
    35 #warning uncomment
    36 @interface InfoWindowController : NSWindowController //<QLPreviewPanelDataSource, QLPreviewPanelDelegate>
     34@interface InfoWindowController : NSWindowController
    3735{
    3836    NSArray * fTorrents;
     
    9593- (void) addRemoveTracker: (id) sender;
    9694
     95- (NSArray *) quickLookURLs;
     96- (BOOL) canQuickLook;
     97- (NSRect) quickLookSourceFrameForPreviewItem: (id /*<QLPreviewItem>*/) item;
     98
    9799- (void) setPiecesView: (id) sender;
    98100- (void) setPiecesViewForAvailable: (BOOL) available;
  • 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
  • trunk/macosx/TorrentTableView.h

    r9283 r9298  
    2525#import <Cocoa/Cocoa.h>
    2626#import <transmission.h>
    27 #import <Quartz/Quartz.h>
    2827
    2928@class Controller;
     
    3332#define GROUP_SEPARATOR_HEIGHT 18.0
    3433
    35 #warning uncomment
    36 @interface TorrentTableView : NSOutlineView //<QLPreviewPanelDataSource, QLPreviewPanelDelegate>
     34@interface TorrentTableView : NSOutlineView
    3735{
    3836    IBOutlet Controller * fController;
     
    5553    CGFloat fPiecesBarPercent;
    5654    NSAnimation * fPiecesBarAnimation;
    57    
    58     #warning change to QLPreviewPanel
    59     id fPreviewPanel;
    6055}
    6156
  • trunk/macosx/TorrentTableView.m

    r9283 r9298  
    5151- (void) createFileMenu: (NSMenu *) menu forFiles: (NSArray *) files;
    5252
    53 - (NSArray *) quickLookableTorrents;
    54 
    5553@end
    5654
     
    8684- (void) dealloc
    8785{
    88     [fPreviewPanel release];
    89    
    9086    [fCollapsedGroups release];
    9187   
     
    876872}
    877873
    878 #warning change from id to QLPreviewPanel
    879 - (BOOL) acceptsPreviewPanelControl: (id) panel
    880 {
    881     return YES;
    882 }
    883 
    884 - (void) beginPreviewPanelControl: (id) panel
    885 {
    886     fPreviewPanel = [panel retain];
    887     [fPreviewPanel setDelegate: self];
    888     [fPreviewPanel setDataSource: self];
    889 }
    890 
    891 - (void) endPreviewPanelControl: (id) panel
    892 {
    893     [fPreviewPanel release];
    894     fPreviewPanel = nil;
    895 }
    896 
    897 - (NSInteger) numberOfPreviewItemsInPreviewPanel: (id) panel
    898 {
    899     return [[self quickLookableTorrents] count];
    900 }
    901 
    902 - (id /*<QLPreviewItem>*/) previewPanel: (id) panel previewItemAtIndex: (NSInteger) index
    903 {
    904     return [[self quickLookableTorrents] objectAtIndex: index];
    905 }
    906 
    907 - (BOOL) previewPanel: (id) panel handleEvent: (NSEvent *) event
    908 {
    909     if ([event type] == NSKeyDown)
    910     {
    911         [super keyDown: event];
    912         return YES;
    913     }
    914    
    915     return NO;
    916 }
    917 
    918 - (NSRect) previewPanel: (id) panel sourceFrameOnScreenForPreviewItem: (id /*<QLPreviewItem>*/) item
    919 {
    920     const NSInteger row = [self rowForItem: item];
    921     if (row == -1)
    922         return NSZeroRect;
    923    
    924     NSRect frame = [self iconRectForRow: row];
    925     frame.origin = [self convertPoint: frame.origin toView: nil];
    926     frame.origin = [[self window] convertBaseToScreen: frame.origin];
    927     frame.origin.y -= frame.size.height;
    928     return frame;
    929 }
    930 
    931874@end
    932875
     
    988931}
    989932
    990 - (NSArray *) quickLookableTorrents
    991 {
    992     NSArray * selectedTorrents = [self selectedTorrents];
    993     NSMutableArray * qlArray = [NSMutableArray arrayWithCapacity: [selectedTorrents count]];
    994    
    995     for (Torrent * torrent in selectedTorrents)
    996         if (([torrent isFolder] || [torrent isComplete]) && [[NSFileManager defaultManager] fileExistsAtPath: [torrent dataLocation]])
    997             [qlArray addObject: torrent];
    998    
    999     return qlArray;
    1000 }
    1001 
    1002933@end
Note: See TracChangeset for help on using the changeset viewer.