Pārlūkot izejas kodu

【fix】 【BOTA】注释列表搜索后就没有注释回复的入口了

tangchao 5 mēneši atpakaļ
vecāks
revīzija
f7f1388043

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

@@ -451,7 +451,13 @@ extension KMLeftSideViewController {
         // 更新数据
         var models: [KMBotaAnnotationModel] = []
         if self.noteSearchMode {
-            models = self.noteSearchArray
+//            models = self.noteSearchArray
+            for model in self.noteSearchArray {
+                guard let data = model as? KMBotaAnnotationModel else {
+                    continue
+                }
+                models.append(data)
+            }
         } else {
             let selModels = self.annoListModel?.datas ?? []
             for selModel in selModels {
@@ -795,8 +801,11 @@ extension KMLeftSideViewController {
     func fetchAnnoModel(for anno: CPDFAnnotation) -> KMBotaAnnotationModel? {
         if self.noteSearchMode { // 搜索模式
             for model in self.noteSearchArray {
-                if anno.isEqual(to: model.anno) {
-                    return model
+                guard let data = model as? KMBotaAnnotationModel else {
+                    continue
+                }
+                if anno.isEqual(to: data.anno) {
+                    return data
                 }
             }
         } else { // 常规模式(非搜索)
@@ -1254,10 +1263,10 @@ extension KMLeftSideViewController {
                     guard let _ = item.anno else {
                         continue
                     }
-                    guard let data = item as? KMBotaAnnotationModel else {
-                        continue
-                    }
-                    self.noteSearchArray.append(data)
+//                    guard let data = item as? KMBotaAnnotationModel else {
+//                        continue
+//                    }
+                    self.noteSearchArray.append(item)
                 }
             }
         } else {
@@ -1280,11 +1289,11 @@ extension KMLeftSideViewController {
                     if caseInsensite {
                         noteString = noteString.lowercased()
                     }
-                    guard let data = item as? KMBotaAnnotationModel else {
-                        continue
-                    }
+//                    guard let data = item as? KMBotaAnnotationModel else {
+//                        continue
+//                    }
                     if noteString.contains(stringValue) {
-                        self.noteSearchArray.append(data)
+                        self.noteSearchArray.append(item)
                     }
                 }
             }

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

@@ -161,7 +161,7 @@ class KMLeftSideViewController: KMSideViewController {
     // 注释搜索模式标记
     var noteSearchMode = false
     // 注释搜索数组
-    var noteSearchArray: [KMBotaAnnotationModel] = []
+    var noteSearchArray: [KMBotaAnnotationBaseModel] = []
     // 注释搜索 忽略大小写标识
     var caseInsensitiveNoteSearch = false
     // 注释列表数据源
@@ -1896,7 +1896,18 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
             }
         } else if outlineView.isEqual(to: self.noteOutlineView) {
             if self.noteSearchMode {
-                return self.noteSearchArray.count
+//                return self.noteSearchArray.count
+                var cnt = 0
+                for model in self.noteSearchArray {
+                    cnt += 1
+                    guard let data = model as? KMBotaAnnotationModel else {
+                        continue
+                    }
+                    for replyI in data.replyAnnos {
+                        cnt += 1
+                    }
+                }
+                return cnt
             }
 //            let count = self.annoListModel?.datas.count ?? 0
             var cnt = 0
@@ -1976,7 +1987,24 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
             }
         } else if outlineView.isEqual(to: self.noteOutlineView) {
             if self.noteSearchMode {
-                return self.noteSearchArray[index]
+//                return self.noteSearchArray[index]
+                var idx = 0
+                for model in self.noteSearchArray {
+                    idx += 1
+                    if index + 1 == idx {
+                        return model
+                    }
+                    guard let data = model as? KMBotaAnnotationModel else {
+                        continue
+                    }
+                    for replyI in data.replyAnnos {
+                        idx += 1
+                        if index + 1 == idx {
+                            return replyI
+                        }
+                    }
+                }
+                return 0
             }
             
             var idx = 0