Browse Source

【fix】【BOTA】注释列表,按页码分类并且进行页码折叠,More 菜单的展开/折叠 功能无反应

tangchao 5 months ago
parent
commit
a46e2641c3

+ 38 - 20
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Note.swift

@@ -293,13 +293,29 @@ extension KMLeftSideViewController {
                 self?.moreButtonLayer?.isHidden = true
             }
         }
+        
         let expandAllItem = menu.addItem(title: KMLocalizedString("Expand All", nil), action: #selector(note_expandAllComments), target: self)
         expandAllItem?.representedObject = self.noteOutlineView
         let foldAllItem = menu.addItem(title: KMLocalizedString("Collapse All", nil), action: #selector(note_foldAllComments), target: self)
         foldAllItem?.representedObject = self.noteOutlineView
         let type = self.annoListModel?.foldType ?? .none
-        expandAllItem?.state = type == .unfold ? .on : .off
-        foldAllItem?.state = type == .fold ? .on : .off
+//        expandAllItem?.state = type == .unfold ? .on : .off
+        expandAllItem?.state = .on
+        for secM in self.annoListModel?.datas ?? [] {
+            if secM.isExpand == false {
+                expandAllItem?.state = .off
+                break
+            }
+        }
+//        foldAllItem?.state = type == .fold ? .on : .off
+        foldAllItem?.state = .on
+        for secM in self.annoListModel?.datas ?? [] {
+            if secM.isExpand {
+                foldAllItem?.state = .off
+                break
+            }
+        }
+        
 
         let showItem = menu.addItem(title: KMLocalizedString("Show Note", nil), action: nil, target: self)
         let subMenu = NSMenu()
@@ -378,17 +394,18 @@ extension KMLeftSideViewController {
         guard let model = self.annoListModel else {
             return
         }
-        if (model.foldType == .unfold) { // 已全部展开
-            return
-        }
-        model.foldType = .unfold
+//        if (model.foldType == .unfold) { // 已全部展开
+//            return
+//        }
+//        model.foldType = .unfold
         
         for secM in self.annoListModel?.datas ?? [] {
-            for model in secM.items {
-                if let data = model as? KMBotaAnnotationFooterModel {
-                    data.isExpand = true
-                }
-            }
+//            for model in secM.items {
+//                if let data = model as? KMBotaAnnotationFooterModel {
+//                    data.isExpand = true
+//                }
+//            }
+            secM.isExpand = true
         }
         
         self.noteOutlineView.reloadData()
@@ -398,17 +415,18 @@ extension KMLeftSideViewController {
         guard let model = self.annoListModel else {
             return
         }
-        if (model.foldType == .fold) {
-            return
-        }
-        model.foldType = .fold
+//        if (model.foldType == .fold) {
+//            return
+//        }
+//        model.foldType = .fold
         
         for secM in self.annoListModel?.datas ?? [] {
-            for model in secM.items {
-                if let data = model as? KMBotaAnnotationFooterModel {
-                    data.isExpand = false
-                }
-            }
+//            for model in secM.items {
+//                if let data = model as? KMBotaAnnotationFooterModel {
+//                    data.isExpand = false
+//                }
+//            }
+            secM.isExpand = false
         }
         
         self.noteOutlineView.reloadData()