sortable
authorClaus Gittinger <cg@exept.de>
Mon, 19 Oct 2009 14:20:06 +0200
changeset 3773 c4fcafeada43
parent 3772 7875f39d446d
child 3774 60cc6d68cc3a
sortable
DSVColumnView.st
--- a/DSVColumnView.st	Mon Oct 19 13:22:49 2009 +0200
+++ b/DSVColumnView.st	Mon Oct 19 14:20:06 2009 +0200
@@ -1062,10 +1062,10 @@
     ^ list
 !
 
-list:aList
+list:aRawList
     "set the list of rows"
 
-    |selectionHasChanged|
+    |newList selectionHasChanged sortColNr sortSelectorOrBlock|
 
     "/ remove selection without redraw
 
@@ -1079,7 +1079,7 @@
     shown ifFalse:[
         cachedPreferredExtent := nil
     ] ifTrue:[
-        aList size == 0 ifTrue:[  
+        aRawList size == 0 ifTrue:[  
             "/ keep old column-width information
         ] ifFalse:[
             columnDescriptors notNil ifTrue:[
@@ -1093,13 +1093,27 @@
         self makeIndependentOfRows
     ].
 
-    aList size == 0 ifTrue:[
+    aRawList size == 0 ifTrue:[
         list := nil.
         viewOrigin := 0 @ 0.
     ] ifFalse:[
-        list := OrderedCollection withAll:aList.
-"/        list := OrderedCollection new:(aList size).
-"/        aList do:[:el| list add:el ].
+        "/ list := OrderedCollection withAll:aRawList.
+        newList := aRawList copyAsOrderedCollection.
+        (sortColNr := labelView indexOfSortColumn) notNil ifTrue:[
+            sortSelectorOrBlock := (columnDescriptors at:sortColNr) sortSelector.
+            sortSelectorOrBlock notNil ifTrue:[
+                sortSelectorOrBlock isBlock ifTrue:[
+                    newList sort:sortSelectorOrBlock
+                ] ifFalse:[
+                    newList sort:[:a :b | (a perform:sortSelectorOrBlock) < (b perform:sortSelectorOrBlock)]
+                ].
+            ].
+            labelView reverseSort ifTrue:[
+                newList reverse.
+            ].
+        ].
+        list := newList.
+
         beDependentOfRows ifTrue:[
             self makeDependentOfRows
         ].
@@ -1556,6 +1570,7 @@
         self updateColumnFromEditValue.
         ^ self
     ].
+
     chgObj == model ifTrue:[
         (what == #selectionIndex or:[ what == #selection ]) ifTrue:[
             self selectRowIndex:(model selectionIndex copy). 
@@ -1577,11 +1592,13 @@
         ].
         ^ self
     ].
+
     chgObj == listHolder ifTrue:[
         cachedPreferredExtent := nil.
         listHoldersList := listHolder value.
         what == #value ifTrue:[
-            self list:listHoldersList. ^ self. 
+            self list:listHoldersList.  
+            ^ self. 
         ].
         aPara isCollection ifTrue:[
             arg1 := aPara at:1.
@@ -1618,10 +1635,8 @@
         ].
         what == #replace: ifTrue:[
             self 
-                replaceFrom:arg1
-                to:arg2
-                with:listHoldersList
-                startingAt:arg1.
+                replaceFrom:arg1 to:arg2
+                with:listHoldersList startingAt:arg1.
             ^ self
         ].
         self list:listHoldersList.
@@ -1702,6 +1717,17 @@
                 ]
             ]
     ].
+!
+
+updateList
+    listHolder notNil ifTrue:[
+        self list:listHolder value.
+        ^ self
+    ].
+    model notNil ifTrue:[
+        self list:model value.
+        ^ self
+    ].
 ! !
 
 !DSVColumnView methodsFor:'drag & drop'!
@@ -4079,7 +4105,7 @@
     rowIdx isSequenceable ifTrue:[
         rowIdx := rowIdx at:1 ifAbsent:[ ^ self ].
     ].
-    editSpec := column specForEditorAt:rowIdx.
+    editSpec := column editorSpecForRowAt:rowIdx.
     editSpec isNil ifTrue:[^ self].
 
     autoScrollToColumn == true ifTrue:[
@@ -4122,6 +4148,10 @@
     ].
     editView realize.
     editor canTab:true.
+    "/ what a hack...
+    (editor isKindOf:ComboListView) ifTrue:[
+        editor pullMenu.
+    ].
     winGroup focusView:editor.
 
     self processAllExposeEvents.
@@ -4564,9 +4594,9 @@
 !DSVColumnView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.251 2009-10-19 09:28:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.252 2009-10-19 12:20:06 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.251 2009-10-19 09:28:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.252 2009-10-19 12:20:06 cg Exp $'
 ! !