mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-28 08:13:17 +03:00
Use binding
This commit is contained in:
parent
5d09f96370
commit
6b2a9080fe
@ -12,7 +12,7 @@ class OpenQuicklyWindow: NSObject,
|
|||||||
UiComponent,
|
UiComponent,
|
||||||
NSWindowDelegate,
|
NSWindowDelegate,
|
||||||
NSTextFieldDelegate,
|
NSTextFieldDelegate,
|
||||||
NSTableViewDelegate, NSTableViewDataSource {
|
NSTableViewDelegate {
|
||||||
|
|
||||||
typealias StateType = AppState
|
typealias StateType = AppState
|
||||||
|
|
||||||
@ -81,8 +81,9 @@ class OpenQuicklyWindow: NSObject,
|
|||||||
|
|
||||||
// FIXME: migrate to State later...
|
// FIXME: migrate to State later...
|
||||||
private(set) var pattern = ""
|
private(set) var pattern = ""
|
||||||
private(set) var fileViewItems = [ScoredFileItem]()
|
@objc private(set) var fileViewItems = [ScoredUrl]()
|
||||||
private var count = 0
|
private var count = 0
|
||||||
|
private let fileViewItemsController = NSArrayController()
|
||||||
|
|
||||||
private let windowController: NSWindowController
|
private let windowController: NSWindowController
|
||||||
|
|
||||||
@ -110,7 +111,17 @@ class OpenQuicklyWindow: NSObject,
|
|||||||
|
|
||||||
let fileView = self.fileView
|
let fileView = self.fileView
|
||||||
fileView.intercellSpacing = CGSize(width: 4, height: 4)
|
fileView.intercellSpacing = CGSize(width: 4, height: 4)
|
||||||
fileView.dataSource = self
|
|
||||||
|
let c = self.fileViewItemsController
|
||||||
|
c.avoidsEmptySelection = false
|
||||||
|
c.preservesSelection = true
|
||||||
|
c.objectClass = ScoredUrl.self
|
||||||
|
c.sortDescriptors = [NSSortDescriptor(key: "score", ascending: false)]
|
||||||
|
c.automaticallyRearrangesObjects = true
|
||||||
|
c.bind(.contentArray, to: self, withKeyPath: "fileViewItems")
|
||||||
|
|
||||||
|
fileView.bind(.content, to: c, withKeyPath: "arrangedObjects")
|
||||||
|
fileView.bind(.selectionIndexes, to: c, withKeyPath: "selectionIndexes")
|
||||||
fileView.delegate = self
|
fileView.delegate = self
|
||||||
|
|
||||||
let fileScrollView = NSScrollView.standardScrollView()
|
let fileScrollView = NSScrollView.standardScrollView()
|
||||||
@ -163,15 +174,6 @@ class OpenQuicklyWindow: NSObject,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - NSTableViewDataSource
|
|
||||||
extension OpenQuicklyWindow {
|
|
||||||
|
|
||||||
@objc(numberOfRowsInTableView:)
|
|
||||||
func numberOfRows(in _: NSTableView) -> Int {
|
|
||||||
return self.fileViewItems.count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - NSTableViewDelegate
|
// MARK: - NSTableViewDelegate
|
||||||
extension OpenQuicklyWindow {
|
extension OpenQuicklyWindow {
|
||||||
|
|
||||||
@ -179,7 +181,7 @@ extension OpenQuicklyWindow {
|
|||||||
return OpenQuicklyFileViewRow()
|
return OpenQuicklyFileViewRow()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc(tableView: viewForTableColumn:row:)
|
@objc(tableView:viewForTableColumn:row:)
|
||||||
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
|
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
|
||||||
let cachedCell = (tableView.makeView(
|
let cachedCell = (tableView.makeView(
|
||||||
withIdentifier: NSUserInterfaceItemIdentifier("file-view-row"), owner: self) as? ImageAndTextTableCell
|
withIdentifier: NSUserInterfaceItemIdentifier("file-view-row"), owner: self) as? ImageAndTextTableCell
|
||||||
@ -216,7 +218,7 @@ extension OpenQuicklyWindow {
|
|||||||
// MARK: - NSTextFieldDelegate
|
// MARK: - NSTextFieldDelegate
|
||||||
extension OpenQuicklyWindow {
|
extension OpenQuicklyWindow {
|
||||||
|
|
||||||
@objc(control: textView:doCommandBySelector:)
|
@objc(control:textView:doCommandBySelector:)
|
||||||
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||||
switch commandSelector {
|
switch commandSelector {
|
||||||
case NSSelectorFromString("cancelOperation:"):
|
case NSSelectorFromString("cancelOperation:"):
|
||||||
|
Loading…
Reference in New Issue
Block a user