|
@@ -361,9 +361,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// //支持拖拽的文字类型
|
|
|
|
|
|
// [tocOutlineView setTypeSelectHelper:[SKTypeSelectHelper typeSelectHelperWithMatchOption:SKSubstringMatch]];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// NSSortDescriptor *countDescriptor = [[[NSSortDescriptor alloc] initWithKey:SKGroupedSearchResultCountKey ascending:NO] autorelease];
|
|
|
// [groupedFindArrayController setSortDescriptors:[NSArray arrayWithObjects:countDescriptor, nil]];
|
|
|
|
|
@@ -1237,10 +1234,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()
|
|
|
}
|
|
@@ -1363,13 +1360,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]
|
|
@@ -1379,6 +1374,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
|
|
@@ -1742,42 +1742,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] {
|
|
@@ -1851,15 +1849,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 {
|