123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- //
- // KMOutlineViewController.swift
- // PDF Reader Pro
- //
- // Created by lxy on 2022/10/10.
- //
- import Cocoa
- import KMComponentLibrary
- extension KMNSearchKey.wholeWords {
- static let outline = "OutlineSearchWholeWordsKey"
- }
- extension KMNSearchKey.caseSensitive {
- static let outline = "OutlineSearchCaseSensitiveKey"
- }
- class KMOutlineViewController: KMNBaseViewController {
- @IBOutlet var contendView: NSView!
- @IBOutlet weak var topView: NSView!
- @IBOutlet weak var titleLabel: NSTextField!
-
- @IBOutlet weak var lineView: NSView!
-
- @IBOutlet weak var addButton: NSButton!
- @IBOutlet weak var moreButton: NSButton!
- @IBOutlet var topSepline: NSView!
-
- @IBOutlet weak var emptyView: NSView!
- @IBOutlet weak var bigTipLabel: NSTextField!
- @IBOutlet weak var tipLabel: NSTextField!
-
- @IBOutlet weak var BOTAOutlineView: KMBOTAOutlineView!
-
- var dragPDFOutline : KMBOTAOutlineItem!
- var renameTextField : NSTextField!
- var renamePDFOutline : KMBOTAOutlineItem!
- let moreMenu = NSMenu()
- var isLocalEvent = false
-
- var model = KMNOutlineModel()
- var handdler = KMNOutlineHanddler()
-
- private weak var popover_: NSPopover?
-
- private lazy var searchButton_: ComponentButton = {
- let view = ComponentButton()
- view.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, state: .normal, isDisable: false, onlyIcon: true)
- return view
- }()
-
- private lazy var addButton_: ComponentButton = {
- let view = ComponentButton()
- view.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, state: .normal, isDisable: false, onlyIcon: true, keepPressState: false)
- return view
- }()
-
- private lazy var moreDropdown_: ComponentButton = {
- let view = ComponentButton()
- view.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, state: .normal, isDisable: false, onlyIcon: true, icon: NSImage(named: "KMImageNameOutlineMore"))
- return view
- }()
-
- private lazy var headerSearchView_: KMNBotaHeaderSearchView? = {
- let view = KMNBotaHeaderSearchView.createFromNib()
- return view
- }()
-
- private var emptyView_: ComponentEmpty = {
- let view = ComponentEmpty()
- view.properties = ComponentEmptyProperty(emptyType: .noOutline, state: .normal, image: NSImage(named: "KMImageNameOutlineEmpty"), text: KMLocalizedString("No Outline"), subText: KMLocalizedString("Here is the description."))
- return view
- }()
-
- private var groupView_: ComponentGroup?
- private var menuGroupView_: ComponentGroup?
- private var searchGroupView_: ComponentGroup?
- private var searchGroupTarget_: ComponentButton?
-
- deinit {
- self.BOTAOutlineView.delegate = nil
- }
-
- override func viewWillDisappear() {
- super.viewWillDisappear()
- self.cancelSelect()
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- handdler.delegate = self
-
- titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-bold")
- self.topView.wantsLayer = true
-
- addButton.image = nil
-
- topView.addSubview(searchButton_)
- searchButton_.km_add_size_constraint(size: NSMakeSize(24, 24))
- searchButton_.km_add_centerY_constraint(constant: 1)
- searchButton_.km_add_trailing_constraint(equalTo: addButton, attribute: .leading, constant: -4)
- searchButton_.setTarget(self, action: #selector(_searchAction))
-
- addButton.addSubview(addButton_)
- addButton_.km_add_size_constraint(size: NSMakeSize(24, 24))
- addButton_.km_add_centerX_constraint()
- addButton_.km_add_centerY_constraint()
- addButton_.setTarget(self, action: #selector(addNewOutline))
-
- moreButton.image = nil
- moreButton.addSubview(moreDropdown_)
- moreDropdown_.km_add_size_constraint(size: NSMakeSize(24, 24))
- moreDropdown_.km_add_centerX_constraint()
- moreDropdown_.km_add_centerY_constraint()
- moreDropdown_.setTarget(self, action: #selector(_moreAction))
-
- if let data = headerSearchView_ {
- topView.addSubview(data)
- headerSearchView_?.frame = topView.bounds
- headerSearchView_?.autoresizingMask = [.width, .height]
- }
- _hideHeaderSearch()
- headerSearchView_?.itemClick = { [weak self] idx, params in
- if idx == 1 { // 显示搜索限制条件
- guard let button = params.first as? ComponentButton else {
- return
- }
- self?.showSearchGroupView(sender: button)
- } else if idx == 2 { // 关闭搜索
- self?._hideHeaderSearch()
-
- self?.reloadData()
- }
- }
- headerSearchView_?.valueDidChange = { [weak self] sender, info in
- let value = info?[.newKey] as? String ?? ""
-
- self?.BOTAOutlineView.searchKey = value
- self?.reloadData()
- self?.BOTAOutlineView.outlineView.expandItem(nil, expandChildren: true)
- }
-
- emptyView.wantsLayer = true
- bigTipLabel.stringValue = ""
- tipLabel.stringValue = ""
-
- emptyView.addSubview(emptyView_)
- emptyView_.km_add_top_constraint(constant: 232)
- emptyView_.km_add_bottom_constraint()
- emptyView_.km_add_leading_constraint()
- emptyView_.km_add_trailing_constraint()
-
- self.BOTAOutlineView.delegate = self
- self.BOTAOutlineView.inputData = self.handdler.outlineRoot()
- self.BOTAOutlineView.outlineView.doubleAction = #selector(outlineViewDoubleAction)
- }
-
- // To create an outline, please right-click on the selected page and choose \"Add Outline\", or click \"Add\" in the upper right corner.
- override func updateUILanguage() {
- super.updateUILanguage()
-
- KMMainThreadExecute {
- self.titleLabel.stringValue = KMLocalizedString("Outline")
-
- self.moreButton.toolTip = KMLocalizedString("More")
- self.addButton.toolTip = KMLocalizedString("Add Outline")
- }
- }
-
- override func updateUIThemeColor() {
- super.updateUIThemeColor()
-
- KMMainThreadExecute {
- self.contendView.wantsLayer = true
- let color = KMNColorTools.colorBg_layoutMiddle()
- self.contendView.layer?.backgroundColor = color.cgColor
- self.headerSearchView_?.wantsLayer = true
- self.headerSearchView_?.layer?.backgroundColor = color.cgColor
- self.headerSearchView_?.bottomLine.wantsLayer = true
- self.headerSearchView_?.bottomLine.layer?.backgroundColor = KMNColorTools.colorPrimary_border1().cgColor
-
- self.titleLabel.textColor = KMNColorTools.colorText_2()
-
- self.addButton_.properties.icon = NSImage(named: "KMBookmarkAdd")
- self.addButton_.reloadData()
-
- self.searchButton_.properties.icon = NSImage(named: "KMImageNameOutlineSearch")
- self.searchButton_.reloadData()
-
- let dividerColor = KMNColorTools.colorBorder_divider()
- self.topSepline.wantsLayer = true
- self.topSepline.layer?.backgroundColor = dividerColor.cgColor
- self.lineView.backgroundColor(dividerColor)
- }
- }
-
- override func addNotifations() {
- super.addNotifations()
-
- NotificationCenter.default.addObserver(self, selector: #selector(KMPDFViewCurrentPageDidChangedNotification), name: NSNotification.Name.init(rawValue: "KMPDFViewCurrentPageDidChanged"), object: nil)
- }
-
- func addRightMenu(view: NSView, event: NSEvent) {
- let point = event.locationInWindow
- let tempView = view
- var viewHeight: CGFloat = 0
- let items: [String] = ["Add Item", "Add Sub-Item", "Add A Higher Level","", "Delete","", "Edit", "Rename", "Change Destination","", "Promote", "Demote"]
- var menuItemArr: [ComponentMenuitemProperty] = []
- for value in items {
- if value.count == 0 {
- let property: ComponentMenuitemProperty = ComponentMenuitemProperty.divider()
- menuItemArr.append(property)
- viewHeight += 8
- } else {
- let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
- itemSelected: false,
- isDisabled: false,
- keyEquivalent: nil,
- text: KMLocalizedString(value),
- identifier: value)
-
- menuItemArr.append(properties_Menuitem)
- viewHeight += 36
- }
- }
- if self.BOTAOutlineView.outlineView.selectedRowIndexes.count > 1 {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Delete") {
- data.isDisabled = false
- } else {
- data.isDisabled = true
- }
- }
- if menuGroupView_ == nil {
- menuGroupView_ = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
- }
-
- if menuGroupView_ != nil {
- menuGroupView_?.clickedAutoHide = false
- menuGroupView_?.groupDelegate = self
- menuGroupView_?.frame = CGRectMake(0, 0, 180, viewHeight)
- menuGroupView_?.updateGroupInfo(menuItemArr)
-
- menuGroupView_?.showWithPoint(CGPoint(x: point.x, y: point.y - viewHeight), relativeTo: tempView)
- }
- return
- } else if self.BOTAOutlineView.outlineView.selectedRowIndexes.count > 0 {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Add Sub-Item") || data.text == KMLocalizedString("Change Destination") {
- data.isDisabled = false
- } else {
- // data.isDisabled = true
- }
- }
- }
- if self.BOTAOutlineView.outlineView.clickedRow == -1 {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Add Item") {
- data.isDisabled = false
- } else {
- data.isDisabled = true
- }
- }
- } else {
- let outlineItem : KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow: self.BOTAOutlineView.outlineView.clickedRow) as! KMBOTAOutlineItem
- if outlineItem.outline.index > 0 {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Demote") {
- data.isDisabled = false
- } else {
- // data.isDisabled = true
- }
- }
- } else {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Demote") {
- data.isDisabled = true
- } else {
- // data.isDisabled = true
- }
- }
- }
-
- let parentOutline = outlineItem.outline.parent
- let grandparentOutline = parentOutline?.parent
- if grandparentOutline != nil {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Add A Higher Level") || data.text == KMLocalizedString("Promote") {
- data.isDisabled = false
- } else {
- // data.isDisabled = true
- }
- }
- } else {
- for data in menuItemArr {
- if data.text == KMLocalizedString("Add A Higher Level") || data.text == KMLocalizedString("Promote") {
- data.isDisabled = true
- } else {
- // data.isDisabled = true
- }
- }
- }
- }
-
- if menuGroupView_ == nil {
- menuGroupView_ = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
- }
-
- if menuGroupView_ != nil {
- menuGroupView_?.clickedAutoHide = false
- menuGroupView_?.groupDelegate = self
- menuGroupView_?.frame = CGRectMake(0, 0, 180, viewHeight)
- menuGroupView_?.updateGroupInfo(menuItemArr)
-
- menuGroupView_?.showWithPoint(CGPoint(x: point.x, y: point.y - viewHeight), relativeTo: tempView)
- }
- }
-
- func reloadData() {
- self.BOTAOutlineView.reloadData(expandItemType: .none)
- }
-
- func editOutlineUI(editVC : KMOutlineEditViewController!) {
- if editVC.pageRadio.properties.checkboxType == .selected {
- let index = Int(editVC.pageInput.properties.text) ?? 0
- let pageIndex = max(0, index-1)
- if editVC.originalDestination?.pageIndex != pageIndex {
- let page = editVC.pdfView?.document.page(at: UInt(pageIndex))
- if page != nil {
- let destination = CPDFDestination.init(document: editVC.pdfView!.document, pageIndex: pageIndex)
- editVC.outline?.destination = destination
- } else {
- __NSBeep()
- }
- }
- } else if editVC.webRaido.properties.checkboxType == .selected {
- if editVC.originalURLString != editVC.webInput.properties.text {
- var urlString = editVC.webInput.properties.text
- let tLowerUrl = urlString.lowercased()
- if !tLowerUrl.hasPrefix("https://") && !tLowerUrl.hasPrefix("pf]://") && !urlString.hasPrefix("https://") &&
- urlString.lengthOfBytes(using: String.Encoding(rawValue: String.Encoding.utf16.rawValue)) > 0 {
- urlString = "http://\(urlString)"
- }
- let action = CPDFURLAction.init(url: urlString)
- editVC.outline?.action = action
- }
- } else if editVC.emailRadio.properties.checkboxType == .selected {
- var mailString = editVC.emailInput.properties.text
- let tLowerStr = mailString.lowercased()
- if !tLowerStr.hasPrefix("mailto:") {
- mailString = "mailto:\(mailString)"
- }
- if mailString != editVC.originalURLString {
- var action = CPDFURLAction.init(url: mailString)
- if action?.url == nil {
- action = CPDFURLAction.init(url: "mailto:")
- }
- editVC.outline?.action = action
- }
- }
- }
-
- // MARK: - Private Methods
-
- private func _showAlert(style: NSAlert.Style, message: String, info: String, buttons: [String]) -> NSApplication.ModalResponse {
- let alert = NSAlert()
- alert.alertStyle = style
- alert.messageText = message
- alert.informativeText = info
- for button in buttons {
- alert.addButton(withTitle: button)
- }
- return alert.runModal()
- }
-
- private func _showHeaderSearch() {
- BOTAOutlineView.isSearchMode = true
- headerSearchView_?.isHidden = false
- }
-
- private func _hideHeaderSearch() {
- BOTAOutlineView.isSearchMode = false
- headerSearchView_?.isHidden = true
- }
-
- @objc private func _moreAction() {
- self.showGroupView()
- }
-
- //MARK: - GroupView
-
- func showGroupView() {
- var viewHeight: CGFloat = 8
- var menuItemArr: [ComponentMenuitemProperty] = []
- for i in ["Expand All", "Collapse All", "Remove All Outlines"] {
- let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
- itemSelected: false,
- isDisabled: false,
- keyEquivalent: nil,
- text: KMLocalizedString(i))
- menuItemArr.append(properties_Menuitem)
- viewHeight += 36
- }
-
- if let data = menuItemArr.first {
- var canExpand = false
- for row in 0..<self.BOTAOutlineView.outlineView.numberOfRows {
- // 检查当前项目是否可以展开
- let item = self.BOTAOutlineView.outlineView.item(atRow: row)
- if self.BOTAOutlineView.outlineView.isExpandable(item) {
- if !self.BOTAOutlineView.outlineView.isItemExpanded(item) {
- canExpand = true
- break
- }
- }
- }
- data.isDisabled = !canExpand
- }
-
- if let data = menuItemArr.safe_element(for: 1) as? ComponentMenuitemProperty {
- var canCollapse = false
- for row in 0..<self.BOTAOutlineView.outlineView.numberOfRows {
- let item = self.BOTAOutlineView.outlineView.item(atRow: row)
- if self.BOTAOutlineView.outlineView.isExpandable(item) {
- if self.BOTAOutlineView.outlineView.isItemExpanded(item) {
- canCollapse = true
- break
- }
- }
- }
- data.isDisabled = !canCollapse
- }
-
- if let data = menuItemArr.last {
- if self.BOTAOutlineView.outlineView.item(atRow: 0) != nil {
- data.isDisabled = false
- } else {
- data.isDisabled = true
- }
- }
-
- if groupView_ == nil {
- groupView_ = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
- }
- groupView_?.groupDelegate = self
- groupView_?.frame = CGRectMake(310, 0, 200, viewHeight)
- groupView_?.updateGroupInfo(menuItemArr)
-
- var point = moreDropdown_.convert(moreDropdown_.frame.origin, to: nil)
- point.y -= viewHeight
- groupView_?.showWithPoint(point, relativeTo: moreDropdown_)
-
- moreDropdown_.properties.state = .pressed
- moreDropdown_.reloadData()
- }
-
- func showSearchGroupView(sender: ComponentButton) {
- var viewHeight: CGFloat = 8
- var menuItemArr: [ComponentMenuitemProperty] = []
- let titles = ["Whole Words","Case Sensitive"]
- for i in titles {
- let menuI = ComponentMenuitemProperty(text: KMLocalizedString(i))
- menuItemArr.append(menuI)
- viewHeight += 36
- }
-
- if let info = menuItemArr.first {
- if KMDataManager.ud_bool(forKey: KMNSearchKey.wholeWords.outline) {
- info.righticon = NSImage(named: "KMNImageNameMenuSelect")
- }
- }
- if let info = menuItemArr.last {
- if KMDataManager.ud_bool(forKey: KMNSearchKey.caseSensitive.outline) {
- info.righticon = NSImage(named: "KMNImageNameMenuSelect")
- }
- }
-
- let groupView = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
- searchGroupView_ = groupView
- groupView?.groupDelegate = self
- groupView?.frame = CGRectMake(310, 0, 200, viewHeight)
- groupView?.updateGroupInfo(menuItemArr)
-
- var point = sender.convert(sender.frame.origin, to: nil)
- point.y -= viewHeight
- groupView?.showWithPoint(point, relativeTo: sender)
- searchGroupTarget_ = sender
- }
-
- func removeGroupView() {
- if groupView_ != nil {
- groupView_?.removeFromSuperview()
- }
- moreDropdown_.properties.state = .normal
- moreDropdown_.reloadData()
- }
-
- func updateExtempViewState() {
- if(self.handdler.outlineRoot() == nil || self.handdler.outlineRoot()?.numberOfChildren == 0) { //无数据时的图
- self.emptyView.isHidden = false
- } else {
- self.emptyView.isHidden = true
- }
- }
- }
- //MARK: - Notification
- extension KMOutlineViewController {
- @objc func KMPDFViewCurrentPageDidChangedNotification(notification: NSNotification) {
- if notification.object is CPDFDocument {
- let pdfdocument : CPDFDocument = notification.object as! CPDFDocument
- if pdfdocument.isEqual(self.handdler.document) {
- if !isLocalEvent {
- self.updateOutlineSelection()
- }
- self.isLocalEvent = false
- }
- }
- }
- }
- //MARK: - Menu 右键菜单
- extension KMOutlineViewController {
- @objc func outlineViewDoubleAction() {
- if(self.BOTAOutlineView.outlineView.clickedRow >= 0) {
- self.renameItemAction()
- }
- }
-
- @objc func addItemAction() {
- guard let outlineView = BOTAOutlineView.outlineView else {
- return
- }
- let selectRowIndexs = outlineView.selectedRowIndexes
- let dataCount = BOTAOutlineView.data?.children.count ?? 0
- var index: Int = 0
- var parent: KMBOTAOutlineItem?
- var outlineItem: KMBOTAOutlineItem?
- if selectRowIndexs.count == 0 {
- var lastOulineItem: KMBOTAOutlineItem?
- if dataCount == 0 {
- let item = KMBOTAOutlineItem()
- item.outline = self.handdler.document!.setNewOutlineRoot()
- item.parent = nil
- parent = item
-
- lastOulineItem = item
- } else {
- outlineItem = outlineView.item(atRow: outlineView.numberOfRows - 1) as? KMBOTAOutlineItem
- lastOulineItem = outlineItem
- while lastOulineItem?.parent != nil {
- lastOulineItem = lastOulineItem?.parent
- }
- parent = lastOulineItem
- }
- index = Int(lastOulineItem?.outline.numberOfChildren ?? 0)
- } else {
- outlineItem = outlineView.item(atRow: selectRowIndexs.last ?? 0) as? KMBOTAOutlineItem
- parent = outlineItem?.parent ?? KMBOTAOutlineItem()
- index = Int((outlineItem?.outline.index) ?? 0 + 1)
- }
-
- self.addOutlineToIndex(index: index, parent: parent)
- }
-
- @objc func addChildItemAction() {
- let outlineView: KMOutlineView = self.BOTAOutlineView.outlineView
- let selectRowIndexs = outlineView.selectedRowIndexes
- if selectRowIndexs.count != 0 {
- let outlineItem: KMBOTAOutlineItem = outlineView.item(atRow: selectRowIndexs.last!) as! KMBOTAOutlineItem
- let index = outlineItem.outline.numberOfChildren
- self.addOutlineToIndex(index: NSInteger(index), parent: outlineItem)
- }
- }
-
- @objc func addHigherItemAction() {
- let outlineView: KMOutlineView = self.BOTAOutlineView.outlineView
- let selectRowIndexs = outlineView.selectedRowIndexes
- if selectRowIndexs.count != 0 {
- let outlineItem: KMBOTAOutlineItem = outlineView.item(atRow: selectRowIndexs.last!) as! KMBOTAOutlineItem
- var parent = outlineItem.parent
- let index = NSInteger(parent!.outline.index) + 1
- parent = parent?.parent
- if parent != nil {
- self.addOutlineToIndex(index: index, parent: parent!)
- }
- }
- }
-
- @objc func deleteItemAction() {
- let outlineView: KMOutlineView = self.BOTAOutlineView.outlineView
- let selectRowIndexs = outlineView.selectedRowIndexes
- if selectRowIndexs.count != 0 {
- var outlineItems: [KMBOTAOutlineItem] = []
- for index in selectRowIndexs {
- let outlineItem: KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow: index) as! KMBOTAOutlineItem
- outlineItem.toIndex = index
- outlineItem.parent = outlineItem.parent ?? KMBOTAOutlineItem()
- outlineItems.append(outlineItem)
- }
- self.deleteOutline(outlineItems: outlineItems)
- }
- }
-
- @objc func editItemAction() {
- let clickedRow = BOTAOutlineView.outlineView.clickedRow
- if clickedRow < 0 {
- NSSound.beep()
- return
- }
- if let rowView = self.BOTAOutlineView.outlineView.rowView(atRow: clickedRow, makeIfNecessary: true) {
- let item = self.BOTAOutlineView.outlineView.item(atRow: clickedRow) as? KMBOTAOutlineItem
- let vc = KMOutlineEditViewController.init(outline: item?.outline, document: self.handdler.pdfView)
- vc.pageCount = handdler.pageCount()
- vc.itemClick = { [weak self] idx, params in
- if idx == 1 {
- self?.popover_?.close()
- } else if idx == 2 {
- self?.popover_?.close()
-
- if let viewC = params.first as? KMOutlineEditViewController {
- let resp = self?._showAlert(style: .informational, message: KMLocalizedString("Are you sure you want to apply edits to this outline?"), info: "", buttons: [KMLocalizedString("Apply"), KMLocalizedString("Cancel")])
- if resp == .alertFirstButtonReturn {
- self?.editOutlineUI(editVC: viewC)
- }
- }
- }
- }
- let popover = NSPopover()
- popover_ = popover
- popover.delegate = self
- popover.contentViewController = vc
- popover.animates = true
- popover.behavior = .transient
- popover.setValue(true, forKey: "shouldHideAnchor")
- popover.show(relativeTo: rowView.bounds, of: rowView, preferredEdge: .minX)
- }
- }
-
- @objc func renameItemAction() {
- if self.BOTAOutlineView.outlineView.clickedRow >= 0 {
- self.renameOutlineWithRow(row: self.BOTAOutlineView.outlineView.clickedRow)
- } else {
- __NSBeep()
- }
- }
-
- @objc func changeItemAction() {
- if self.BOTAOutlineView.outlineView.clickedRow >= 0 {
- let outlineItem: KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow: self.BOTAOutlineView.outlineView.clickedRow) as! KMBOTAOutlineItem
- let resp = _showAlert(style: .informational, message: NSLocalizedString("Are you sure you want to set the destination as the current location?", comment: ""), info: "", buttons: [NSLocalizedString("Yes", comment:""), NSLocalizedString("No", comment:"")])
- if resp == .alertFirstButtonReturn {
- // self.changeLocation(outlineItem: outlineItem, destination: self.fetchCurrentDestination())
- }
- } else {
- __NSBeep()
- }
- }
-
- @objc func promoteItemAction() {
- if self.BOTAOutlineView.outlineView.clickedRow >= 0 {
- let outlineItem: KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow: self.BOTAOutlineView.outlineView.clickedRow) as! KMBOTAOutlineItem
- var parent = outlineItem.parent
- let index = NSInteger(parent!.outline.index) + 1
- parent = parent?.parent
- if parent != nil {
- self.moveOutline(outlineItem: outlineItem, index: index, parent: parent)
- }
- }
- }
-
- @objc func demoteItemAction() {
- if self.BOTAOutlineView.outlineView.clickedRow >= 0 {
- let outlineItem: KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow: self.BOTAOutlineView.outlineView.clickedRow) as! KMBOTAOutlineItem
- let parent = outlineItem.parent
- let newParent = parent?.children[Int(outlineItem.outline.index) - 1]
- let index = newParent?.children.count
- if (index != nil) {
- self.moveOutline(outlineItem: outlineItem, index: NSInteger(index ?? 0), parent: newParent)
- }
- }
- }
-
- @objc private func expandAllComments(item: NSMenuItem) {
- self.BOTAOutlineView.expandAllComments(item: item)
- }
-
- @objc private func collapseAllComments(item: NSMenuItem) {
-
- self.BOTAOutlineView.collapseAllComments(item: item)
- }
-
- @objc private func removeAllOutlineItem(item: NSMenuItem) {
- let alter = NSAlert()
- alter.alertStyle = NSAlert.Style.informational
- alter.messageText = NSLocalizedString("This will permanently remove all outlines. Are you sure to continue?", comment: "")
- alter.addButton(withTitle: NSLocalizedString("Yes", comment:""))
- alter.addButton(withTitle: NSLocalizedString("No", comment:""))
- let modlres = alter.runModal()
- if modlres == NSApplication.ModalResponse.alertFirstButtonReturn {
- self.removeAllOutline()
- }
- }
-
-
- @objc private func removeAllOutline() {
- guard let data = self.BOTAOutlineView.data else { return }
-
- for item in data.children {
- item.toIndex = Int(item.outline.index)
- }
- self.deleteOutline(outlineItems: data.children)
- self.BOTAOutlineView.reloadData(expandItemType: .none)
- }
-
- @objc private func _searchAction() {
- _showHeaderSearch()
- }
- }
- //MARK: - Action
- extension KMOutlineViewController {
- @IBAction func addNewOutline(_ sender: Any) {
- self.addItemAction()
- }
-
-
- @IBAction func escButtonAction(_ sender: Any) {
- self.cancelSelect()
- }
-
- func cancelSelect() {
- self.BOTAOutlineView.cancelSelect()
- }
-
- func renameOutlineWithRow(row: NSInteger) {
- DispatchQueue.main.async {
- self.renamePDFOutline = self.BOTAOutlineView.outlineView.item(atRow: row) as? KMBOTAOutlineItem
- let cell : KMBOTAOutlineCellView = self.BOTAOutlineView.outlineView.view(atColumn: 0, row: row, makeIfNecessary: true) as! KMBOTAOutlineCellView
- self.renameTextField = cell.titleLabel
- self.renameTextField.delegate = self
- self.renameTextField.isEditable = true
- self.renameTextField.becomeFirstResponder()
- }
- }
-
- func addOutlineToIndex(index: Int, parent: KMBOTAOutlineItem?) {
- let pageIndex = self.handdler.currentPageIndex
- let label = self.fetchCurrentLabel(pageIndex: pageIndex)
- let destination = self.handdler.currentDestination()
-
- self.addOutlineToIndex(index: index, pageIndex: pageIndex, destination: destination, lable: label, parent: parent)
- }
-
- func addOutlineToIndex(index: Int, pageIndex: Int, destination: CPDFDestination?, lable: String, parent: KMBOTAOutlineItem?) {
- let outlineItem = KMBOTAOutlineItem()
- outlineItem.destination = destination
- outlineItem.label = lable
- outlineItem.parent = parent
- outlineItem.toIndex = index
- self.addOutline(outlineItems: [outlineItem])
-
- let tempOutlineView = self.BOTAOutlineView!
- var index = -1
- if tempOutlineView.outlineView.numberOfRows == 1 || tempOutlineView.data == nil {
- index = 0
- } else {
- index = tempOutlineView.outlineView.row(forItem: outlineItem)
- }
- tempOutlineView.selectIndex(index: index)
- //滑动到指定位置
- if(tempOutlineView.outlineView.selectedRow >= 0) {
- self.renameOutlineWithRow(row: tempOutlineView.outlineView.selectedRow)
- }
- let row = tempOutlineView.outlineView.row(forItem: outlineItem)
- if Thread.current.isMainThread {
- tempOutlineView.outlineView.scrollToVisible(tempOutlineView.outlineView.rect(ofRow: row))
- } else {
- DispatchQueue.main.async {
- tempOutlineView.outlineView.scrollToVisible(tempOutlineView.outlineView.rect(ofRow: row))
- }
- }
- }
-
- func updateOutlineSelection() {
- let currentPageIndex = self.handdler.currentPageIndex
- let numRows = self.BOTAOutlineView.outlineView.numberOfRows
- if numRows > 0 {
- for i in 0...numRows - 1 {
- let outlineItem: KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow: i) as! KMBOTAOutlineItem
- if (outlineItem.outline.destination == nil) {
- continue
- }
-
- if outlineItem.outline.destination.pageIndex == currentPageIndex {
- self.BOTAOutlineView.selectIndex(index: currentPageIndex)
- break
- }
- }
- }
- }
-
- // func fetchCurrentDestination() -> CPDFDestination {
- // //destination
- // var destination: CPDFDestination
- // let pageIndex: Int
- // if self.listView.currentSelection != nil {
- // let des :CPDFDestination = CPDFDestination.init(document: self.listView.document, pageIndex: Int(self.listView.currentSelection.page.pageIndex()), at: CGPoint(x: self.listView.currentSelection.bounds.origin.x, y: self.listView.currentSelection.bounds.origin.y + self.listView.currentSelection.bounds.size.height), zoom: self.listView.scaleFactor)
- // destination = des
- // pageIndex = Int(self.listView.currentSelection.page.pageIndex())
- // } else {
- // let des :CPDFDestination = CPDFDestination.init(document: self.listView.document, pageIndex: Int(self.listView.currentPageIndex), at: CGPoint(x: 0, y: self.listView.currentPage().size.height), zoom: self.listView.scaleFactor)
- // destination = des
- // pageIndex = Int(self.listView.currentPageIndex)
- // }
- //
- // if "\(destination.point.x )" == "nan" {
- // destination = CPDFDestination(document: self.listView.document, pageIndex: pageIndex, at: CGPoint(x: 0, y: 0), zoom: self.listView.scaleFactor)
- // }
- // return destination
- // }
-
- func fetchCurrentLabel(pageIndex: Int) -> String {
- var label = "\(NSLocalizedString("Page", comment: ""))\(pageIndex + 1)"
- let currentSelection = self.handdler.currentSelection()
- if currentSelection != nil && currentSelection?.selectionsByLine != nil {
- for data in currentSelection?.selectionsByLine ?? [] {
- label = data.string() ?? ""
- }
- }
- return label
- }
- }
- //MARK: - KMBOTAOutlineViewDelegate
- extension KMOutlineViewController: KMBOTAOutlineViewDelegate {
- func BOTAOutlineView(_ outlineView: KMBOTAOutlineView, rightDidMoseDown: KMBOTAOutlineItem, event: NSEvent) {
- let row = outlineView.outlineView.row(forItem: rightDidMoseDown)
- if outlineView.outlineView.rowView(atRow: row, makeIfNecessary: false) != nil {
- let rowView = outlineView.outlineView.rowView(atRow: row, makeIfNecessary: false)
- self.addRightMenu(view: rowView!, event: event)
- }
- }
- func BOTAOutlineView(_ outlineView: KMBOTAOutlineView, didReloadData: KMBOTAOutlineItem) {
- self.updateExtempViewState()
- }
-
- func BOTAOutlineView(_ outlineView: KMBOTAOutlineView, didSelectItem: [KMBOTAOutlineItem]) {
- if self.BOTAOutlineView.outlineView.selectedRowIndexes.count == 1 {
- self.isLocalEvent = true
-
- let outlineItem: KMBOTAOutlineItem = self.BOTAOutlineView.outlineView.item(atRow:self.BOTAOutlineView.outlineView.selectedRow) as! KMBOTAOutlineItem
-
- if outlineItem.outline.destination != nil {
- if outlineItem.outline.destination.page() != nil {
- // self.listView.go(toTargetPoint: outlineItem.outline.destination.point, on: outlineItem.outline.destination.page() , at: .top)
- } else {
- let alter = NSAlert()
- alter.alertStyle = NSAlert.Style.informational
- alter.messageText = NSLocalizedString("The target page is invalid, please relocate it.", comment: "")
- alter.addButton(withTitle: NSLocalizedString("OK", comment:""))
- alter.beginSheetModal(for: self.view.window ?? NSWindow())
- }
- } else if outlineItem.outline.action != nil {
- let alter = NSAlert()
- alter.alertStyle = NSAlert.Style.informational
- alter.messageText = NSLocalizedString("The target page is invalid, please relocate it.", comment: "")
- alter.addButton(withTitle: NSLocalizedString("OK", comment:""))
- alter.beginSheetModal(for: self.view.window ?? NSWindow())
- // self.listView.perform(outlineItem.outline.action)
- }
- }
- }
-
- func BOTAOutlineView(_ outlineView: KMBOTAOutlineView, writeItems items: [Any], to pasteboard: NSPasteboard) -> Bool {
- if outlineView.outlineView.selectedRowIndexes.count > 1 || outlineView.outlineView.selectedRow == -1 {
- return false
- }
-
- self.dragPDFOutline = items.first as? KMBOTAOutlineItem
-
- let indexSet = [outlineView.outlineView.clickedRow]
- let indexSetData: Data = try!NSKeyedArchiver.archivedData(withRootObject: indexSet, requiringSecureCoding: true)
- pasteboard.declareTypes([NSPasteboard.PasteboardType(rawValue: "kKMPDFViewOutlineDragDataType")], owner: self)
- pasteboard.setData(indexSetData, forType: NSPasteboard.PasteboardType(rawValue: NSPasteboard.PasteboardType.RawValue("kKMPDFViewOutlineDragDataType")))
- return true
- }
-
- func BOTAOutlineView(_ outlineView: KMBOTAOutlineView, validateDrop info: NSDraggingInfo, proposedItem item: Any?, proposedChildIndex index: Int) -> NSDragOperation {
- var dragOperation = NSDragOperation.init(rawValue: 0)
- if index >= 0 {
- dragOperation = NSDragOperation.move
- }
- return dragOperation
- }
-
- func BOTAOutlineView(_ outlineView: KMBOTAOutlineView, acceptDrop info: NSDraggingInfo, item: Any?, childIndex index: Int) -> Bool {
- guard let dragOutlineItem = self.dragPDFOutline else { return false }
- let outlineItem: KMBOTAOutlineItem = (item ?? KMBOTAOutlineItem()) as! KMBOTAOutlineItem
- if index < 0 {
- return false
- }
-
- if outlineItem.parent == nil {
- var root = dragOutlineItem.parent
- while root?.parent?.children != nil {
- root = root?.parent!
- }
- if dragOutlineItem.parent!.isEqual(root) {
- if dragOutlineItem.outline.index > index {
- self.moveOutline(outlineItem: dragOutlineItem, index: index, parent: root)
- } else {
- self.moveOutline(outlineItem: dragOutlineItem, index: index - 1, parent: root)
- }
- } else {
- self.moveOutline(outlineItem: dragOutlineItem, index: index, parent: root)
- }
- } else {
- if dragOutlineItem.parent!.isEqual(item) {
- // if dragOutlineItem.outline.index != 0 {
- if dragOutlineItem.outline.index > index {
- self.moveOutline(outlineItem: dragOutlineItem, index: index, parent: item as? KMBOTAOutlineItem)
- } else {
- self.moveOutline(outlineItem: dragOutlineItem, index: index - 1, parent: item as? KMBOTAOutlineItem)
- }
- // } else {
- // return false
- // }
- } else {
- var tOutline = outlineItem
- var isContains = false
- while (tOutline.parent != nil) {
- if tOutline.outline.isEqual(dragOutlineItem.outline) {
- isContains = true
- break
- }
- tOutline = tOutline.parent!
- }
- if isContains == false {
- self.moveOutline(outlineItem: dragOutlineItem, index: index, parent: item as? KMBOTAOutlineItem)
- }
- }
- }
- self.BOTAOutlineView.selectItem(outlineItem: dragOutlineItem)
-
- return true
- }
- }
- //MARK: - NSTextFieldDelegate
- extension KMOutlineViewController: NSTextFieldDelegate {
- func controlTextDidEndEditing(_ obj: Notification) {
- if (self.renameTextField.isEqual(obj.object)) {
- let textField : NSTextField = obj.object as! NSTextField
- self.renamePDFOutline(outlineItem: self.renamePDFOutline, label: textField.stringValue)
- }
- }
- }
- //MARK: - NSPopoverDelegate
- extension KMOutlineViewController: NSPopoverDelegate {
- func popoverWillClose(_ notification: Notification) {
- let popover : NSPopover = notification.object as! NSPopover
- if popover.contentViewController!.isKind(of: KMOutlineEditViewController.self) {
-
- }
- }
-
- func popoverDidClose(_ notification: Notification) {
- if popover_ == (notification.object as? NSPopover) {
- popover_ = nil
- }
- }
- }
- //MARK: - NSMenuItemValidation
- extension KMOutlineViewController: NSMenuDelegate, NSMenuItemValidation {
- func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
- let action = menuItem.action
- if (action == #selector(undo)) {
- return handdler.canUndo()
- }
- if (action == #selector(redo)) {
- return handdler.canRedo()
- }
-
- return true
- }
- }
- // MARK: - KMNOutlineHanddlerDelegate
- extension KMOutlineViewController: KMNOutlineHanddlerDelegate {
- func handdler(_ handdler: KMNOutlineHanddler, didAdd info: [String : Any]?) {
- let tempOutlineItems = info?["data"] as? [KMBOTAOutlineItem] ?? []
-
- let tempOutlineView = self.BOTAOutlineView
- if tempOutlineView?.data?.children.count == 0 || tempOutlineView?.data == nil {
- tempOutlineView?.inputData = self.handdler.outlineRoot()
- } else {
- tempOutlineView?.outlineView.reloadData()
- }
-
- //展开
- // DispatchQueue.main.async {
- for outlineItem in tempOutlineItems {
- var tempParent = outlineItem
- while tempParent.parent != nil {
- tempParent.isItemExpanded = true
- tempParent = tempParent.parent!
- tempOutlineView?.outlineView.expandItem(tempParent)
- }
- tempOutlineView?.outlineView.expandItem(tempParent.parent)
- }
- // }
-
- self.updateExtempViewState()
- }
-
- func handdler(_ handdler: KMNOutlineHanddler, didRemove info: [String : Any]?) {
- let tempOutlineItems = info?["data"] as? [KMBOTAOutlineItem] ?? []
- let tempOutlineView = self.BOTAOutlineView
- //展开
- for outlineItem in tempOutlineItems {
- outlineItem.parent?.isItemExpanded = true
- tempOutlineView?.outlineView.expandItem(outlineItem.parent)
- }
-
- tempOutlineView?.outlineView.reloadData()
- //删除需要取消选中
- tempOutlineView?.cancelSelect()
-
- //刷新nil数据
- self.updateExtempViewState()
- }
-
- func handdler(_ handdler: KMNOutlineHanddler, didRename outline: CPDFOutline?, info: [String : Any]?) {
- let outlineItem = info?["data"] as? KMBOTAOutlineItem
- let tempOutlineView = self.BOTAOutlineView
-
- tempOutlineView?.outlineView.reloadItem(outlineItem)
- }
-
- func handdler(_ handdler: KMNOutlineHanddler, didChangeLocation outline: CPDFOutline?, info: [String : Any]?) {
- let outlineItem = info?["data"] as? KMBOTAOutlineItem
- let tempOutlineView = self.BOTAOutlineView
-
- tempOutlineView?.outlineView.reloadItem(outlineItem)
- }
-
- func handdler(_ handdler: KMNOutlineHanddler, didMove outline: CPDFOutline?, info: [String : Any]?) {
- guard let outlineItem = info?["data"] as? KMBOTAOutlineItem else {
- return
- }
-
- let parent = info?["parent"] as? KMBOTAOutlineItem
- let tempOutlineView = self.BOTAOutlineView
- let index = info?["index"] as? Int ?? 0
-
- //显示数据刷新
- outlineItem.parent?.children.removeObject(outlineItem)
- parent?.children.insert(outlineItem, at: index)
- outlineItem.parent = parent
- tempOutlineView?.outlineView.reloadData()
- tempOutlineView?.cancelSelect()
-
- //展开
- outlineItem.isItemExpanded = true
- outlineItem.parent?.isItemExpanded = true
- tempOutlineView?.outlineView.expandItem(outlineItem)
- tempOutlineView?.outlineView.expandItem(outlineItem.parent)
- }
- }
- //MARK: - 快捷键
- extension KMOutlineViewController {
- @IBAction func delete(_ sender: Any) {
- self.deleteItemAction()
- }
- }
- //MARK: - undoRedo
- extension KMOutlineViewController {
- func moveOutline(outlineItem: KMBOTAOutlineItem, index: NSInteger, parent: KMBOTAOutlineItem!) {
- handdler.moveOutline(outlineItem: outlineItem, index: index, parent: parent)
- }
-
- func changeLocation(outlineItem: KMBOTAOutlineItem, destination: CPDFDestination) {
- handdler.changeLocation(outlineItem: outlineItem, destination: destination)
- }
-
- func renamePDFOutline(outlineItem: KMBOTAOutlineItem!, label: String) {
- let tempOutlineView = self.BOTAOutlineView!
-
- self.view.window?.makeFirstResponder(tempOutlineView.outlineView)
- self.renameTextField.isEditable = false
- if outlineItem.outline.label == label {
- return
- }
- handdler.renamePDFOutline(outlineItem: outlineItem, label: label)
- }
-
- func deleteOutline(outlineItems: [KMBOTAOutlineItem]) {
- NSApp.mainWindow?.makeFirstResponder(self.BOTAOutlineView)
- let tempOutlineView = self.BOTAOutlineView!
-
- handdler.deleteOutline(outlineItems: outlineItems)
- }
-
- func addOutline(outlineItems: [KMBOTAOutlineItem]) {
- NSApp.mainWindow?.makeFirstResponder(self.BOTAOutlineView)
- let tempOutlineView = self.BOTAOutlineView!
- //先取消选中
- tempOutlineView.cancelSelect()
-
- var tempOutlineItems: [KMBOTAOutlineItem] = outlineItems
- tempOutlineItems.sort(){$0.toIndex < $1.toIndex}
-
- handdler.addOutline(outlineItems: tempOutlineItems)
- }
-
- @IBAction func undo(_ sender: Any) {
- handdler.undo()
- }
-
- @IBAction func redo(_ sender: Any) {
- handdler.redo()
- }
- }
- //MARK: - ComponentDropdownDelegate
- extension KMOutlineViewController: ComponentDropdownDelegate {
- func componentDropdownDidShowMenuItem(dropdown: ComponentDropdown) {
- showGroupView()
- }
- }
- //MARK: - ComponentGroupDelegate
- extension KMOutlineViewController: ComponentGroupDelegate {
- func componentGroupDidDismiss(group: ComponentGroup?) {
- if group == groupView_ {
- removeGroupView()
- } else if group == menuGroupView_ {
- group?.removeFromSuperview()
- menuGroupView_ = nil
- } else if group == searchGroupView_ {
- // searchGroupView_ = nil
- searchGroupTarget_?.properties.state = .normal
- searchGroupTarget_?.reloadData()
- searchGroupTarget_ = nil
- }
- }
-
- func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
- if group == groupView_ {
- if let selItem = menuItemProperty {
- let index = group?.menuItemArr.firstIndex(of: selItem)
- if index == 0 {
- expandAllComments(item: NSMenuItem())
- } else if index == 1 {
- collapseAllComments(item: NSMenuItem())
- } else if index == 2 {
- removeAllOutlineItem(item: NSMenuItem())
- }
- }
- } else if group == menuGroupView_ {
- if let selItem = menuItemProperty {
- let index = group?.menuItemArr.firstIndex(of: selItem)
- if index == 0 {
- addItemAction()
- } else if index == 1 {
- addChildItemAction()
- } else if index == 2 {
- addHigherItemAction()
- } else if index == 4 {
- deleteItemAction()
- } else if index == 6 {
- group?.removeFromSuperview()
-
- editItemAction()
- } else if index == 7 {
- renameItemAction()
- } else if index == 8 {
- changeItemAction()
- } else if index == 10 {
- promoteItemAction()
- } else if index == 11 {
- demoteItemAction()
- }
-
- group?.removeFromSuperview()
- }
- } else if group == searchGroupView_ {
- guard let menuI = menuItemProperty else {
- return
- }
- let idx = group?.menuItemArr.firstIndex(of: menuI)
- if idx == 0 {
- let key = KMNSearchKey.wholeWords.outline
- let value = KMDataManager.ud_bool(forKey: key)
- KMDataManager.ud_set(!value, forKey: key)
-
- BOTAOutlineView.wholeWords = !value
- } else if idx == 1 {
- let key = KMNSearchKey.caseSensitive.outline
- let value = KMDataManager.ud_bool(forKey: key)
- KMDataManager.ud_set(!value, forKey: key)
-
- BOTAOutlineView.caseSensitive = !value
- }
- }
- }
- }
|