Kaynağa Gözat

【页面编辑】反转优化(局部刷新)

tangchao 1 yıl önce
ebeveyn
işleme
9c25dcc9c4

+ 13 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -345,7 +345,9 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
         KMPageEditTools.reverse((self.listView?.document)!, indexs
         ) { result, error in
             if (result) {
-                self.refreshUIForKeepSelecteds()
+                let indexpaths = self.thumbnailView.selectionIndexPaths
+                self.refreshUI(indexpaths: self.indexsToIndexpaths(indexs: indexs))
+                self.thumbnailView.selectionIndexPaths = indexpaths
                 
                 self.kmUndoManager?.registerUndo(withTarget: self, selector: #selector(self.reversePages), object: indexs)
             }
@@ -958,6 +960,16 @@ extension KMPDFEditViewController {
         self.km_becomeFirstResponder()
     }
     
+    override func replaceAfter(of targetIndexs: IndexSet, with pages: [CPDFPage], at index: Int) {
+        var indexpaths = Set<IndexPath>()
+        var insertIndex = index
+        for _ in pages {
+            indexpaths.insert(IndexPath(item: insertIndex, section: 0))
+            insertIndex += 1
+        }
+        self.thumbnailView.selectionIndexPaths = indexpaths
+    }
+    
     func listViewCurrentPageUpdateForDrag(indexs: IndexSet, toIndex: Int) {
         // listView 当前页面 被拖拽
         if (indexs.contains(self._listViewCurrentIndex)) {

+ 9 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift

@@ -334,6 +334,7 @@ class KMPDFThumbViewBaseController: KMBaseViewController {
             }
             
             self._undo_replace(of: self.indexpathsToIndexs(indexpaths: targetIndexpaths), with: pages, at: index)
+            self.replaceAfter(of: self.indexpathsToIndexs(indexpaths: targetIndexpaths), with: pages, at: index)
         }
     }
     
@@ -906,6 +907,13 @@ extension KMPDFThumbViewBaseController {
         }
         return indexs
     }
+    func indexsToIndexpaths(indexs: IndexSet) -> Set<IndexPath> {
+        var indexpaths = Set<IndexPath>()
+        for index in indexs {
+            indexpaths.insert(IndexPath(item: index, section: 0))
+        }
+        return indexpaths
+    }
     
     @objc func deleteAfter(indexpaths: Set<IndexPath>) {}
     @objc func leftRotateAfter(indexpaths: Set<IndexPath>) {}
@@ -913,6 +921,7 @@ extension KMPDFThumbViewBaseController {
     @objc func cutAfter(indexpaths: Set<IndexPath>) {}
     @objc func copyAfter(indexpaths: Set<IndexPath>) {}
     @objc func pasteAfter(at index: Int) {}
+    @objc func replaceAfter(of targetIndexs: IndexSet, with pages: [CPDFPage], at index: Int) {}
     
     func km_beginSheet(windowC: NSWindowController) {
         guard let _window = windowC.window else {