Explorar o código

【综合】整理代码

tangchao hai 1 ano
pai
achega
275bfbe31b

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

@@ -61,4 +61,17 @@ extension KMLeftSideViewController {
         targrtTextField?.isEditable = true
         targrtTextField?.becomeFirstResponder()
     }
+    
+    func loadUnfoldDate(_ foldType: KMFoldType) {
+        self.allFoldNotes.removeAll()
+        
+        var mutableArray: [CPDFAnnotation] = []
+        for note in self.notes {
+            if note is CPDFMarkupAnnotation {
+                mutableArray.append(note)
+            }
+        }
+        self.canFoldNotes = mutableArray
+        self.allFoldNotes = []
+    }
 }

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

@@ -228,10 +228,11 @@ class KMLeftSideViewController: KMSideViewController {
     private let kKMPDFViewOutlineDragDataType  = "kKMPDFViewOutlineDragDataType"
     private let KPDFThumbnailDoucumentURLForDraggedTypes  = "KPDFThumbnailDoucumentURLForDraggedTypes"
     
-    private var allFoldNotes: [CPDFAnnotation] = []
-    
     var renamePDFOutline: CPDFOutline?
     var renamePDFOutlineTextField: NSTextField?
+    var allFoldNotes: [CPDFAnnotation] = []
+    var notes: [CPDFAnnotation] = []
+    var canFoldNotes: [CPDFAnnotation] = []
     
     override func loadView() {
         super.loadView()
@@ -1132,15 +1133,6 @@ class KMLeftSideViewController: KMSideViewController {
             NSMenu.popUpContextMenu(menu, with: NSApp.currentEvent!, for: sender as! NSButton)
         } else if (tag == 302) {
             let menu = NSMenu()
-    //        NSMenuItem *addEntryItem = [menu addItemWithTitle:NSLocalizedString(@"Add Item", nil) action:@selector(outlineContextMenuItemClicked_AddEntry:) target:self];
-    //        [addEntryItem setRepresentedObject:self.leftSideController.tocOutlineView];
-    //        NSMenuItem *addChildItem = [menu addItemWithTitle:NSLocalizedString(@"Add Sub-Item", nil) action:@selector(outlineContextMenuItemClicked_AddChildEntry:) target:self];
-    //        [addChildItem setRepresentedObject:self.leftSideController.tocOutlineView];
-    //        [menu addItem:[NSMenuItem separatorItem]];
-    //
-    //        NSMenuItem *setDestinationItem = [menu addItemWithTitle:NSLocalizedString(@"Change Destination", nil) action:@selector(outlineContextMenuItemClicked_SetDestination:) target:self];
-    //        [setDestinationItem setRepresentedObject:self.leftSideController.tocOutlineView];
-    //        [menu addItem:[NSMenuItem separatorItem]];
             let expandAllCommentsItem = menu.addItem(title: KMLocalizedString("Expand All", nil), action: #selector(toc_expandAllComments), target: self)
             expandAllCommentsItem?.representedObject = self.tocOutlineView
 
@@ -1281,7 +1273,7 @@ class KMLeftSideViewController: KMSideViewController {
             return
         }
         self.foldType = .unfold
-//        [self loadUnfoldDate:KMFoldAllAnnotationType_None];
+        self.loadUnfoldDate(.none)
         self.noteOutlineView.reloadData()
     }
     
@@ -1290,7 +1282,7 @@ class KMLeftSideViewController: KMSideViewController {
             return
         }
         self.foldType = .fold
-//        [self loadUnfoldDate:KMFoldAllAnnotationType_None];
+        self.loadUnfoldDate(.none)
         self.noteOutlineView.reloadData()
     }
 
@@ -3723,6 +3715,18 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
         }
     }
     
+    func outlineViewItemDidExpand(_ notification: Notification) {
+        if self.tocOutlineView.isEqual(to: notification.object) {
+            self.updateOutlineSelection()
+        }
+    }
+    
+    func outlineViewItemDidCollapse(_ notification: Notification) {
+        if self.tocOutlineView.isEqual(to: notification.object) {
+            self.updateOutlineSelection()
+        }
+    }
+    
     /*
      #pragma mark NSOutlineView datasource protocol
 
@@ -3924,17 +3928,7 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
          return @"";
      }
 
-     - (void)outlineViewItemDidExpand:(NSNotification *)notification{
-         if ([[notification object] isEqual:leftSideController.tocOutlineView]) {
-             [self updateOutlineSelection];
-         }
-     }
 
-     - (void)outlineViewItemDidCollapse:(NSNotification *)notification{
-         if ([[notification object] isEqual:leftSideController.tocOutlineView]) {
-             [self updateOutlineSelection];
-         }
-     }
 
      - (void)outlineViewColumnDidResize:(NSNotification *)notification{
          if (mwcFlags.autoResizeNoteRows &&