mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 09:39:16 +02:00
lcl: adding autosortindicator property for the listview
git-svn-id: branches/listviewsortindicator@62518 -
This commit is contained in:
parent
78b457b59d
commit
2e704b21cb
@ -1377,6 +1377,7 @@ type
|
||||
FEditor: TCustomListViewEditor;
|
||||
FAllocBy: Integer;
|
||||
FAutoSort: Boolean;
|
||||
FAutoSortIndicator: Boolean;
|
||||
FAutoWidthLastColumn: Boolean;
|
||||
FCanvas: TCanvas;
|
||||
FDefaultItemHeight: integer;
|
||||
@ -1541,6 +1542,7 @@ type
|
||||
protected
|
||||
property AllocBy: Integer read FAllocBy write SetAllocBy default 0;
|
||||
property AutoSort: Boolean read FAutoSort write FAutoSort default True;
|
||||
property AutoSortIndicator: Boolean read FAutoSortIndicator write FAutoSortIndicator default False;
|
||||
property AutoWidthLastColumn: Boolean read FAutoWidthLastColumn write SetAutoWidthLastColumn default False;
|
||||
property ColumnClick: Boolean index Ord(lvpColumnClick) read GetProperty write SetProperty default True;
|
||||
property Columns: TListColumns read FColumns write SetColumns;
|
||||
@ -1659,6 +1661,7 @@ type
|
||||
property AllocBy;
|
||||
property Anchors;
|
||||
property AutoSort;
|
||||
property AutoSortIndicator;
|
||||
property AutoWidthLastColumn: Boolean read FAutoWidthLastColumn write SetAutoWidthLastColumn default False; // resize last column to fit width of TListView
|
||||
property BorderSpacing;
|
||||
property BorderStyle;
|
||||
|
@ -209,6 +209,10 @@ end;
|
||||
{ TCustomListView ColClick }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.ColClick(AColumn: TListColumn);
|
||||
const
|
||||
DirToIndicator : array [TSortDirection] of TSortIndicator = (siAscending, siDescending);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if IsEditing then
|
||||
begin
|
||||
@ -226,8 +230,14 @@ begin
|
||||
if SortType <> stNone then
|
||||
begin
|
||||
if AColumn.Index <> SortColumn then begin
|
||||
if FAutoSortIndicator then
|
||||
for i:=0 to Columns.Count-1 do
|
||||
if (i <> AColumn.Index) and (Columns[i].SortIndicator <> siNone) then
|
||||
Columns[i].SortIndicator := siNone;
|
||||
|
||||
SortColumn := AColumn.Index;
|
||||
SortDirection := sdAscending;
|
||||
if FAutoSortIndicator then AColumn.SortIndicator := siAscending;
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -236,6 +246,7 @@ begin
|
||||
SortDirection := sdDescending
|
||||
else
|
||||
SortDirection := sdAscending;
|
||||
if FAutoSortIndicator then AColumn.SortIndicator := DirToIndicator[SortDirection];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user