diff options
author | Damiano Galassi <[email protected]> | 2019-02-05 14:03:27 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2019-02-05 14:03:27 +0100 |
commit | 6c3376e9db3b8b314b022e5991806c8696496585 (patch) | |
tree | 4666fe1edf8fdf3a1da1babed5fbd082db40aed5 /macosx/HBTableView.m | |
parent | 948a6712a11a7fe1f1f314ebb26f728a00ba963c (diff) |
MacGui: use a view-based table view in the queue window.
Diffstat (limited to 'macosx/HBTableView.m')
-rw-r--r-- | macosx/HBTableView.m | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/macosx/HBTableView.m b/macosx/HBTableView.m new file mode 100644 index 000000000..ba7ea4733 --- /dev/null +++ b/macosx/HBTableView.m @@ -0,0 +1,86 @@ +/* HBQueueOutlineView.m $ + + This file is part of the HandBrake source code. + Homepage: <http://handbrake.fr/>. + It may be used under the terms of the GNU General Public License. */ + +#import "HBTableView.h" + +@implementation HBTableView + +/** + * 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]; +} + +- (void)keyDown:(NSEvent *)event +{ + id delegate = self.delegate; + + NSString *characters = [event charactersIgnoringModifiers]; + if (characters.length) + { + unichar key = [characters characterAtIndex:0]; + if ((key == NSDeleteCharacter || key == NSDeleteFunctionKey) && + [delegate respondsToSelector:@selector(HB_deleteSelectionFromTableView:)]) + { + if (self.selectedRow == -1) + { + NSBeep(); + } + else + { + [delegate HB_deleteSelectionFromTableView:self]; + } + return; + } + else if (key == NSLeftArrowFunctionKey && + [delegate respondsToSelector:@selector(HB_collapseSelectionFromTableView:)]) + { + [delegate HB_collapseSelectionFromTableView:self]; + return; + } + else if (key == NSRightArrowFunctionKey && + [delegate respondsToSelector:@selector(HB_expandSelectionFromTableView:)]) + { + [delegate HB_expandSelectionFromTableView:self]; + return; + } + } + + [super keyDown:event]; +} + +- (void)viewDidEndLiveResize +{ + // Since we disabled calculating row heights during a live resize, force them to + // recalculate now. + [self noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.numberOfRows)]]; + [super viewDidEndLiveResize]; +} + +@end |