PureLVSORT library : sorting ListIconGadgets (and more)
Moderator: gnozal
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
You could use this procedure to change the listicon content after #HDN_FILTERCHANGE or #HDN_FILTERBTNCLICK events.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Yeah, it is possible, but a lot of work. It would be quite easier if the library would do the restore procedure and would ask by callback wether to add this one row or not. When do not want to use another filter logic than that provided by LoadfromMem function you have to the loading on your own and hack your save format.
Another point is that the filter callback does not work when column width is fixed with
Another point is that the filter callback does not work when column width is fixed with
Code: Select all
PureLVSORT_SetColumnFlag(#ListIcon_0,1,#PureLVSORT_Column_Fixed)
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Yes, it seems that Windows doesn't send a #HDN_FILTERCHANGE message if you return #True for #HDN_ITEMCHANGING [to lock the column width] for the same column.Vladi wrote:Another point is that the filter callback does not work when column width is fixed withCode: Select all
PureLVSORT_SetColumnFlag(#ListIcon_0,1,#PureLVSORT_Column_Fixed)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal,
I don't know how you're handling the filter but what if you added a PureLVSORT_SetColumnFilterType() and have types such as #PureLVSORT_Filter_Equal, #PureLVSORT_Filter_GreaterThan, #PureLVSORT_Filter_Greater... etc....?
That way the user could specify how they want a column to filter when they first set it up.
I don't know how you're handling the filter but what if you added a PureLVSORT_SetColumnFilterType() and have types such as #PureLVSORT_Filter_Equal, #PureLVSORT_Filter_GreaterThan, #PureLVSORT_Filter_Greater... etc....?
That way the user could specify how they want a column to filter when they first set it up.
In addition to the above post, I have a couple more things to harass you about 
Can we have a flag that turns off filtering while typing the filter? This would force the user to click the little filter button. For large lists it can lock the app while you're trying to type the whole thing.
Is there anything that can be done to add in the speed of filtering on large lists? For example, in one app I have a little bit over 10,000 lines and it takes a while to filter. Is there a bottleneck somewhere that can be worked around? Similar to your PureLVSORT_Disabled(#True) when loading large lists.
Thanks again for all your help!
EDIT: I forgot the other thing. What about the possibility of multiple sort orders? Allow the user to define them by holding down the CTRL key and clicking on a column header. The first column to sort is defined by clicking without the CTRL key down but the second, third, etc... columns are defined by holding down the CTRL key.

Can we have a flag that turns off filtering while typing the filter? This would force the user to click the little filter button. For large lists it can lock the app while you're trying to type the whole thing.
Is there anything that can be done to add in the speed of filtering on large lists? For example, in one app I have a little bit over 10,000 lines and it takes a while to filter. Is there a bottleneck somewhere that can be worked around? Similar to your PureLVSORT_Disabled(#True) when loading large lists.
Thanks again for all your help!
EDIT: I forgot the other thing. What about the possibility of multiple sort orders? Allow the user to define them by holding down the CTRL key and clicking on a column header. The first column to sort is defined by clicking without the CTRL key down but the second, third, etc... columns are defined by holding down the CTRL key.
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
The PureLVSORT_SetFilterString() function uses the #HDM_SETITEM message with #HDFT_ISSTRING type. I don't think > or < filter types are possible with this function.Xombie wrote:I don't know how you're handling the filter but what if you added a PureLVSORT_SetColumnFilterType() and have types such as #PureLVSORT_Filter_Equal, #PureLVSORT_Filter_GreaterThan, #PureLVSORT_Filter_Greater... etc....?
But the filtering callback is designed for this for this.
Did you try the filtering callback ?Xombie wrote:Can we have a flag that turns off filtering while typing the filter? This would force the user to click the little filter button. For large lists it can lock the app while you're trying to type the whole thing.
You can choose to react only to a #PureLVSORT_FilterBtnClick event (so nothing is done while the user is typing some text [#PureLVSORT_FilterChange event]) :
Code: Select all
Procedure MyFilterCallback(GadgetNumber.l, FilterString.s, ListIconColumn.l, EventCode.l) ; simple search example
Protected itemNumber.l, I.l
If FilterString And EventCode = #PureLVSORT_FilterBtnClick
itemNumber = -1
If IsGadget(GadgetNumber)
; Search for string
For I = 0 To CountGadgetItems(GadgetNumber) - 1
If FilterString = GetGadgetItemText(GadgetNumber, I, ListIconColumn)
itemNumber = I
Break
EndIf
Next
;
If itemNumber <> -1 ; if string found, scroll to row
PureLVSORT_ScrollToRow(GadgetNumber, itemNumber)
SetGadgetItemState(GadgetNumber, itemNumber, GetGadgetItemState(GadgetNumber, itemNumber) | #PB_ListIcon_Selected)
EndIf
EndIf
EndIf
EndProcedure
;
#Window_0 = 0
#ListIcon_0 = 0
;
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT Test", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(#Window_0))
ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "String", 110)
AddGadgetColumn(#ListIcon_0, 1, "Numeric", 110)
AddGadgetColumn(#ListIcon_0, 2, "Float", 110)
AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120)
AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120)
AddGadgetItem(#ListIcon_0, -1, "ABCDE" + Chr(10) + "514" + Chr(10) + "0.9" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004")
AddGadgetItem(#ListIcon_0, -1, "ACDEF" + Chr(10) + "118" + Chr(10) + "1.9" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004")
AddGadgetItem(#ListIcon_0, -1, "ZABCD" + Chr(10) + "-414" + Chr(10) + "7.0" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003")
AddGadgetItem(#ListIcon_0, -1, "DEFGH" + Chr(10) + "524" + Chr(10) + "900" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001")
EndIf
EndIf
EndProcedure
;
Open_Window_0()
;
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_String) ; default, not necessary
PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_Numeric)
PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_Float)
PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY)
PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY)
PureLVSORT_SortListIconNow(#ListIcon_0, 3, 1)
PureLVSORT_DefineFilterCallback(@MyFilterCallback())
PureLVSORT_SetFilterTimeOut(100)
PureLVSORT_SetFilter(#ListIcon_0)
EndIf
;
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
Again you can use the filtering callback and choose you own filtering code.Xombie wrote:Is there anything that can be done to add in the speed of filtering on large lists? For example, in one app I have a little bit over 10,000 lines and it takes a while to filter. Is there a bottleneck somewhere that can be worked around? Similar to your PureLVSORT_Disabled(#True) when loading large lists.
As PureLVSORT uses the #LVM_SORTITEMS Windows message, I don't think this is possible.Xombie wrote:What about the possibility of multiple sort orders? Allow the user to define them by holding down the CTRL key and clicking on a column header. The first column to sort is defined by clicking without the CTRL key down but the second, third, etc... columns are defined by holding down the CTRL key.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal,
Thanks a lot for your patience with me.
I think I just realized what's going on. I'm using your example from the PureLVSORT_LoadListIconFromMem() help entry as my test. So basically the filter callback is not doing the filtering. It's the LoadListIconFromMem call that's doing it. And you're just passing the filter parameters there. Garrrr... I'm blind and dumb
So that's what you've meant when you said I could do my own filtering code.
I think I'm all set. Thanks again!
EDIT: I put in my own filtering routine and got the time down from 4500+ ms to 313 ms. Yay!
Thanks a lot for your patience with me.
Again you can use the filtering callback and choose you own filtering code.


I think I'm all set. Thanks again!
EDIT: I put in my own filtering routine and got the time down from 4500+ ms to 313 ms. Yay!
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
I will see if this is possible...Xombie wrote:For the filter callback, is there any chance to add a #PureLVSORT_FilterReturn event code that is handled when the user presses the enter key in the filter field?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Update (PB4.20 version only)
Changes :
Recompiled for PB4.20 final with 'exported string function fix'
See this thread for more information : http://www.purebasic.fr/english/viewtop ... 0&start=18
Changes :
Recompiled for PB4.20 final with 'exported string function fix'
See this thread for more information : http://www.purebasic.fr/english/viewtop ... 0&start=18
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- Thorsten1867
- Addict
- Posts: 1372
- Joined: Wed Aug 24, 2005 4:02 pm
- Location: Germany
LvSort seems to destroy my database id's (GadgetItemData) in the ListIconGadget.
Translated with http://www.DeepL.com/Translator
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Yes.Thorsten1867 wrote:LvSort seems to destroy my database id's (GadgetItemData) in the ListIconGadget.
PureLVSORT.chm wrote:Important note : PureLVSORT uses the Windows #LVM_SORTITEMS message to sort the listicongadget, and this implies using LV_ITEM\lParam (so the sorting is not compatible with Set/GetGadgetItemData(), or the other way round : the Purebasic listicongadget is not 100% Windows API compatible : it's not a simple SysListView32).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- Thorsten1867
- Addict
- Posts: 1372
- Joined: Wed Aug 24, 2005 4:02 pm
- Location: Germany
Sorry, I use LVSort since PB V3.x and so I don't read the help file.
Translated with http://www.DeepL.com/Translator
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]