From 923aad5d94d9ad0920d8a18a7863a56545d89f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Mon, 24 Apr 2017 15:36:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=9C=A8=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E7=9A=84=E5=A4=9A=E4=B8=AAprofile?= =?UTF-8?q?=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PreferencesWindowController.swift | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index b8deeb2..883af37 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -168,16 +168,23 @@ class PreferencesWindowController: NSWindowController } @IBAction func duplicate(_ sender: Any) { - let profile = profileMgr.profiles[profilesTableView.clickedRow] - let duplicateProfile = profile.copy() as! ServerProfile - duplicateProfile.uuid = UUID().uuidString - profileMgr.profiles.insert(duplicateProfile, at: profilesTableView.clickedRow+1) - profilesTableView.beginUpdates() - let index = IndexSet(integer: profileMgr.profiles.count-1) - profilesTableView.insertRows(at: index, withAnimation: .effectFade) - self.profilesTableView.scrollRowToVisible(profilesTableView.clickedRow+1) - self.profilesTableView.selectRowIndexes(index, byExtendingSelection: false) - profilesTableView.endUpdates() + var copyCount = 0 + for (_, toDuplicateIndex) in profilesTableView.selectedRowIndexes.enumerated() { + print(profileMgr.profiles.count) + let profile = profileMgr.profiles[toDuplicateIndex + copyCount] + let duplicateProfile = profile.copy() as! ServerProfile + duplicateProfile.uuid = UUID().uuidString + profileMgr.profiles.insert(duplicateProfile, at:toDuplicateIndex + copyCount) + + profilesTableView.beginUpdates() + let index = IndexSet(integer: toDuplicateIndex + copyCount) + profilesTableView.insertRows(at: index, withAnimation: .effectFade) + self.profilesTableView.scrollRowToVisible(toDuplicateIndex + copyCount) + self.profilesTableView.selectRowIndexes(index, byExtendingSelection: false) + profilesTableView.endUpdates() + + copyCount += 1 + } updateProfileBoxVisible() }