CtlCandidateTDK // Add isFilterable().
This commit is contained in:
parent
d386a93784
commit
5a8303a45f
|
@ -232,6 +232,16 @@ public extension CandidatePool {
|
||||||
}
|
}
|
||||||
return (min, nil)
|
return (min, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isFilterable(target index: Int) -> Bool {
|
||||||
|
let spanLength = candidateDataAll[index].spanLength
|
||||||
|
guard spanLength == 1 else { return true }
|
||||||
|
return cellsOf(spanLength: spanLength).count > 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func cellsOf(spanLength: Int) -> [CandidateCellData] {
|
||||||
|
candidateDataAll.filter { $0.spanLength == spanLength }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Privates.
|
// MARK: - Privates.
|
||||||
|
|
|
@ -333,6 +333,7 @@ private extension VwrCandidateTDKCocoa {
|
||||||
var theMenu: NSMenu?
|
var theMenu: NSMenu?
|
||||||
|
|
||||||
private func prepareMenu() {
|
private func prepareMenu() {
|
||||||
|
guard let thePool = (target as? VwrCandidateTDKCocoa)?.thePool else { return }
|
||||||
let newMenu = NSMenu()
|
let newMenu = NSMenu()
|
||||||
let boostMenuItem = NSMenuItem(
|
let boostMenuItem = NSMenuItem(
|
||||||
title: "↑ \(cellData.displayedText)",
|
title: "↑ \(cellData.displayedText)",
|
||||||
|
@ -350,9 +351,7 @@ private extension VwrCandidateTDKCocoa {
|
||||||
nerfMenuItem.target = self
|
nerfMenuItem.target = self
|
||||||
newMenu.addItem(nerfMenuItem)
|
newMenu.addItem(nerfMenuItem)
|
||||||
|
|
||||||
if let dataAll = (target as? VwrCandidateTDKCocoa)?.thePool.candidateDataAll,
|
if thePool.isFilterable(target: cellData.index) {
|
||||||
dataAll.count > cellData.index, dataAll[cellData.index].spanLength > 1
|
|
||||||
{
|
|
||||||
let filterMenuItem = NSMenuItem(
|
let filterMenuItem = NSMenuItem(
|
||||||
title: "✖︎ \(cellData.displayedText)",
|
title: "✖︎ \(cellData.displayedText)",
|
||||||
action: #selector(menuActionOfFiltering(_:)),
|
action: #selector(menuActionOfFiltering(_:)),
|
||||||
|
|
|
@ -168,9 +168,7 @@ extension VwrCandidateTDK {
|
||||||
} label: {
|
} label: {
|
||||||
Text("↓ " + cell.displayedText)
|
Text("↓ " + cell.displayedText)
|
||||||
}
|
}
|
||||||
if thePool.candidateDataAll.count > cell.index,
|
if thePool.isFilterable(target: cell.index) {
|
||||||
thePool.candidateDataAll[cell.index].spanLength > 1
|
|
||||||
{
|
|
||||||
Button {
|
Button {
|
||||||
didRightClickCandidateAt(cell.index, action: .toFilter)
|
didRightClickCandidateAt(cell.index, action: .toFilter)
|
||||||
} label: {
|
} label: {
|
||||||
|
|
Loading…
Reference in New Issue