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