Bladeren bron

【左边栏】- 大纲列表添加上一级无效,进入编辑状态效果处理

liaoxiaoyue 1 jaar geleden
bovenliggende
commit
a032b15a20

+ 6 - 2
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Outline/KMOutlineViewController.swift

@@ -208,8 +208,9 @@ class KMOutlineViewController: NSViewController,NSMenuItemValidation {
             __NSBeep()
             __NSBeep()
         } else {
         } else {
             let currentPDFOutline  = self.outlineView.item(atRow: selectedRowIndexes.last!) as! CPDFOutline
             let currentPDFOutline  = self.outlineView.item(atRow: selectedRowIndexes.last!) as! CPDFOutline
-            let parent = currentPDFOutline.parent
+            var parent = currentPDFOutline.parent
             let index = NSInteger(parent!.index) + 1
             let index = NSInteger(parent!.index) + 1
+            parent = parent?.parent
             if parent != nil {
             if parent != nil {
                 self.addPDFOutlineToIndex(index: index, atParent: parent)
                 self.addPDFOutlineToIndex(index: index, atParent: parent)
             } else {
             } else {
@@ -320,10 +321,10 @@ class KMOutlineViewController: NSViewController,NSMenuItemValidation {
     }
     }
     
     
     func renamePDFOutline(outline : CPDFOutline! , label:String) {
     func renamePDFOutline(outline : CPDFOutline! , label:String) {
+        self.renameTextField.isEditable = false
         if outline.label == label {
         if outline.label == label {
             return
             return
         }
         }
-        
         outline.label = label
         outline.label = label
         self.outlineView.reloadData()
         self.outlineView.reloadData()
         
         
@@ -390,6 +391,9 @@ class KMOutlineViewController: NSViewController,NSMenuItemValidation {
         for i in 0..<numRows {
         for i in 0..<numRows {
             let tPDFOutline = self.outlineView.item(atRow: i) as! CPDFOutline
             let tPDFOutline = self.outlineView.item(atRow: i) as! CPDFOutline
             let tPage = tPDFOutline.destination.pageIndex
             let tPage = tPDFOutline.destination.pageIndex
+            if tPage < 0 {
+                continue
+            }
             var page = self.listView.document.page(at: UInt(tPage))!
             var page = self.listView.document.page(at: UInt(tPage))!
             var tDict : [String : CPDFPage] = ["\(i)":page]
             var tDict : [String : CPDFPage] = ["\(i)":page]
             arr.append(tDict)
             arr.append(tDict)