]> granicus.if.org Git - handbrake/commitdiff
MacGui: modified the way the queue contextual menu selects its target. It now uses...
authorritsuka <damiog@gmail.com>
Sat, 1 Nov 2014 16:09:43 +0000 (16:09 +0000)
committerritsuka <damiog@gmail.com>
Sat, 1 Nov 2014 16:09:43 +0000 (16:09 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6492 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBQueueController.mm

index 33510e524c2d708f72e3be41ae43b8ca1cd337e2..19fc8a37ac492c78c87aacd18a1b388d23e084d1 100644 (file)
     }
 }
 
+/**
+ *  An index set containing the indexes of the targeted rows.
+ *  If the selected row indexes contain the clicked row index, it returns every selected row,
+ *  otherwise it returns only the clicked row index.
+ */
+- (NSIndexSet *)targetedRowIndexes
+{
+    NSMutableIndexSet *rowIndexes = [NSMutableIndexSet indexSet];
+    NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
+    NSInteger clickedRow = [self clickedRow];
+
+    if (clickedRow != -1)
+    {
+        [rowIndexes addIndex:clickedRow];
+
+        // If we clicked on a selected row, then we want to consider all rows in the selection. Otherwise, we only consider the clicked on row.
+        if ([selectedRowIndexes containsIndex:clickedRow])
+        {
+            [rowIndexes addIndexes:selectedRowIndexes];
+        }
+    }
+    else
+    {
+        [rowIndexes addIndexes:selectedRowIndexes];
+    }
+
+    return [[rowIndexes copy] autorelease];
+}
+
 @end
 
 #pragma mark -
 //------------------------------------------------------------------------------------
 - (IBAction)removeSelectedQueueItem: (id)sender
 {
-    NSIndexSet * selectedRows = [fOutlineView selectedRowIndexes];
-    NSUInteger row = [selectedRows firstIndex];
+    NSIndexSet *targetedRow = [fOutlineView targetedRowIndexes];
+    NSUInteger row = [targetedRow firstIndex];
     if( row == NSNotFound )
         return;
     /* if this is a currently encoding job, we need to be sure to alert the user,
 //------------------------------------------------------------------------------------
 - (IBAction)revealSelectedQueueItem: (id)sender
 {
-    NSIndexSet * selectedRows = [fOutlineView selectedRowIndexes];
-    NSInteger row = [selectedRows firstIndex];
+    NSIndexSet *targetedRow = [fOutlineView targetedRowIndexes];
+    NSInteger row = [targetedRow firstIndex];
     if (row != NSNotFound)
     {
         while (row != NSNotFound)
             NSMutableDictionary *queueItemToOpen = [fOutlineView itemAtRow: row];
             [[NSWorkspace sharedWorkspace] selectFile:queueItemToOpen[@"DestinationPath"] inFileViewerRootedAtPath:nil];
 
-            row = [selectedRows indexGreaterThanIndex: row];
+            row = [targetedRow indexGreaterThanIndex: row];
         }
     }
 }
 //------------------------------------------------------------------------------------
 - (IBAction)editSelectedQueueItem: (id)sender
 {
-    NSIndexSet * selectedRows = [fOutlineView selectedRowIndexes];
-    NSUInteger row = [selectedRows firstIndex];
-    if( row == NSNotFound )
+    NSInteger row = [fOutlineView clickedRow];
+    if (row == NSNotFound)
+    {
         return;
+    }
+
     /* if this is a currently encoding job, we need to be sure to alert the user,
      * to let them decide to cancel it first, then if they do, we can come back and
      * remove it */