Просмотр исходного кода

【BOTA】搜索页面逻辑完善

lizhe 2 лет назад
Родитель
Сommit
7c843e76c7

+ 17 - 1
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Annotation/KMAnnotationViewController.swift

@@ -75,7 +75,23 @@ class KMAnnotationViewController: KMSideViewController {
     }
     
     @objc private func toc_expandAllComments(sender:NSMenuItem) {
-        
+//        if item.tag == 0 {
+//            self.outlineView.reloadData()
+//            self.outlineView.expandItem(nil, expandChildren: true)
+//        } else if item.tag == 1 {
+//            self.outlineView.reloadData()
+//            self.outlineView.collapseItem(nil, collapseChildren: true)
+//        } else if item.tag == 2 {
+//            let alter = NSAlert()
+//            alter.alertStyle = NSAlert.Style.informational
+//            alter.messageText = NSLocalizedString("This will permanently remove all outlines. Are you sure to continue?", comment: "")
+//            alter.addButton(withTitle: NSLocalizedString("Yes", comment:""))
+//            alter.addButton(withTitle: NSLocalizedString("No", comment:""))
+//            let modlres = alter.runModal()
+//            if modlres == NSApplication.ModalResponse.alertFirstButtonReturn {
+//                self.removeAllOutline()
+//            }
+//        }
     }
     
    @objc public func reloadData() {

+ 1 - 1
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Outline/KMOutlineViewController.swift

@@ -406,7 +406,7 @@ class KMOutlineViewController: NSViewController,NSMenuItemValidation {
         var arr = [[String : CPDFPage]]()
         for i in 0..<numRows {
             let tPDFOutline = self.outlineView.item(atRow: i) as! CPDFOutline
-            let tPage = tPDFOutline.destination.pageIndex
+            let tPage = tPDFOutline.destination?.pageIndex ?? 0
             if tPage < 0 {
                 continue
             }

+ 6 - 1
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Search/KMSearchViewController.swift

@@ -153,6 +153,7 @@ class KMSearchViewController: NSViewController, NSTextFieldDelegate, NSSearchFie
             self.delegate?.searchAction?(searchString: self.searchTextField.stringValue,isCase:self.isCase)
             
             self.doneButton.isHidden = false
+            self.outlineView.expandItem(nil, expandChildren: true)
         }
         
         //移除响应
@@ -164,6 +165,7 @@ class KMSearchViewController: NSViewController, NSTextFieldDelegate, NSSearchFie
         self.searchResults = [];
         self.reloadData()
         self.delegate?.searchDoneAction?(viewController: self)
+        self.doneButton.isHidden = true
     }
     
     @IBAction func searchHistoryAction(sender: NSMenuItem) {
@@ -182,7 +184,10 @@ class KMSearchViewController: NSViewController, NSTextFieldDelegate, NSSearchFie
         self.updateSearchMenu()
     }
     
-   private func updateSearchMenu() {
+    @IBAction func escButtonAction(_ sender: Any) {
+        self.outlineView.deselectAll(nil)
+    }
+    private func updateSearchMenu() {
        searchFieldMenu.removeAllItems()
        let item = searchFieldMenu.addItem(withTitle: NSLocalizedString("Ignore Case", comment: ""), action: #selector(caseSetAction), target: self)
        if self.isCase {

+ 16 - 1
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Search/KMSearchViewController.xib

@@ -78,12 +78,27 @@
                                         <action selector="doneSearchAction:" target="-2" id="4ne-Zc-nCm"/>
                                     </connections>
                                 </button>
+                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sDW-fs-0uG">
+                                    <rect key="frame" x="111" y="12" width="0.0" height="0.0"/>
+                                    <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="2iK-aQ-Jvr">
+                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                        <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+                                    </buttonCell>
+                                    <connections>
+                                        <action selector="escButtonAction:" target="-2" id="Mbh-bS-L3c"/>
+                                    </connections>
+                                </button>
                             </subviews>
                             <constraints>
                                 <constraint firstAttribute="trailing" secondItem="FEc-5K-ivt" secondAttribute="trailing" constant="16" id="7Qd-5j-06w"/>
                                 <constraint firstItem="xF3-eP-wmn" firstAttribute="centerY" secondItem="bdI-Qa-G1g" secondAttribute="centerY" id="GGZ-OQ-YFS"/>
                                 <constraint firstAttribute="height" constant="24" id="RLb-KV-f9q"/>
                                 <constraint firstItem="xF3-eP-wmn" firstAttribute="leading" secondItem="bdI-Qa-G1g" secondAttribute="leading" constant="16" id="WiB-qF-0NW"/>
+                                <constraint firstItem="sDW-fs-0uG" firstAttribute="centerY" secondItem="bdI-Qa-G1g" secondAttribute="centerY" id="ccU-PW-fN5"/>
+                                <constraint firstItem="sDW-fs-0uG" firstAttribute="centerX" secondItem="bdI-Qa-G1g" secondAttribute="centerX" id="nff-4q-Fdb"/>
                                 <constraint firstItem="FEc-5K-ivt" firstAttribute="centerY" secondItem="bdI-Qa-G1g" secondAttribute="centerY" id="vTg-Wv-iyv"/>
                             </constraints>
                         </customView>
@@ -330,7 +345,7 @@
                 <constraint firstAttribute="trailing" secondItem="EEm-dH-8Qq" secondAttribute="trailing" id="Uat-RT-z61"/>
                 <constraint firstItem="6ti-WI-xmu" firstAttribute="top" secondItem="4rz-2J-CjZ" secondAttribute="bottom" id="XQT-cI-Pzf"/>
             </constraints>
-            <point key="canvasLocation" x="134" y="87.5"/>
+            <point key="canvasLocation" x="179" y="161"/>
         </customView>
     </objects>
     <resources>