From e8e4f9ad11a4b72b831eb245d352a3db4afc2549 Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Thu, 20 Jul 2017 15:09:54 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"=E5=AE=9E=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E7=8A=B6=E6=80=81=E4=B8=8B=E7=9A=84=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAprofile=E5=A4=8D=E5=88=B6""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit efd0c767631746219875d6cb4a0eddeec0ea5d9a. --- .../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() }