Browse Source

【综合】BOTA大纲搜索忽略大小写问题修复

tangchao 1 year ago
parent
commit
7738fdf9e1

+ 12 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Outline.swift

@@ -467,4 +467,16 @@ extension KMLeftSideViewController {
             self.promoteOutlineWithGrandParent(grandParentOutLine, promoteOutline: currentOutline, rowIndex:Int(currentOutline.index))
         }
     }
+    
+    @objc func toggleOutlineCaseInsensitiveSearch(_ sender: NSMenuItem) {
+        if (sender.state == .on) {
+            self.outlineIgnoreCaseFlag = false
+        } else {
+            self.outlineIgnoreCaseFlag = true
+        }
+        if (self.outlineSearchField.stringValue.isEmpty == false) {
+            self.tocOutlineView.reloadData()
+            self.tocOutlineView.expandItem(nil, expandChildren: true)
+        }
+    }
 }

+ 7 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -2167,9 +2167,13 @@ extension KMLeftSideViewController {
     }
     
     private func _hasContainString(_ searchString: String, rootOutline outline: CPDFOutline) -> Bool {
-        let label_low = outline.label.lowercased()
-        let searchString_low = searchString.lowercased()
-        if label_low.contains(searchString_low) {
+        var label = outline.label ?? ""
+        var searchLabel = searchString
+        if self.outlineIgnoreCaseFlag {
+            label = label.lowercased()
+            searchLabel = searchLabel.lowercased()
+        }
+        if label.contains(searchLabel) {
 //        if ([outline.label rangeOfString:searchString options:self.outlineIgnoreCaseFlag?NSCaseInsensitiveSearch:0].location != NSNotFound){
             return true
         } else {
@@ -4715,10 +4719,6 @@ extension KMLeftSideViewController {
         
     }
     
-    @objc func toggleOutlineCaseInsensitiveSearch(_ sender: AnyObject?) {
-        KMPrint("KMLeftSideViewController-toggleOutlineCaseInsensitiveSearch...")
-    }
-    
     private func _tableView(_ tv: NSTableView, cutRowsWithIndexes rowIndexes: IndexSet) {
         if tv.isEqual(to: self.thumbnailTableView) {
             self._copysPages.removeAll()