<p style="padding:0 0 0 0; margin:0 0 0 0;">Delphi has no properties AutoSort, SortColumn and SortDirection nor methods BeginUpdate and EndUpdate.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">I would provide a patch which will set Flag lffPreparingSorting on BeginUpdate and reset it on EndUpdate.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">+one additional call of Sort on EndUpdate (maybe only if AutoSort is True) OR move Sort; form protected to public.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">What is preferred?</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">V.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br />
> Od: "Vojtěch Čihák" <vojtech.cihak@atlas.cz><br />
> Komu: Lazarus mailing list <lazarus@lists.lazarus.freepascal.org><br />
> Datum: 14.04.2015 15:23<br />
> Předmět: Re: [Lazarus] Strange Alphasort in ListView<br />
></p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">I understand. Method Sort; is protected (as it is in Delphi).</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">You have probably no other choice than do</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> ListView1.SortDirection:=sdDescending;</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> ListView1.SortDirection:=sdAscending;</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">which works but it is unefficient, sorting is done twice.</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">I tried:</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> ListView1.BeginUpdate;</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> ListView1.SortDirection:=sdDescending;</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> ListView1.EndUpdate;</p>
<div><span style="font-size: 10pt;"> ListView1.SortDirection:=sdAscending;</span></div>
<div>but it doesn't help, sorting is still done twice (at least on Qt).</div>
<div>ListView has some flags to avoid sorting but those flags are private.</div>
<div>V.</div>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">______________________________________________________________<br />
> Od: "Valdas Jankūnas" <zmuogs@gmail.com><br />
> Komu: Lazarus mailing list <lazarus@lists.lazarus.freepascal.org><br />
> Datum: 14.04.2015 15:02<br />
> Předmět: Re: [Lazarus] Strange Alphasort in ListView<br />
></p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">2015.04.14 15:34, Vojtěch Čihák rašė:<br />
> No, it isn't a bug.<br />
><br />
> In sources, you can see comment:<br />
><br />
> function AlphaSort: Boolean; // always sorts column 0 in sdAscending order<br />
<br />
Looked not in *primary* source (Google, Documentation) :)<br />
<br />
><br />
> So if you want other sorting, you must set three sort-related properties:<br />
><br />
> ListView1.SortColumn:=1;<br />
> ListView1.SortDirection:=sdAscending;<br />
> ListView1.SortType:=stText;<br />
><br />
> It works, I just tested in Qt.<br />
<br />
Why I came to AlphaSort: in my source ListView is cleared (columns stays <br />
same) and populated with new info. After that current column (say <br />
SortColumn=1) is no sorted (Autosort is TRUE; tried in Qt, Gtk2 and Win) <br />
so I must somehow to trigger sorting. But how?<br />
<br />
<br />
-- <br />
Valdas Jankūnas<br />
<br />
--<br />
_______________________________________________<br />
Lazarus mailing list<br />
Lazarus@lists.lazarus.freepascal.org<br />
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a></p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"><br />
<br />
----------<br />
<br />
--<br />
_______________________________________________<br />
Lazarus mailing list<br />
Lazarus@lists.lazarus.freepascal.org<br />
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a></p>