|
@@ -256,6 +256,8 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
private var _dragPDFOutline: CPDFOutline?
|
|
|
|
|
|
+ var updatingOutlineSelection = false
|
|
|
+
|
|
|
override func loadView() {
|
|
|
super.loadView()
|
|
|
|
|
@@ -2784,13 +2786,15 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
}
|
|
|
|
|
|
func outlineViewSelectionDidChange(_ notification: Notification) {
|
|
|
+
|
|
|
if self.tocOutlineView.isEqual(to: notification.object) {
|
|
|
-// if ([[notification object] isEqual:leftSideController.tocOutlineView] && (mwcFlags.updatingOutlineSelection == 0)){
|
|
|
-// mwcFlags.updatingOutlineSelection = 1;
|
|
|
- self.goToSelectedOutlineItem(nil)
|
|
|
-// mwcFlags.updatingOutlineSelection = 0;
|
|
|
-// if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
|
|
|
-// [self hideLeftSideWindow];
|
|
|
+ if self.updatingOutlineSelection == false {
|
|
|
+ self.updatingOutlineSelection = true
|
|
|
+ self.goToSelectedOutlineItem(nil)
|
|
|
+ self.updatingOutlineSelection = false
|
|
|
+ // if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
|
|
|
+ // [self hideLeftSideWindow];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2925,6 +2929,14 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+ func outlineView(_ outlineView: NSOutlineView, willDisplayOutlineCell cell: Any, for tableColumn: NSTableColumn?, item: Any) {
|
|
|
+ if outlineView.isEqual(to: self.tocOutlineView) {
|
|
|
+ if outlineView.selectionHighlightStyle == .regular && outlineView.isRowSelected(outlineView.row(forItem: item)) {
|
|
|
+ (cell as? NSCell)?.backgroundStyle = .lowered
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
#pragma mark NSOutlineView datasource protocol
|
|
|
|
|
@@ -2952,14 +2964,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
return [tableColumn dataCellForRow:[ov rowForItem:item]];
|
|
|
}
|
|
|
|
|
|
- - (void)outlineView:(NSOutlineView *)ov willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
|
|
|
- if ([ov isEqual:leftSideController.tocOutlineView] &&
|
|
|
- [ov selectionHighlightStyle] == NSTableViewSelectionHighlightStyleRegular &&
|
|
|
- [ov isRowSelected:[ov rowForItem:item]]) {
|
|
|
- [cell setBackgroundStyle:NSBackgroundStyleLowered];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- (BOOL)outlineView:(NSOutlineView *)ov shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item{
|
|
|
if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
if (tableColumn == nil) {
|
|
@@ -3038,53 +3042,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- - (void)updateSelectRowHeight{
|
|
|
- CGFloat rowHeight = 0;
|
|
|
- PDFOutline *outline = [leftSideController.tocOutlineView itemAtRow:leftSideController.tocOutlineView.selectedRow];
|
|
|
- if (!outline){
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableAttributedString *attributedString = [[[NSMutableAttributedString alloc]init] autorelease];
|
|
|
- NSDictionary *dictAttr1 = @{NSForegroundColorAttributeName:[KMAppearance KMColor_Layout_H0]};
|
|
|
- NSAttributedString *attr1 = [[NSAttributedString alloc]initWithString:outline.label attributes:dictAttr1];
|
|
|
- [attributedString appendAttributedString:attr1];
|
|
|
-
|
|
|
- NSInteger *row = [leftSideController.tocOutlineView selectedRow];
|
|
|
- NSTableCellView *viewS = [leftSideController.tocOutlineView viewAtColumn:0 row:row makeIfNecessary:YES];
|
|
|
- NSTableColumn *tableColumn = [leftSideController.tocOutlineView tableColumnWithIdentifier:LABEL_COLUMNID];
|
|
|
- // id cell = [tableColumn dataCell];
|
|
|
- id cell = [tableColumn dataCellForRow:row];
|
|
|
- [cell setObjectValue:attributedString];
|
|
|
- CGFloat w = leftSideController.view.frame.size.width - 86;//[tableColumn width] > 260 ? [tableColumn width] : 260;
|
|
|
-
|
|
|
- NSInteger num = [self getNum:outline];
|
|
|
- CGFloat gap = [leftSideController.tocOutlineView indentationPerLevel];
|
|
|
- rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, w - (num > 0?16:0) - gap*num, CGFLOAT_MAX)].height;
|
|
|
- rowHeight = fmax(rowHeight, [leftSideController.tocOutlineView rowHeight]) + 25;
|
|
|
- [rowHeights setFloat:rowHeight forKey:outline];
|
|
|
-
|
|
|
- if (@available(macOS 10.13, *)) {
|
|
|
-
|
|
|
- } else {
|
|
|
- rowHeight = 40.0;
|
|
|
- }
|
|
|
- CGRect fram = viewS.frame;
|
|
|
- viewS.frame = CGRectMake(fram.origin.x, fram.origin.y, fram.size.width, rowHeight);
|
|
|
- [leftSideController.tocOutlineView reloadData];
|
|
|
- }
|
|
|
-
|
|
|
- - (NSInteger)getNum:(PDFOutline *)ol{
|
|
|
- NSInteger num = 0;
|
|
|
- PDFOutline *outLine = [ol parent];
|
|
|
- do {
|
|
|
- outLine = [outLine parent];
|
|
|
- if (outLine){
|
|
|
- num ++;
|
|
|
- }
|
|
|
- } while (outLine);
|
|
|
- return num;
|
|
|
- }
|
|
|
-
|
|
|
- (void)sizeOutlineViewToContents:(NSOutlineView*) outlineView;
|
|
|
{
|
|
|
NSInteger rowCount = [outlineView numberOfRows];
|
|
@@ -3139,56 +3096,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
}
|
|
|
return noteItems
|
|
|
}
|
|
|
- /*
|
|
|
-
|
|
|
- - (NSArray *)outlineView:(NSOutlineView *)ov typeSelectHelperSelectionStrings:(SKTypeSelectHelper *)typeSelectHelper {
|
|
|
- if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
- NSInteger i, count = [rightSideController.noteOutlineView numberOfRows];
|
|
|
- NSMutableArray *texts = [NSMutableArray arrayWithCapacity:count];
|
|
|
- for (i = 0; i < count; i++) {
|
|
|
- id item = [rightSideController.noteOutlineView itemAtRow:i];
|
|
|
- NSString *string = [item string];
|
|
|
- [texts addObject:string ?: @""];
|
|
|
- }
|
|
|
- return texts;
|
|
|
- } else if ([ov isEqual:leftSideController.tocOutlineView]) {
|
|
|
- NSInteger i, count = [leftSideController.tocOutlineView numberOfRows];
|
|
|
- NSMutableArray *array = [NSMutableArray arrayWithCapacity:count];
|
|
|
- for (i = 0; i < count; i++)
|
|
|
- [array addObject:[[(PDFOutline *)[leftSideController.tocOutlineView itemAtRow:i] label] lossyStringUsingEncoding:NSASCIIStringEncoding]];
|
|
|
- return array;
|
|
|
- }
|
|
|
- return nil;
|
|
|
- }
|
|
|
-
|
|
|
- - (void)outlineView:(NSOutlineView *)ov typeSelectHelper:(SKTypeSelectHelper *)typeSelectHelper didFailToFindMatchForSearchString:(NSString *)searchString {
|
|
|
- if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
- [statusBar setRightStringValue:[NSString stringWithFormat:NSLocalizedString(@"No match: \"%@\"", @"Status message"), searchString]];
|
|
|
- } else if ([ov isEqual:leftSideController.tocOutlineView]) {
|
|
|
- [statusBar setLeftStringValue:[NSString stringWithFormat:NSLocalizedString(@"No match: \"%@\"", @"Status message"), searchString]];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- - (void)outlineView:(NSOutlineView *)ov typeSelectHelper:(SKTypeSelectHelper *)typeSelectHelper updateSearchString:(NSString *)searchString {
|
|
|
- if ([typeSelectHelper isEqual:[leftSideController.thumbnailTableView typeSelectHelper]] || [typeSelectHelper isEqual:[pdfView typeSelectHelper]]) {
|
|
|
- if (searchString)
|
|
|
- [statusBar setLeftStringValue:[NSString stringWithFormat:NSLocalizedString(@"Go to page: %@", @"Status message"), searchString]];
|
|
|
- else
|
|
|
- [self updateLeftStatus];
|
|
|
- } else if ([typeSelectHelper isEqual:[rightSideController.noteOutlineView typeSelectHelper]]) {
|
|
|
- if (searchString)
|
|
|
- [statusBar setRightStringValue:[NSString stringWithFormat:NSLocalizedString(@"Finding note: \"%@\"", @"Status message"), searchString]];
|
|
|
- else
|
|
|
- [self updateRightStatus];
|
|
|
- } else if ([typeSelectHelper isEqual:[leftSideController.tocOutlineView typeSelectHelper]]) {
|
|
|
- if (searchString)
|
|
|
- [statusBar setLeftStringValue:[NSString stringWithFormat:NSLocalizedString(@"Finding: \"%@\"", @"Status message"), searchString]];
|
|
|
- else
|
|
|
- [self updateLeftStatus];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- */
|
|
|
}
|
|
|
|
|
|
// MARK: - KMCustomOutlineViewDelegate, KMCustomOutlineViewDataSource
|
|
@@ -3271,9 +3178,58 @@ extension KMLeftSideViewController: KMCustomOutlineViewDelegate, KMCustomOutline
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func outlineView(_ anOutlineView: NSOutlineView, typeSelectHelperSelectionStrings aTypeSelectHelper: SKTypeSelectHelper) -> NSArray {
|
|
|
+// if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
+// NSInteger i, count = [rightSideController.noteOutlineView numberOfRows];
|
|
|
+// NSMutableArray *texts = [NSMutableArray arrayWithCapacity:count];
|
|
|
+// for (i = 0; i < count; i++) {
|
|
|
+// id item = [rightSideController.noteOutlineView itemAtRow:i];
|
|
|
+// NSString *string = [item string];
|
|
|
+// [texts addObject:string ?: @""];
|
|
|
+// }
|
|
|
+// return texts;
|
|
|
+// } else
|
|
|
+ if self.tocOutlineView.isEqual(to: anOutlineView) {
|
|
|
+ let count = self.tocOutlineView.numberOfRows
|
|
|
+ var array = NSMutableArray(capacity: count)
|
|
|
+ for i in 0 ..< count {
|
|
|
+ // [array addObject:[[(PDFOutline *)[leftSideController.tocOutlineView itemAtRow:i] label] lossyStringUsingEncoding:NSASCIIStringEncoding]];
|
|
|
+ let item = self.tocOutlineView.item(atRow: i) as? CPDFOutline
|
|
|
+ array.add(item?.label ?? "")
|
|
|
+ }
|
|
|
+ return array
|
|
|
+ }
|
|
|
+ return NSArray()
|
|
|
+ }
|
|
|
+
|
|
|
+ func outlineView(_ anOutlineView: NSOutlineView, typeSelectHelper aTypeSelectHelper: SKTypeSelectHelper, didFailToFindMatchForSearchString searchString: String) {
|
|
|
+// if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
+// [statusBar setRightStringValue:[NSString stringWithFormat:NSLocalizedString(@"No match: \"%@\"", @"Status message"), searchString]];
|
|
|
+// } else if ([ov isEqual:leftSideController.tocOutlineView]) {
|
|
|
+// [statusBar setLeftStringValue:[NSString stringWithFormat:NSLocalizedString(@"No match: \"%@\"", @"Status message"), searchString]];
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ aTableView: NSTableView, typeSelectHelper aTypeSelectHelper: SKTypeSelectHelper, updateSearchString searchString: String) {
|
|
|
+// if ([typeSelectHelper isEqual:[leftSideController.thumbnailTableView typeSelectHelper]] || [typeSelectHelper isEqual:[pdfView typeSelectHelper]]) {
|
|
|
+// if (searchString)
|
|
|
+// [statusBar setLeftStringValue:[NSString stringWithFormat:NSLocalizedString(@"Go to page: %@", @"Status message"), searchString]];
|
|
|
+// else
|
|
|
+// [self updateLeftStatus];
|
|
|
+// } else if ([typeSelectHelper isEqual:[rightSideController.noteOutlineView typeSelectHelper]]) {
|
|
|
+// if (searchString)
|
|
|
+// [statusBar setRightStringValue:[NSString stringWithFormat:NSLocalizedString(@"Finding note: \"%@\"", @"Status message"), searchString]];
|
|
|
+// else
|
|
|
+// [self updateRightStatus];
|
|
|
+// } else if ([typeSelectHelper isEqual:[leftSideController.tocOutlineView typeSelectHelper]]) {
|
|
|
+// if (searchString)
|
|
|
+// [statusBar setLeftStringValue:[NSString stringWithFormat:NSLocalizedString(@"Finding: \"%@\"", @"Status message"), searchString]];
|
|
|
+// else
|
|
|
+// [self updateLeftStatus];
|
|
|
+// }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// MARK: - Other
|
|
|
|
|
|
extension KMLeftSideViewController {
|