|
@@ -98,6 +98,8 @@ class KMBookMarkViewController: NSViewController, NSTextFieldDelegate {
|
|
|
|
|
|
self.dataSource.sort(){$0.bookMark.pageIndex < $1.bookMark.pageIndex}
|
|
self.dataSource.sort(){$0.bookMark.pageIndex < $1.bookMark.pageIndex}
|
|
self.bookTableView.reloadData()
|
|
self.bookTableView.reloadData()
|
|
|
|
+
|
|
|
|
+ self.updateAddBookMarkState()
|
|
}
|
|
}
|
|
|
|
|
|
func addBookMarkAndEdit(newBookMark: KMBookMarkItem) {
|
|
func addBookMarkAndEdit(newBookMark: KMBookMarkItem) {
|
|
@@ -239,6 +241,7 @@ class KMBookMarkViewController: NSViewController, NSTextFieldDelegate {
|
|
}
|
|
}
|
|
isLocalEvent = false
|
|
isLocalEvent = false
|
|
}
|
|
}
|
|
|
|
+ self.updateAddBookMarkState()
|
|
}
|
|
}
|
|
|
|
|
|
@objc func documentPageCountChangedNotification(notification: NSNotification) {
|
|
@objc func documentPageCountChangedNotification(notification: NSNotification) {
|
|
@@ -295,7 +298,11 @@ extension KMBookMarkViewController : NSTableViewDelegate,NSTableViewDataSource {
|
|
self.selectItems.count == 1 {
|
|
self.selectItems.count == 1 {
|
|
self.selectIndex(index: row)
|
|
self.selectIndex(index: row)
|
|
}
|
|
}
|
|
- self.addMenuTitle(view: view, event: event)
|
|
|
|
|
|
+
|
|
|
|
+ if self.bookTableView.rowView(atRow: row, makeIfNecessary: false) != nil {
|
|
|
|
+ let tempView = self.bookTableView.rowView(atRow: row, makeIfNecessary: false)
|
|
|
|
+ self.addMenuTitle(view: tempView!, event: event)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return rowView
|
|
return rowView
|
|
@@ -391,6 +398,21 @@ extension KMBookMarkViewController : NSTableViewDelegate,NSTableViewDataSource {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func updateAddBookMarkState() {
|
|
|
|
+ self.addBookButton.isEnabled = self.canAddBorkMark()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func canAddBorkMark() -> Bool {
|
|
|
|
+ if self.listView.document.bookmarks() != nil && self.listView.document.bookmarks()?.count != 0 {
|
|
|
|
+ for bookMark in self.listView.document.bookmarks() {
|
|
|
|
+ if bookMark.pageIndex == self.listView.currentPageIndex {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: undoRedo
|
|
//MARK: undoRedo
|
|
@@ -455,11 +477,15 @@ extension KMBookMarkViewController {
|
|
self.reloadData()
|
|
self.reloadData()
|
|
|
|
|
|
if bookMarks.count == 1 {
|
|
if bookMarks.count == 1 {
|
|
- let item = KMBookMarkItem()
|
|
|
|
- item.bookMark = self.listView.document.bookmark(forPageIndex: UInt(bookMarks.first!.index))
|
|
|
|
- item.label = item.bookMark.label
|
|
|
|
- item.index = UInt(item.bookMark.pageIndex)
|
|
|
|
- self.addBookMarkAndEdit(newBookMark: item)
|
|
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ if self.listView.document.bookmark(forPageIndex: UInt(bookMarks.first!.index)) != nil {
|
|
|
|
+ let item = KMBookMarkItem()
|
|
|
|
+ item.bookMark = self.listView.document.bookmark(forPageIndex: UInt(bookMarks.first!.index))
|
|
|
|
+ item.label = item.bookMark.label
|
|
|
|
+ item.index = UInt(item.bookMark.pageIndex)
|
|
|
|
+ self.addBookMarkAndEdit(newBookMark: item)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//undo redo
|
|
//undo redo
|