|
@@ -571,8 +571,8 @@ extension KMLeftSideViewController {
|
|
|
if self.noteSearchMode { // 搜索模式
|
|
|
return self.noteSearchArray.safe_element(for: index) as? CPDFAnnotation
|
|
|
} else { // 常规模式(非搜索)
|
|
|
- let section = self.annotations.safe_element(for: index) as? KMBOTAAnnotationSection
|
|
|
- return section?.annotations?.first?.annotation
|
|
|
+ let model = self.annotations.safe_element(for: index) as? KMBotaAnnotationModel
|
|
|
+ return model?.anno
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -654,8 +654,8 @@ extension KMLeftSideViewController {
|
|
|
if anno is CPDFLineAnnotation || anno is CPDFSquareAnnotation || anno is CPDFCircleAnnotation || anno is CPDFInkAnnotation {
|
|
|
// 形状注释 + Ink 需要显示框住的内容【刷新】
|
|
|
for item in self.annotations {
|
|
|
- if let data = item.annotations?.first?.annotation, data.isEqual(to: anno) {
|
|
|
- self.noteOutlineView.reloadItem(item.annotations?.first)
|
|
|
+ if anno.isEqual(to: item.anno) {
|
|
|
+ self.noteOutlineView.reloadItem(item)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -676,11 +676,9 @@ extension KMLeftSideViewController {
|
|
|
self.filterButtonLayer?.isHidden = false
|
|
|
}
|
|
|
|
|
|
- var dataArray: [KMBOTAAnnotationSection] = []
|
|
|
var annotationArray: [CPDFAnnotation] = []
|
|
|
var allAnnotation: [CPDFAnnotation] = []
|
|
|
for i in 0 ..< self.pageCount() {
|
|
|
- var items: [KMBOTAAnnotationItem] = []
|
|
|
let page = self.pdfDocument()?.page(at: UInt(i))
|
|
|
var annos: [CPDFAnnotation] = []
|
|
|
// 处理过滤
|
|
@@ -711,25 +709,9 @@ extension KMLeftSideViewController {
|
|
|
annos.removeObject(annotation)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //转换所有annotation类型
|
|
|
- let section = KMBOTAAnnotationSection()
|
|
|
- for anno in annos {
|
|
|
- let item = KMBOTAAnnotationItem()
|
|
|
- item.section = section
|
|
|
- item.annotation = anno
|
|
|
- item.index = Int(anno.page.pageIndex())
|
|
|
- items.append(item)
|
|
|
-
|
|
|
- allAnnotation.append(anno)
|
|
|
- }
|
|
|
|
|
|
- if items.count != 0 {
|
|
|
- section.annotations = items
|
|
|
- section.page = page
|
|
|
- section.isItemExpanded = true
|
|
|
- dataArray.append(section)
|
|
|
- }
|
|
|
+ // 添加刷选后的注释
|
|
|
+ allAnnotation += annos
|
|
|
|
|
|
//添加所有annotation 用于筛选
|
|
|
annotationArray += (page?.annotations ?? [])
|
|
@@ -737,7 +719,6 @@ extension KMLeftSideViewController {
|
|
|
|
|
|
// 处理排序
|
|
|
if self.noteSortType == .page {
|
|
|
- var datas: [KMBOTAAnnotationSection] = []
|
|
|
/// 排序(升序)
|
|
|
if self.isAscendSort {
|
|
|
allAnnotation.sort {
|
|
@@ -752,22 +733,7 @@ extension KMLeftSideViewController {
|
|
|
return idx0 > idx1
|
|
|
}
|
|
|
}
|
|
|
- for anno in allAnnotation {
|
|
|
- let section = KMBOTAAnnotationSection()
|
|
|
- let item = KMBOTAAnnotationItem()
|
|
|
- item.section = section
|
|
|
- item.annotation = anno
|
|
|
- item.index = Int(anno.pageIndex())
|
|
|
-
|
|
|
- section.annotations = [item]
|
|
|
- section.page = anno.page
|
|
|
- section.isItemExpanded = true
|
|
|
-
|
|
|
- datas.append(section)
|
|
|
- }
|
|
|
- self.annotations = datas
|
|
|
} else if self.noteSortType == .time {
|
|
|
- var datas: [KMBOTAAnnotationSection] = []
|
|
|
/// 排序(升序)
|
|
|
if self.isAscendSort {
|
|
|
allAnnotation.sort {
|
|
@@ -790,21 +756,22 @@ extension KMLeftSideViewController {
|
|
|
return $0.modificationDate() > $1.modificationDate()
|
|
|
}
|
|
|
}
|
|
|
- for anno in allAnnotation {
|
|
|
- let section = KMBOTAAnnotationSection()
|
|
|
- let item = KMBOTAAnnotationItem()
|
|
|
- item.section = section
|
|
|
- item.annotation = anno
|
|
|
- item.index = Int(anno.pageIndex())
|
|
|
-
|
|
|
- section.annotations = [item]
|
|
|
- section.page = anno.page
|
|
|
- section.isItemExpanded = true
|
|
|
-
|
|
|
- datas.append(section)
|
|
|
- }
|
|
|
- self.annotations = datas
|
|
|
}
|
|
|
+ // 数据模型\化
|
|
|
+ var datas: [KMBotaAnnotationModel] = []
|
|
|
+ for anno in allAnnotation {
|
|
|
+ let item = KMBotaAnnotationModel()
|
|
|
+// item.section = section
|
|
|
+ item.anno = anno
|
|
|
+// item.index = Int(anno.pageIndex())
|
|
|
+
|
|
|
+// section.annotations = [item]
|
|
|
+// section.page = anno.page
|
|
|
+// section.isItemExpanded = true
|
|
|
+
|
|
|
+ datas.append(item)
|
|
|
+ }
|
|
|
+ self.annotations = datas
|
|
|
|
|
|
// 转换对象,用于数据显示
|
|
|
self.allAnnotations = annotationArray
|
|
@@ -830,15 +797,15 @@ extension KMLeftSideViewController {
|
|
|
// 清空数据
|
|
|
self.noteSearchArray.removeAll()
|
|
|
if stringValue.isEmpty {
|
|
|
- for section in self.annotations {
|
|
|
- guard let note = section.annotations?.first?.annotation else {
|
|
|
+ for model in self.annotations {
|
|
|
+ guard let note = model.anno else {
|
|
|
continue
|
|
|
}
|
|
|
self.noteSearchArray.append(note)
|
|
|
}
|
|
|
} else {
|
|
|
- for section in self.annotations {
|
|
|
- guard let note = section.annotations?.first?.annotation else {
|
|
|
+ for model in self.annotations {
|
|
|
+ guard let note = model.anno else {
|
|
|
continue
|
|
|
}
|
|
|
var noteString = KMBOTAAnnotationTool.fetchContentLabelString(annotation: note)
|
|
@@ -898,8 +865,8 @@ extension KMLeftSideViewController {
|
|
|
let rowIndexes = self.noteOutlineView.selectedRowIndexes
|
|
|
for row in rowIndexes {
|
|
|
let item = self.noteOutlineView.item(atRow: row)
|
|
|
- if item is KMBOTAAnnotationItem {
|
|
|
- if let anno = (item as! KMBOTAAnnotationItem).annotation {
|
|
|
+ if item is KMBotaAnnotationModel {
|
|
|
+ if let anno = (item as! KMBotaAnnotationModel).anno {
|
|
|
// if anno.type == nil {
|
|
|
// item = [(SKNoteText *)item note];
|
|
|
// }
|
|
@@ -936,11 +903,9 @@ extension KMLeftSideViewController {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- for section in self.annotations {
|
|
|
- for item in section.annotations ?? [] {
|
|
|
- if let note = item.annotation, note is CPDFMarkupAnnotation {
|
|
|
- mutableArray.append(note)
|
|
|
- }
|
|
|
+ for model in self.annotations {
|
|
|
+ if let note = model.anno, note is CPDFMarkupAnnotation {
|
|
|
+ mutableArray.append(note)
|
|
|
}
|
|
|
}
|
|
|
}
|