服务器面板可多选删除

This commit is contained in:
秦宇航
2017-04-15 08:56:01 +08:00
parent ceeeb6892f
commit 1112ae9c23
@@ -93,6 +93,7 @@ class PreferencesWindowController: NSWindowController
override func awakeFromNib() {
profilesTableView.register(forDraggedTypes: [tableViewDragType])
profilesTableView.allowsMultipleSelection = true
}
@IBAction func addProfile(_ sender: NSButton) {
@@ -115,11 +116,14 @@ class PreferencesWindowController: NSWindowController
}
@IBAction func removeProfile(_ sender: NSButton) {
let index = profilesTableView.selectedRow
let index = Int(profilesTableView.selectedRowIndexes.first!)
if index >= 0 {
profilesTableView.beginUpdates()
profileMgr.profiles.remove(at: index)
profilesTableView.removeRows(at: IndexSet(integer: index), withAnimation: .effectFade)
for (_, _) in profilesTableView.selectedRowIndexes.enumerated() {
print(profileMgr.profiles.count)
profileMgr.profiles.remove(at: index)
profilesTableView.removeRows(at: IndexSet(integer: index), withAnimation: .effectFade)
}
profilesTableView.endUpdates()
}
self.profilesTableView.scrollRowToVisible(index)