From 2e704b21cb66d2d15b4c80e86aa1ca8341e5c6f3 Mon Sep 17 00:00:00 2001 From: dmitry Date: Thu, 9 Jan 2020 19:58:03 +0000 Subject: [PATCH] lcl: adding autosortindicator property for the listview git-svn-id: branches/listviewsortindicator@62518 - --- lcl/comctrls.pp | 3 +++ lcl/include/customlistview.inc | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index faef94c9fd..b40d492696 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -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; diff --git a/lcl/include/customlistview.inc b/lcl/include/customlistview.inc index bee29bf33f..2bb3a76295 100644 --- a/lcl/include/customlistview.inc +++ b/lcl/include/customlistview.inc @@ -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;