From f356cd2d5c3bf741e0762caf255c06bc4c86eafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Sat, 15 Apr 2017 09:03:42 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=8F=AF=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowsocksX-NG/PreferencesWindowController.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 9cb0ddb..5957831 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -107,6 +107,7 @@ class PreferencesWindowController: NSWindowController override func awakeFromNib() { profilesTableView.register(forDraggedTypes: [tableViewDragType]) + profilesTableView.allowsMultipleSelection = true } @IBAction func addProfile(_ sender: NSButton) { @@ -129,11 +130,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() } updateProfileBoxVisible() From 3df85772b016726a7cc62f3515eb499650b5c7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Sat, 15 Apr 2017 09:10:42 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=BF=9E?= =?UTF-8?q?=E7=BB=AD=E5=A4=9A=E9=80=89=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowsocksX-NG/PreferencesWindowController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 5957831..a4f3082 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -131,12 +131,14 @@ class PreferencesWindowController: NSWindowController @IBAction func removeProfile(_ sender: NSButton) { let index = Int(profilesTableView.selectedRowIndexes.first!) + var deleteCount = 0 if index >= 0 { profilesTableView.beginUpdates() - for (_, _) in profilesTableView.selectedRowIndexes.enumerated() { + for (_, toDeleteIndex) in profilesTableView.selectedRowIndexes.enumerated() { print(profileMgr.profiles.count) - profileMgr.profiles.remove(at: index) - profilesTableView.removeRows(at: IndexSet(integer: index), withAnimation: .effectFade) + profileMgr.profiles.remove(at: toDeleteIndex - deleteCount) + profilesTableView.removeRows(at: IndexSet(integer: toDeleteIndex - deleteCount), withAnimation: .effectFade) + deleteCount += 1 } profilesTableView.endUpdates() } From f6a46311c39a1ef9807aa69b8d550a6837be0010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Sat, 15 Apr 2017 22:40:25 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E9=85=8D=E7=BD=AE=E5=90=8E=E6=BB=9A=E5=8A=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowsocksX-NG/PreferencesWindowController.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index a4f3082..b8deeb2 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -142,6 +142,8 @@ class PreferencesWindowController: NSWindowController } profilesTableView.endUpdates() } + self.profilesTableView.scrollRowToVisible(index-1) + self.profilesTableView.selectRowIndexes(IndexSet(integer: index-1), byExtendingSelection: false) updateProfileBoxVisible() } 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 4/5] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=9C=A8=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E7=8A=B6=E6=80=81=E4=B8=8B=E7=9A=84=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?profile=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() } From efd0c767631746219875d6cb4a0eddeec0ea5d9a 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 17:24:11 +0800 Subject: [PATCH 5/5] =?UTF-8?q?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 923aad5d94d9ad0920d8a18a7863a56545d89f91. --- .../PreferencesWindowController.swift | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 883af37..b8deeb2 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -168,23 +168,16 @@ class PreferencesWindowController: NSWindowController } @IBAction func duplicate(_ sender: Any) { - 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 - } + 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() updateProfileBoxVisible() }