3 Commits ba34130a60 ... 891c7d4685

Autore SHA1 Messaggio Data
  liaoxiaoyue 891c7d4685 【PDFView】- 右键菜单添加书签,移除书签显示修改 1 anno fa
  liaoxiaoyue 376710fd7c 【左边栏】- 删除选中缩略图后选中当前页面的缩略图 1 anno fa
  liaoxiaoyue 2c06ce7f8d 【左边栏】- 添加书签打开左边栏并进入编辑状态 1 anno fa

+ 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) {