Browse Source

【左边栏】搜索列表显示内容调整

tangchao 1 year ago
parent
commit
ea2bb39ff3

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

@@ -517,6 +517,7 @@ class KMLeftSideViewController: KMSideViewController {
         self.noteOutlineView.dataSource = self
         self.noteOutlineView.botaDelegate = self
         self.noteOutlineView.botaDataSource = self
+        self.noteOutlineView.noteDelegate = self
         self.noteOutlineView.menu = NSMenu()
         self.noteOutlineView.menu?.delegate = self
 //        [noteOutlineView setTypeSelectHelper:[SKTypeSelectHelper typeSelectHelperWithMatchOption:SKSubstringMatch]];
@@ -2026,77 +2027,6 @@ extension KMLeftSideViewController: KMThumbnailTableViewDelegate {
     }
 }
 
-//MARK: NSTableViewDelegate,NSTableViewDataSource
-
-//extension KMLeftSideViewController: NSTableViewDelegate,NSTableViewDataSource {
-//    func numberOfRows(in tableView: NSTableView) -> Int {
-//        return self.dataSource.count
-//    }
-//
-//    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
-//        let cell : KMLiftSideCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMLiftSideCellView"), owner: self) as! KMLiftSideCellView
-//        if row <= selectImage.count-1 {
-//            if self.dataSource[row] == self.type {
-//                cell.isSelect = true
-//                cell.mothedImage.image = NSImage(named: selectImage[row])
-//                cell.backgroundColor(NSColor.km_init(hex: "#DFE1E5"))
-//            } else {
-//                cell.isSelect = false
-//                cell.mothedImage.image = NSImage(named: norImage[row])
-//                cell.backgroundColor(NSColor.clear)
-//            }
-//        }
-//        cell.index = row
-//        cell.buttonClick = { [unowned self] index in
-//            if ((index < self.dataSource.count) && (index > -1)) {
-//
-//                let isSearch = self.type.methodType == .Search
-//
-//                var show = true
-//                if( self.type == self.dataSource[index]) {
-//                    self.type = KMLeftMethodMode()
-//                    show = false
-//                } else {
-//                    self.type = self.dataSource[index]
-//                    show = true
-//                }
-//
-//                self.trackEvent(type: self.type.methodType)
-//
-//                self.updateViewButtonState()
-//                self.delegate?.controlStateChange?(self,show:show)
-////                self.leftTableview.selectRowIndexes([index], byExtendingSelection: true)
-////                self.leftTableview.reloadData()
-//
-//                UserDefaults.standard.set(index, forKey: "KMBOTASelectedIndexKey")
-//                UserDefaults.standard.synchronize()
-//
-//                if (isSearch && show == false) {
-//                    self.view.window?.makeFirstResponder(self)
-//                } else if (isSearch && self.type.methodType != .Search) { // 切换
-//                    self.view.window?.makeFirstResponder(self)
-//                }
-//            }
-//        }
-//        return cell
-//    }
-//
-//    func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
-//        return 48
-//    }
-//
-//    func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
-//        let rowView = KMCustomTableRowView()
-//        rowView.selectionColor = NSColor(calibratedRed: 223.0/255.0, green: 225.0/255.0, blue: 229.0/255.0, alpha: 1.0)
-//        rowView.color = NSColor.km_init(hex: "#F7F8FA")
-//        return rowView
-//    }
-//
-//    func tableViewSelectionDidChange(_ notification: Notification) {
-//
-//    }
-//}
-
 //extension KMLeftSideViewController: KMPDFViewPanelSetViewControllerDelegate {
 //    func controller(_ controller: KMPDFViewPanelSetViewController, dispayDidChange dispay: KMPDFDisplayType) {
 //        self.delegate?.controller?(self, dispayDidChange: dispay)
@@ -2413,10 +2343,10 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
             let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMFindTableviewCell"), owner: self) as! KMFindTableviewCell
              let selection = searchResults[row]
             if let data = tableColumn?.identifier.rawValue, data == "results" {
-                cell.resultLabel.attributedStringValue = selection.selection.attributedString()
+                cell.resultLabel.attributedStringValue = selection.attributedString
                 cell.resultLabel.textColor = KMAppearance.Layout.h0Color()
             } else if let data = tableColumn?.identifier.rawValue, data == "page" {
-                cell.resultLabel.stringValue = selection.selection.pages().first?.label ?? ""
+                cell.resultLabel.stringValue = "\(Int(selection.selection.page?.pageIndex() ?? 0))"
                 cell.resultLabel.textColor = KMAppearance.Layout.h2Color()
             }
             return cell
@@ -4193,19 +4123,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
          }
      }
 
