Quellcode durchsuchen

Merge branch 'develop' of git.kdan.cc:Mac_PDF/PDF_Office into develop

tangchao vor 1 Jahr
Ursprung
Commit
1e87d9a506

+ 14 - 5
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/BookMarks/KMBookMarkViewController.swift

@@ -65,14 +65,23 @@ class KMBookMarkViewController: NSViewController, NSTextFieldDelegate,NSMenuItem
         self.bookTableView.reloadData()
     }
     
+    func addBookMarkAndEdit(newBookMark:CPDFBookmark) {
+        self.reloadData()
+        if self.dataSource.contains(newBookMark) {
+            if let index = self.dataSource.firstIndex(of: newBookMark) {
+                self.selectRow(index: index)
+                self.renameBookWithRow(row: index)
+            }
+        }
+    }
+    
     func selectRow(index:NSInteger) {
         self.bookTableView.deselectAll(nil)
         
-        if index > 0 {
-            var indexSet = IndexSet()
-            indexSet.insert(index)
-            self.bookTableView.selectRowIndexes(indexSet, byExtendingSelection: false)
-        }
+        var indexSet = IndexSet()
+        indexSet.insert(index)
+        self.bookTableView.selectRowIndexes(indexSet, byExtendingSelection: false)
+        
     }
     
     func initNotification() {

+ 2 - 1
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMThumbnailViewController.swift

@@ -173,7 +173,7 @@ class KMThumbnailViewController: NSViewController {
     @objc func KMPDFViewCurrentPageDidChangedNotification(notification: NSNotification) {
         let pdfdocument : CPDFDocument = notification.object as! CPDFDocument
         if pdfdocument.isEqual(self.listView.document) {
-            self.pdfCurrentPageChange();
+            self.pdfCurrentPageChange()
         }
     }
     
@@ -491,6 +491,7 @@ class KMThumbnailViewController: NSViewController {
             self.listView.document.removePage(at: indexs)
             self.listView.layoutDocumentView()
             self.thumbnailView.reloadData()
+            self.pdfCurrentPageChange()
         }
     }
     

+ 17 - 4
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -273,8 +273,13 @@ extension KMMainViewController {
     }
     
     func addBookmarkMenu() -> NSMenuItem {
-        let bookMarkItem = NSMenuItem(title: NSLocalizedString("Add BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
-        return bookMarkItem
+        if self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex)) == nil {
+            let bookMarkItem = NSMenuItem(title: NSLocalizedString("Add BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
+            return bookMarkItem
+        } else {
+            let bookMarkItem = NSMenuItem(title: NSLocalizedString("Remove BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
+            return bookMarkItem
+        }
     }
     
     func findStringMenu() -> NSMenuItem {
@@ -499,8 +504,16 @@ extension KMMainViewController {
             self.listView.document.removeBookmark(forPageIndex: UInt(self.listView.currentPageIndex))
             self.listView.setNeedsDisplayForVisiblePages()
         }
-        self.leftSideViewController.refreshMethodType(methodType: .BookMark)
-        self.leftSideViewController.bookViewController.reloadData()
+        if self.leftPanelOpen == false || self.leftSideViewController.type.methodType != .BookMark {
+            self.leftSideViewController.refreshMethodType(methodType: .BookMark)
+        }
+        let bookMark = self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex))
+        if bookMark != nil {
+            self.leftSideViewController.bookViewController.addBookMarkAndEdit(newBookMark: bookMark!)
+        } else {
+            self.leftSideViewController.bookViewController.reloadData()
+        }
+        
     }
     
     @objc func menuItemAnnotationClick_FindString(sender:NSMenuItem) {