class: SelectionInListView
added: #checkRemovingSelectionFrom:to:
changed:
#checkRemovingSelection:
#removeFromIndex:toIndex:
faster remove of a line range (selection update tuned)
--- a/SelectionInListView.st Fri Nov 23 16:43:09 2012 +0100
+++ b/SelectionInListView.st Mon Nov 26 14:16:27 2012 +0100
@@ -1553,7 +1553,7 @@
].
].
- endLineNr to:startLineNr by:-1 do:[:eachIndex | self checkRemovingSelection:eachIndex].
+ self checkRemovingSelectionFrom:startLineNr to:endLineNr.
oldSelection ~= selection ifTrue:[
"/ cannot keep the selection (items removed)
"/ must tell the model if there is one ....
@@ -2971,16 +2971,22 @@
checkRemovingSelection:lineNr
"when a line is removed, we have to adjust selection"
+ self checkRemovingSelectionFrom:lineNr to:lineNr
+!
+
+checkRemovingSelectionFrom:startNr to:endNr
+ "when a range of lines is removed, we have to adjust the selection"
+
|newSelection|
selection notNil ifTrue:[
self multipleSelectOk ifTrue:[
newSelection := OrderedCollection new.
selection do:[:sel |
- sel < lineNr ifTrue:[
+ sel < startNr ifTrue:[
newSelection add:sel
] ifFalse:[
- sel > lineNr ifTrue:[
+ sel > endNr ifTrue:[
newSelection add:(sel - 1)
]
"otherwise remove it from the selection"
@@ -2992,10 +2998,10 @@
selection := newSelection
]
] ifFalse:[
- selection == lineNr ifTrue:[
+ (selection between:startNr and:endNr) ifTrue:[
selection := nil
] ifFalse:[
- selection > lineNr ifTrue:[
+ selection > endNr ifTrue:[
selection := selection - 1
]
]
@@ -4103,9 +4109,9 @@
!SelectionInListView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.260 2012-11-23 15:43:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.261 2012-11-26 13:16:27 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.260 2012-11-23 15:43:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.261 2012-11-26 13:16:27 cg Exp $'
! !