-     - (void)outlineView:(NSOutlineView *)ov didChangeHiddenOfTableColumn:(NSTableColumn *)tableColumn {
-         if (mwcFlags.autoResizeNoteRows &&
-             [ov isEqual:rightSideController.noteOutlineView] &&
-             [[tableColumn identifier] isEqualToString:NOTE_COLUMNID]) {
-             [rowHeights removeAllFloats];
-             [rightSideController.noteOutlineView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [rightSideController.noteOutlineView numberOfRows])]];
-         }
-     }
-
-     - (CGFloat)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item {
-  
-     }
-
      - (void)updateSelectRowHeight{
          CGFloat rowHeight = 0;
          PDFOutline *outline = [leftSideController.tocOutlineView itemAtRow:leftSideController.tocOutlineView.selectedRow];
@@ -4291,17 +4208,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
          [leftSideController.tocOutlineView reloadData];
      }
 
-     - (BOOL)outlineView:(NSOutlineView *)ov canResizeRowByItem:(id)item {
-         if ([ov isEqual:rightSideController.noteOutlineView]) {
-             return YES;
-         }
-         return NO;
-     }
-
-     - (void)outlineView:(NSOutlineView *)ov setHeight:(CGFloat)newHeight ofRowByItem:(id)item {
-         [rowHeights setFloat:newHeight forKey:item];
-     }
-
      - (NSArray *)noteItems:(NSArray *)items {
          NSMutableArray *noteItems = [NSMutableArray array];
          
@@ -4315,14 +4221,6 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
          return noteItems;
      }
 
