@ -168,23 +168,16 @@ class PreferencesWindowController: NSWindowController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func duplicate(_ sender: Any) {
|
@IBAction func duplicate(_ sender: Any) {
|
||||||
var copyCount = 0
|
let profile = profileMgr.profiles[profilesTableView.clickedRow]
|
||||||
for (_, toDuplicateIndex) in profilesTableView.selectedRowIndexes.enumerated() {
|
let duplicateProfile = profile.copy() as! ServerProfile
|
||||||
print(profileMgr.profiles.count)
|
duplicateProfile.uuid = UUID().uuidString
|
||||||
let profile = profileMgr.profiles[toDuplicateIndex + copyCount]
|
profileMgr.profiles.insert(duplicateProfile, at: profilesTableView.clickedRow+1)
|
||||||
let duplicateProfile = profile.copy() as! ServerProfile
|
profilesTableView.beginUpdates()
|
||||||
duplicateProfile.uuid = UUID().uuidString
|
let index = IndexSet(integer: profileMgr.profiles.count-1)
|
||||||
profileMgr.profiles.insert(duplicateProfile, at:toDuplicateIndex + copyCount)
|
profilesTableView.insertRows(at: index, withAnimation: .effectFade)
|
||||||
|
self.profilesTableView.scrollRowToVisible(profilesTableView.clickedRow+1)
|
||||||
profilesTableView.beginUpdates()
|
self.profilesTableView.selectRowIndexes(index, byExtendingSelection: false)
|
||||||
let index = IndexSet(integer: toDuplicateIndex + copyCount)
|
profilesTableView.endUpdates()
|
||||||
profilesTableView.insertRows(at: index, withAnimation: .effectFade)
|
|
||||||
self.profilesTableView.scrollRowToVisible(toDuplicateIndex + copyCount)
|
|
||||||
self.profilesTableView.selectRowIndexes(index, byExtendingSelection: false)
|
|
||||||
profilesTableView.endUpdates()
|
|
||||||
|
|
||||||
copyCount += 1
|
|
||||||
}
|
|
||||||
updateProfileBoxVisible()
|
updateProfileBoxVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user