Modify

Opened 13 years ago

Closed 12 years ago

#1930 closed Feature Request (Rejected)

_GUICtrlListView_SimpleSort doesn't sort ItemParam

Reported by: BugFix Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

With new Beta _GUICtrlListView_SimpleSort sorts checkboxes too, but association between item and ItemParam are lost by sort.
I've changed this function, so that it also sort ItemParam. Would nice to have this feature generally.

Func _GUICtrlListView_SimpleSort($hWnd, ByRef $vDescending, $iCol)

If $Debug_LV Then UDF_ValidateClassName($hWnd, $LISTVIEWCONSTANT_ClassName)

If _GUICtrlListView_GetItemCount($hWnd) Then

Local $b_desc
If (IsArray($vDescending)) Then

$b_desc = $vDescending[$iCol]

Else

$b_desc = $vDescending

EndIf
Local $columns = _GUICtrlListView_GetColumnCount($hWnd)
Local $items = _GUICtrlListView_GetItemCount($hWnd)
Local $temp_item = ""
Local $SeparatorChar = Opt('GUIDataSeparatorChar')
For $x = 1 To $columns

$temp_item = $temp_item & " " & $SeparatorChar

Next
$temp_item = StringTrimRight($temp_item, 1)

;~ Local $a_lv[$items][$columns + 1]

Local $a_lv[$items][$columns + 2], $i_selected ; add column for ItemParam ### MODIFIED ###
Local $i_selected = StringSplit(_GUICtrlListView_GetSelectedIndices($hWnd), $SeparatorChar)
Local $i_checked = StringSplit(GUICtrlListView_GetCheckedIndices($hWnd), $SeparatorChar)
Local $v_item, $iFocused = -1
For $x = 0 To UBound($a_lv) - 1 Step 1

If $iFocused = -1 Then

If _GUICtrlListView_GetItemFocused($hWnd, $x) Then $iFocused = $x

EndIf
_GUICtrlListView_SetItemSelected($hWnd, $x, False)
_GUICtrlListView_SetItemChecked($hWnd, $x, False)

;~ For $Y = 0 To UBound($a_lv, 2) - 2 Step 1

For $Y = 0 To UBound($a_lv, 2) - 3 Step 1 ; ### MODIFIED ###

$v_item = StringStripWS(_GUICtrlListView_GetItemText($hWnd, $x, $Y), 2)
If (StringIsFloat($v_item) Or StringIsInt($v_item)) Then

$a_lv[$x][$Y] = Number($v_item)

Else

$a_lv[$x][$Y] = $v_item

EndIf

Next
$a_lv[$x][$Y] = $x
$a_lv[$x][$Y + 1] = _GUICtrlListView_GetItemParam($hWnd, $x) ; read ItemParam ### NEW ###

Next
_ArraySort($a_lv, $b_desc, 0, 0, $iCol)
For $x = 0 To UBound($a_lv) - 1 Step 1

;~ For $Y = 0 To UBound($a_lv, 2) - 2 Step 1

For $Y = 0 To UBound($a_lv, 2) - 3 Step 1 ; ### MODIFIED ###

_GUICtrlListView_SetItemText($hWnd, $x, $a_lv[$x][$Y], $Y)

Next
_GUICtrlListView_SetItemParam($hWnd, $x, $a_lv[$x][$Y + 1]) ; write ItemParam ### NEW ###
For $Z = 1 To $i_selected[0]

;~ If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_selected[$Z] Then

If $a_lv[$x][UBound($a_lv, 2) - 2] = $i_selected[$Z] Then ; ### MODIFIED ###

;~ If $a_lv[$x][UBound($a_lv, 2) - 1] = $iFocused Then

If $a_lv[$x][UBound($a_lv, 2) - 2] = $iFocused Then ; ### MODIFIED ###

_GUICtrlListView_SetItemSelected($hWnd, $x, True, True)

Else

_GUICtrlListView_SetItemSelected($hWnd, $x, True)

EndIf
ExitLoop

EndIf

Next
For $Z = 1 To $i_checked[0]

;~ If $a_lv[$x][UBound($a_lv, 2) - 1] = $i_checked[$Z] Then

If $a_lv[$x][UBound($a_lv, 2) - 2] = $i_checked[$Z] Then ; ### MODIFIED ###

_GUICtrlListView_SetItemChecked($hWnd, $x, True)
ExitLoop

EndIf

Next

Next
If (IsArray($vDescending)) Then

$vDescending[$iCol] = Not $b_desc

Else

$vDescending = Not $b_desc

EndIf

EndIf

EndFunc ;==>_GUICtrlListView_SimpleSort

Attachments (0)

Change History (1)

comment:1 Changed 12 years ago by trancexx

  • Resolution set to Rejected
  • Status changed from new to closed

Where? What?
...If you don't mind doing that properly next time please.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.