-     - (void)outlineViewCommandKeyPressedDuringNavigation:(NSOutlineView *)ov {
-         PDFAnnotation *annotation = [[self selectedNotes] lastObject];
-         if (annotation) {
-             [pdfView scrollAnnotationToVisible:annotation];
-             [pdfView setActiveAnnotation:annotation];
-         }
-     }
-
      - (NSArray *)outlineView:(NSOutlineView *)ov typeSelectHelperSelectionStrings:(SKTypeSelectHelper *)typeSelectHelper {
          if ([ov isEqual:rightSideController.noteOutlineView]) {
              NSInteger i, count = [rightSideController.noteOutlineView numberOfRows];
@@ -4478,6 +4376,38 @@ extension KMLeftSideViewController: KMTocOutlineViewDelegate {
     }
 }
 
+extension KMLeftSideViewController: KMNoteOutlineViewDelegate {
+    func outlineView(_ anOutlineView: NSOutlineView, canResizeRowByItem item: AnyObject?) -> Bool? {
+        if anOutlineView.isEqual(to: self.noteOutlineView) {
+            return true
+        }
+        return false
+    }
+    
+    func outlineView(_ anOutlineView: NSOutlineView, setHeight newHeight: CGFloat, ofRowByItem item: AnyObject?) {
+//        [rowHeights setFloat:newHeight forKey:item];
+    }
+    
+    func outlineView(_ anOutlineView: NSOutlineView, didChangeHiddenOfTableColumn aTableColumn: NSTableColumn) {
+//            if (mwcFlags.autoResizeNoteRows &&
+//                [ov isEqual:rightSideController.noteOutlineView] &&
+//                [[tableColumn identifier] isEqualToString:NOTE_COLUMNID]) {
+//                [rowHeights removeAllFloats];
+//                [rightSideController.noteOutlineView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [rightSideController.noteOutlineView numberOfRows])]];
+//            }
+    }
+    
+    func outlineViewCommandKeyPressedDuringNavigation(_ anOutlineView: NSOutlineView) {
+//            PDFAnnotation *annotation = [[self selectedNotes] lastObject];
+//            if (annotation) {
+//                [pdfView scrollAnnotationToVisible:annotation];
+//                [pdfView setActiveAnnotation:annotation];
+//            }
+    }
+    
+    
+}
+
 extension KMLeftSideViewController: NSSearchFieldDelegate {
     
 }

+ 50 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/LeftSideView.xib

@@ -104,7 +104,7 @@
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
                                 <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="luU-CI-1RC">
-                                    <rect key="frame" x="0.0" y="274" width="156" height="176"/>
+                                    <rect key="frame" x="0.0" y="92" width="156" height="176"/>
                                     <view key="contentView" id="YZn-Xi-c3Y">
                                         <rect key="frame" x="0.0" y="0.0" width="156" height="176"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -164,7 +164,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <clipView key="contentView" drawsBackground="NO" id="fXK-1u-PsQ">
                 <rect key="frame" x="0.0" y="0.0" width="201" height="405"/>
-                <autoresizingMask key="autoresizingMask"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                     <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" selectionHighlightStyle="none" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="86" rowSizeStyle="automatic" viewBased="YES" id="101" customClass="KMThumbnailTableView" customModule="PDF_Master" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="201" height="405"/>
@@ -398,7 +398,10 @@
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="QCf-DA-Ep5">
-                                                <rect key="frame" x="-2" y="12" width="132" height="16"/>
+                                                <rect key="frame" x="-2" y="5" width="132" height="30"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="30" id="aeE-Zj-40Z"/>
+                                                </constraints>
                                                 <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="1" id="KwK-Ef-KWy">
                                                     <font key="font" usesAppearanceFont="YES"/>
                                                     <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -434,7 +437,7 @@
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aMp-rS-uGn">
-                                                <rect key="frame" x="0.0" y="12" width="56" height="16"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="56" height="30"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
                                                 <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="10000" id="fJk-rj-99q">
                                                     <font key="font" usesAppearanceFont="YES"/>
@@ -474,7 +477,7 @@
                 <rect key="frame" x="0.0" y="0.0" width="223" height="400"/>
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
-                    <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" columnReordering="NO" columnResizing="NO" autosaveColumns="NO" typeSelect="NO" id="128" customClass="KMBotaTableView" customModule="PDF_Master" customModuleProvider="target">
+                    <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" columnReordering="NO" columnResizing="NO" autosaveColumns="NO" typeSelect="NO" rowSizeStyle="automatic" viewBased="YES" id="128" customClass="KMBotaTableView" customModule="PDF_Master" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="223" height="400"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <size key="intercellSpacing" width="3" height="2"/>
@@ -489,6 +492,26 @@
                                 <levelIndicatorCell key="dataCell" alignment="left" maxValue="1" id="132" customClass="SKLevelIndicatorCell"/>
                                 <sortDescriptor key="sortDescriptorPrototype" selector="compare:" sortKey="count" ascending="NO"/>
                                 <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+                                <prototypeCellViews>
+                                    <tableCellView id="L9C-6s-m04">
+                                        <rect key="frame" x="11" y="1" width="122" height="17"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                        <subviews>
+                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GUZ-oY-a1n">
+                                                <rect key="frame" x="0.0" y="1" width="122" height="16"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+                                                <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="lho-ux-z3n">
+                                                    <font key="font" usesAppearanceFont="YES"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                </textFieldCell>
+                                            </textField>
+                                        </subviews>
+                                        <connections>
+                                            <outlet property="textField" destination="GUZ-oY-a1n" id="ix1-nC-3tC"/>
+                                        </connections>
+                                    </tableCellView>
+                                </prototypeCellViews>
                             </tableColumn>
                             <tableColumn identifier="page" editable="NO" width="50" minWidth="32" maxWidth="50" id="130">
                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
@@ -502,6 +525,26 @@
                                 </textFieldCell>
                                 <sortDescriptor key="sortDescriptorPrototype" selector="compare:" sortKey="pageIndex"/>
                                 <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+                                <prototypeCellViews>
+                                    <tableCellView id="w6G-bK-O2K">
+                                        <rect key="frame" x="136" y="1" width="54" height="17"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                        <subviews>
+                                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wak-VN-Wb6">
+                                                <rect key="frame" x="0.0" y="1" width="54" height="16"/>
+                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+                                                <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="f7e-Zk-8vT">
+                                                    <font key="font" usesAppearanceFont="YES"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                </textFieldCell>
+                                            </textField>
+                                        </subviews>
+                                        <connections>
+                                            <outlet property="textField" destination="Wak-VN-Wb6" id="FLL-Ht-c1D"/>
+                                        </connections>
+                                    </tableCellView>
+                                </prototypeCellViews>
                             </tableColumn>
                         </tableColumns>
                         <connections>
@@ -988,7 +1031,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="adc-31-u6a">
                 <rect key="frame" x="0.0" y="0.0" width="223" height="409"/>
-                <autoresizingMask key="autoresizingMask"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                     <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" selectionHighlightStyle="none" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="103" rowSizeStyle="automatic" viewBased="YES" id="EZk-9w-Qcv" customClass="SKTableView">
                         <rect key="frame" x="0.0" y="0.0" width="253" height="409"/>
@@ -1090,7 +1133,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="z3N-jy-sfp">
                 <rect key="frame" x="0.0" y="0.0" width="231" height="429"/>
-                <autoresizingMask key="autoresizingMask"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                     <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" tableStyle="fullWidth" typeSelect="NO" autosaveName="KMNoteOutlineView" rowHeight="92" usesAutomaticRowHeights="YES" viewBased="YES" indentationPerLevel="16" outlineTableColumn="yso-Z1-ZNZ" id="ZeT-gb-jMM" customClass="KMNoteOutlineView" customModule="PDF_Master" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="231" height="429"/>