|
@@ -33,6 +33,9 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
var selectPages: [Int]?
|
|
|
open weak var delegate: KMLeftSideViewControllerDelegate?
|
|
|
|
|
|
+ let noteColumnId = NSUserInterfaceItemIdentifier(rawValue: "note")
|
|
|
+ let authorColumnId = NSUserInterfaceItemIdentifier(rawValue: "author")
|
|
|
+
|
|
|
deinit {
|
|
|
KMPrint("KMLeftSideViewController deinit.")
|
|
|
|
|
@@ -88,7 +91,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
NSArrayController *findArrayController;
|
|
|
NSArrayController *groupedFindArrayController;
|
|
|
}
|
|
|
- - (void)applySearchTableHeader:(NSString *)message;
|
|
|
*/
|
|
|
|
|
|
@IBOutlet var segmentedControl: KMSegmentedControl!
|
|
@@ -257,6 +259,8 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
private var _dragPDFOutline: CPDFOutline?
|
|
|
|
|
|
+ var updatingOutlineSelection = false
|
|
|
+
|
|
|
override func loadView() {
|
|
|
super.loadView()
|
|
|
|
|
@@ -362,11 +366,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// //支持拖拽的文字类型
|
|
|
|
|
|
// [tocOutlineView setTypeSelectHelper:[SKTypeSelectHelper typeSelectHelperWithMatchOption:SKSubstringMatch]];
|
|
|
-
|
|
|
-// [[[findTableView tableColumnWithIdentifier:PAGE_COLUMNID] headerCell] setTitle:NSLocalizedString(@"Page", @"Table header title")];
|
|
|
-// [[[groupedFindTableView tableColumnWithIdentifier:PAGE_COLUMNID] headerCell] setTitle:NSLocalizedString(@"Page", @"Table header title")];
|
|
|
-// [[[groupedFindTableView tableColumnWithIdentifier:RELEVANCE_COLUMNID] dataCell] setEnabled:NO];
|
|
|
-
|
|
|
// NSSortDescriptor *countDescriptor = [[[NSSortDescriptor alloc] initWithKey:SKGroupedSearchResultCountKey ascending:NO] autorelease];
|
|
|
// [groupedFindArrayController setSortDescriptors:[NSArray arrayWithObjects:countDescriptor, nil]];
|
|
|
|
|
@@ -571,10 +570,10 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
frame.size.height = self.snapshotTableView.enclosingScrollView?.superview?.frame.size.height ?? 0
|
|
|
self.snapshotTableView.enclosingScrollView?.frame = frame
|
|
|
|
|
|
-// frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
-// frame.origin.y = 0;
|
|
|
-// frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
-// rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
+ frame = self.noteOutlineView.enclosingScrollView?.frame ?? .zero
|
|
|
+ frame.origin.y = 0
|
|
|
+ frame.size.height = self.noteOutlineView.enclosingScrollView?.superview?.frame.size.height ?? 0
|
|
|
+ self.noteOutlineView.enclosingScrollView?.frame = frame
|
|
|
|
|
|
frame = self.tocOutlineView.enclosingScrollView?.frame ?? .zero
|
|
|
frame.origin.y = 0
|
|
@@ -671,15 +670,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
self.snapshotSearchField.delegate = self
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- - (void)applySearchTableHeader:(NSString *)message {
|
|
|
- [[[findTableView tableColumnWithIdentifier:RESULTS_COLUMNID] headerCell] setStringValue:message];
|
|
|
- [[findTableView headerView] setNeedsDisplay:YES];
|
|
|
- [[[groupedFindTableView tableColumnWithIdentifier:RELEVANCE_COLUMNID] headerCell] setStringValue:message];
|
|
|
- [[groupedFindTableView headerView] setNeedsDisplay:YES];
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
func resetThumbnails() {
|
|
|
// [self willChangeValueForKey:THUMBNAILS_KEY];
|
|
|
// self.thumbnailCacheSize = 160
|
|
@@ -1249,10 +1239,10 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
} else if (tableView.isEqual(to: self.findTableView)) {
|
|
|
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMFindTableviewCell"), owner: self) as! KMFindTableviewCell
|
|
|
let selection = searchResults[row]
|
|
|
- if let data = tableColumn?.identifier.rawValue, data == "results" {
|
|
|
+ if let data = tableColumn?.identifier.rawValue, data == kResultsColumnId.rawValue {
|
|
|
cell.resultLabel.attributedStringValue = selection.attributedString
|
|
|
cell.resultLabel.textColor = KMAppearance.Layout.h0Color()
|
|
|
- } else if let data = tableColumn?.identifier.rawValue, data == "page" {
|
|
|
+ } else if let data = tableColumn?.identifier.rawValue, data == kPageColumnId.rawValue {
|
|
|
cell.resultLabel.stringValue = "\(Int(selection.selection.page?.pageIndex() ?? 0) + 1)"
|
|
|
cell.resultLabel.textColor = KMAppearance.Layout.h2Color()
|
|
|
}
|
|
@@ -1375,13 +1365,11 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
|
|
|
}
|
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
|
-// if ([[aNotification object] isEqual:leftSideController.findTableView] || [[aNotification object] isEqual:leftSideController.groupedFindTableView]) {
|
|
|
-// [self updateFindResultHighlightsForDirection:NSDirectSelection];
|
|
|
-//
|
|
|
-// if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
|
|
|
-// [self hideLeftSideWindow];
|
|
|
-// } else
|
|
|
if self.findTableView.isEqual(to: notification.object) {
|
|
|
+ // [self updateFindResultHighlightsForDirection:NSDirectSelection];
|
|
|
+ //
|
|
|
+ // if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
|
|
|
+ // [self hideLeftSideWindow];
|
|
|
let row = self.findTableView.selectedRow
|
|
|
if row >= 0 {
|
|
|
let model = self.searchResults[row]
|
|
@@ -1391,6 +1379,11 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
self.listView.setNeedsDisplayAnnotationViewForVisiblePages()
|
|
|
}
|
|
|
}
|
|
|
+ } else if self.groupedFindTableView.isEqual(to: notification.object) {
|
|
|
+ // [self updateFindResultHighlightsForDirection:NSDirectSelection];
|
|
|
+ //
|
|
|
+ // if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey])
|
|
|
+ // [self hideLeftSideWindow];
|
|
|
} else if self.thumbnailTableView.isEqual(to: notification.object) {
|
|
|
// if (mwcFlags.updatingThumbnailSelection == 0) {
|
|
|
let row = self.thumbnailTableView.selectedRow
|
|
@@ -1754,42 +1747,40 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
self._copysPages.append(page)
|
|
|
}
|
|
|
}
|
|
|
- // NSData *tiffData = [page TIFFDataForRect:[page boundsForBox:[pdfView displayBox]]];
|
|
|
- // NSPasteboard *pboard = [NSPasteboard generalPasteboard];
|
|
|
- // NSPasteboardItem *pboardItem = [[[NSPasteboardItem alloc] init] autorelease];
|
|
|
- // if ([[pdfView document] allowsPrinting])
|
|
|
- // [pboardItem setData:[page dataRepresentation] forType:NSPasteboardTypePDF];
|
|
|
- // [pboardItem setData:tiffData forType:NSPasteboardTypeTIFF];
|
|
|
- // [pboard clearContents];
|
|
|
- // [pboard writeObjects:[NSArray arrayWithObjects:pboardItem, nil]];
|
|
|
- }
|
|
|
- }
|
|
|
-// else if ([tv isEqual:leftSideController.findTableView]) {
|
|
|
-// NSMutableString *string = [NSMutableString string];
|
|
|
-// [rowIndexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
|
|
-// PDFSelection *match = [searchResults objectAtIndex:idx];
|
|
|
-// [string appendString:@"* "];
|
|
|
+ }
|
|
|
+ } else if aTableView.isEqual(to: self.findTableView) {
|
|
|
+ var string = ""
|
|
|
+ for idx in rowIndexes {
|
|
|
+ let match = self.searchResults[idx].selection
|
|
|
+ string.append("* ")
|
|
|
// [string appendFormat:NSLocalizedString(@"Page %@", @""), [match firstPageLabel]];
|
|
|
-// [string appendFormat:@": %@\n", [[match contextString] string]];
|
|
|
-// }];
|
|
|
-// NSPasteboard *pboard = [NSPasteboard generalPasteboard];
|
|
|
-// [pboard clearContents];
|
|
|
-// [pboard writeObjects:[NSArray arrayWithObjects:string, nil]];
|
|
|
-// } else if ([tv isEqual:leftSideController.groupedFindTableView]) {
|
|
|
-// NSMutableString *string = [NSMutableString string];
|
|
|
-// [rowIndexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
|
|
-// SKGroupedSearchResult *result = [groupedSearchResults objectAtIndex:idx];
|
|
|
-// NSArray *matches = [result matches];
|
|
|
-// [string appendString:@"* "];
|
|
|
-// [string appendFormat:NSLocalizedString(@"Page %@", @""), [[result page] displayLabel]];
|
|
|
-// [string appendString:@": "];
|
|
|
-// [string appendFormat:NSLocalizedString(@"%ld Results", @""), (long)[matches count]];
|
|
|
+ string = string.appendingFormat(KMLocalizedString("Page %@", ""), "\(match.safeFirstPage()?.pageIndex() ?? 0)")
|
|
|
+// [string appendFormat:@"", [[match contextString] string]];
|
|
|
+ string = string.appendingFormat(": %@\n", match.string() ?? "")
|
|
|
+ }
|
|
|
+ let pboard = NSPasteboard.general
|
|
|
+ pboard.clearContents()
|
|
|
+ pboard.writeObjects([string as NSPasteboardWriting])
|
|
|
+ } else if aTableView.isEqual(to: self.groupedFindTableView) {
|
|
|
+ var string = ""
|
|
|
+ for idx in rowIndexes {
|
|
|
+ let result = self.groupSearchResults[idx]
|
|
|
+ let matches = result.datas
|
|
|
+ string.append("* ")
|
|
|
+ string = string.appendingFormat(KMLocalizedString("Page %@", ""), "\(result.selectionPageIndex)")
|
|
|
+ string.append(": ")
|
|
|
+ string = string.appendingFormat(KMLocalizedString("%ld Results", ""), matches.count)
|
|
|
// [string appendFormat:@":\n\t%@\n", [[matches valueForKeyPath:@"contextString.string"] componentsJoinedByString:@"\n\t"]];
|
|
|
-// }];
|
|
|
-// NSPasteboard *pboard = [NSPasteboard generalPasteboard];
|
|
|
-// [pboard clearContents];
|
|
|
-// [pboard writeObjects:[NSArray arrayWithObjects:string, nil]];
|
|
|
-// }
|
|
|
+ var tmpString = ""
|
|
|
+ for model in matches {
|
|
|
+ tmpString.append("\(model.selection.string() ?? "")")
|
|
|
+ }
|
|
|
+ string = string.appendingFormat(":\n\t%@\n", tmpString)
|
|
|
+ }
|
|
|
+ let pboard = NSPasteboard.general
|
|
|
+ pboard.clearContents()
|
|
|
+ pboard.writeObjects([string as NSPasteboardWriting])
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, namesOfPromisedFilesDroppedAtDestination dropDestination: URL, forDraggedRowsWith indexSet: IndexSet) -> [String] {
|
|
@@ -1863,15 +1854,13 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func tableView(_ tableView: NSTableView, sortDescriptorsDidChange oldDescriptors: [NSSortDescriptor]) {
|
|
|
+ if tableView.isEqual(to: self.groupedFindTableView) {
|
|
|
+// [leftSideController.groupedFindArrayController setSortDescriptors:[tv sortDescriptors]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
- #pragma mark dragging
|
|
|
-
|
|
|
- - (void)tableView:(NSTableView *)tv sortDescriptorsDidChange:(NSArray *)oldDescriptors {
|
|
|
- if ([tv isEqual:leftSideController.groupedFindTableView]) {
|
|
|
- [leftSideController.groupedFindArrayController setSortDescriptors:[tv sortDescriptors]];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
#pragma mark NSTableView delegate protocol
|
|
|
|
|
|
- (void)tableView:(NSTableView *)tv shareRowsWithIndexes:(NSIndexSet *)rowIndexes {
|
|
@@ -2800,13 +2789,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];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2827,9 +2818,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
if outlineView.isEqual(to: self.noteOutlineView) {
|
|
|
let pboard = info.draggingPasteboard
|
|
|
if pboard.canReadObject(forClasses: [NSColor.self], options: [:]) && index == NSOutlineViewDropOnItemIndex {
|
|
|
- // if ([pboard canReadObjectForClasses:[NSArray arrayWithObject:[NSColor class]] options:[NSDictionary dictionary]] &&
|
|
|
- // anIndex == NSOutlineViewDropOnItemIndex && [(PDFAnnotation *)item type] != nil)
|
|
|
- // dragOp = NSDragOperationEvery;
|
|
|
if let note = item as? CPDFAnnotation, note.type != nil {
|
|
|
dragOp = .every
|
|
|
}
|
|
@@ -2941,61 +2929,85 @@ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func outlineView(_ outlineView: NSOutlineView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, byItem item: Any?) {
|
|
|
+ if outlineView.isEqual(to: self.noteOutlineView) {
|
|
|
+// PDFAnnotation *note = item;
|
|
|
+ var note = item as? CPDFAnnotation
|
|
|
+ if note == nil && note is KMBOTAAnnotationItem {
|
|
|
+ note = (note as? KMBOTAAnnotationItem)?.annotation
|
|
|
+ }
|
|
|
+ if let data = note?.type, data.isEmpty == false {
|
|
|
+ if tableColumn?.identifier.rawValue == self.noteColumnId.rawValue {
|
|
|
+ let string1 = (object as? String) ?? ""
|
|
|
+ let string2 = note?.string() ?? ""
|
|
|
+ if string1 != string2 {
|
|
|
+ note?.setString(string1)
|
|
|
+ }
|
|
|
+ } else if tableColumn?.identifier.rawValue == self.authorColumnId.rawValue {
|
|
|
+ let string1 = (object as? String) ?? ""
|
|
|
+ let string2 = note?.userName() ?? ""
|
|
|
+ if string1 != string2 {
|
|
|
+ note?.setUserName(string1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func outlineView(_ outlineView: NSOutlineView, dataCellFor tableColumn: NSTableColumn?, item: Any) -> NSCell? {
|
|
|
+ if self.noteOutlineView.isEqual(to: outlineView) {
|
|
|
+ if tableColumn == nil {
|
|
|
+ if let anno = item as? CPDFAnnotation, anno.type == nil {
|
|
|
+ return outlineView.tableColumn(withIdentifier: self.noteColumnId)?.dataCell(forRow: outlineView.row(forItem: item)) as? NSCell
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tableColumn?.dataCell(forRow: outlineView.row(forItem: item)) as? NSCell
|
|
|
+ }
|
|
|
+
|
|
|
+ func outlineView(_ outlineView: NSOutlineView, shouldEdit tableColumn: NSTableColumn?, item: Any) -> Bool {
|
|
|
+ if outlineView.isEqual(to: self.noteOutlineView) {
|
|
|
+ if (tableColumn == nil) {
|
|
|
+ if self.listView.hideNotes == false {
|
|
|
+ if let anno = item as? CPDFAnnotation, anno.isNote() {
|
|
|
+ // if ([pdfView hideNotes] == NO && [[(SKNoteText *)item note] isNote]) {
|
|
|
+ // PDFAnnotation *annotation = [(SKNoteText *)item note];
|
|
|
+ self.listView.scrollAnnotationToVisible(anno)
|
|
|
+ self.listView.updateActiveAnnotations([anno])
|
|
|
+ // [self showNote:annotation];
|
|
|
+ // SKNoteWindowController *noteController = (SKNoteWindowController *)[self windowControllerForNote:annotation];
|
|
|
+ // [[noteController window] makeFirstResponder:[noteController textView]];
|
|
|
+ // [[noteController textView] selectAll:nil];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ } else if tableColumn?.identifier.rawValue == self.noteColumnId.rawValue || tableColumn?.identifier.rawValue == self.authorColumnId.rawValue {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ func outlineView(_ outlineView: NSOutlineView, toolTipFor cell: NSCell, rect: NSRectPointer, tableColumn: NSTableColumn?, item: Any, mouseLocation: NSPoint) -> String {
|
|
|
+ if outlineView.isEqual(to: self.noteOutlineView) {
|
|
|
+ if tableColumn == nil || tableColumn?.identifier.rawValue == self.noteColumnId.rawValue {
|
|
|
+ return (item as? CPDFAnnotation)?.string() ?? ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
- #pragma mark NSOutlineView datasource protocol
|
|
|
-
|
|
|
- - (void)outlineView:(NSOutlineView *)ov setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item{
|
|
|
- if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
- PDFAnnotation *note = item;
|
|
|
- if ([note type]) {
|
|
|
- if ([[tableColumn identifier] isEqualToString:NOTE_COLUMNID]) {
|
|
|
- if ([(object ?: @"") isEqualToString:([note string] ?: @"")] == NO)
|
|
|
- [note setString:object];
|
|
|
- } else if ([[tableColumn identifier] isEqualToString:AUTHOR_COLUMNID]) {
|
|
|
- if ([(object ?: @"") isEqualToString:([note userName] ?: @"")] == NO)
|
|
|
- [note setUserName:object];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
#pragma mark NSOutlineView delegate protocol
|
|
|
-
|
|
|
- - (NSCell *)outlineView:(NSOutlineView *)ov dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
|
|
|
- if ([ov isEqual:rightSideController.noteOutlineView] && tableColumn == nil && [(PDFAnnotation *)item type] == nil) {
|
|
|
- return [[ov tableColumnWithIdentifier:NOTE_COLUMNID] dataCellForRow:[ov rowForItem:item]];
|
|
|
- }
|
|
|
- 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) {
|
|
|
- if ([pdfView hideNotes] == NO && [[(SKNoteText *)item note] isNote]) {
|
|
|
- PDFAnnotation *annotation = [(SKNoteText *)item note];
|
|
|
- [pdfView scrollAnnotationToVisible:annotation];
|
|
|
- [pdfView setActiveAnnotation:annotation];
|
|
|
- [self showNote:annotation];
|
|
|
- SKNoteWindowController *noteController = (SKNoteWindowController *)[self windowControllerForNote:annotation];
|
|
|
- [[noteController window] makeFirstResponder:[noteController textView]];
|
|
|
- [[noteController textView] selectAll:nil];
|
|
|
- }
|
|
|
- return NO;
|
|
|
- } else if ([[tableColumn identifier] isEqualToString:NOTE_COLUMNID] || [[tableColumn identifier] isEqualToString:AUTHOR_COLUMNID]) {
|
|
|
- return YES;
|
|
|
- }
|
|
|
- }
|
|
|
- return NO;
|
|
|
- }
|
|
|
-
|
|
|
- (void)outlineView:(NSOutlineView *)ov didClickTableColumn:(NSTableColumn *)tableColumn {
|
|
|
if ([ov isEqual:rightSideController.noteOutlineView]) {
|
|
|
NSTableColumn *oldTableColumn = [ov highlightedTableColumn];
|
|
@@ -3034,16 +3046,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- - (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation {
|
|
|
- if ([ov isEqual:rightSideController.noteOutlineView] &&
|
|
|
- (tableColumn == nil || [[tableColumn identifier] isEqualToString:NOTE_COLUMNID])) {
|
|
|
- return [item string];
|
|
|
- }
|
|
|
- return @"";
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- (void)outlineViewColumnDidResize:(NSNotification *)notification{
|
|
|
if (mwcFlags.autoResizeNoteRows &&
|
|
|
[[notification object] isEqual:rightSideController.noteOutlineView] &&
|
|
@@ -3054,53 +3056,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];
|
|
@@ -3155,56 +3110,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
|
|
@@ -3287,9 +3192,57 @@ extension KMLeftSideViewController: KMCustomOutlineViewDelegate, KMCustomOutline
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func outlineView(_ anOutlineView: NSOutlineView, typeSelectHelperSelectionStrings aTypeSelectHelper: SKTypeSelectHelper) -> NSArray {
|
|
|
+ if self.noteOutlineView.isEqual(to: anOutlineView) {
|
|
|
+ let count = self.noteOutlineView.numberOfRows
|
|
|
+ var texts = NSMutableArray(capacity: count)
|
|
|
+ for i in 0 ..< count {
|
|
|
+ let item = self.noteOutlineView.item(atRow: i)
|
|
|
+ let string = (item as? CPDFAnnotation)?.string() ?? ""
|
|
|
+ texts.add(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 {
|