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/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{
Note: See TracChangeset for help on using the changeset viewer.