View Issue Details

IDProjectCategoryView StatusLast Update
0036596LazarusWidgetsetpublic2020-01-18 11:34
ReporterAnton Kavalenka Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0036596: gtk3: Implement ListView column sort order
DescriptionImplement column sort order indicator as followup in other widgetset changes
TagsNo tags attached.
Fixed in Revision62569
LazTarget-
WidgetsetGTK 3
Attached Files

Activities

Anton Kavalenka

2020-01-17 09:57

reporter  

gtk3widgets.diff (1,463 bytes)   
Index: gtk3widgets.pas
===================================================================
--- gtk3widgets.pas	(revision 62567)
+++ gtk3widgets.pas	(working copy)
@@ -571,6 +571,7 @@
     procedure SetColumnMinWidth(AIndex: Integer; AColumn: TListColumn; AMinWidth: Integer);
     procedure SetColumnWidth(AIndex: Integer; AColumn: TListColumn; AWidth: Integer);
     procedure SetColumnVisible(AIndex: Integer; AColumn: TListColumn; AVisible: Boolean);
+    procedure ColumnSetSortIndicator(const AIndex: Integer; const AColumn: TListColumn; const ASortIndicator: TSortIndicator);
 
     procedure ItemDelete(AIndex: Integer);
     procedure ItemInsert(AIndex: Integer; AItem: TListItem);
@@ -5815,6 +5816,27 @@
   end;
 end;
 
+procedure TGtk3ListView.ColumnSetSortIndicator(const AIndex: Integer;
+  const AColumn: TListColumn; const ASortIndicator: TSortIndicator);
+const
+  GtkOrder : array [ TSortIndicator] of TGtkSortType = (0, {GTK_SORT_ASCENDING}0, {GTK_SORT_DESCENDING}1);
+var
+  AGtkColumn: PGtkTreeViewColumn;
+begin
+  AGtkColumn := PGtkTreeView(getContainerWidget)^.get_column(AIndex);
+
+  if AGtkColumn <> nil then
+  begin
+    if ASortIndicator = siNone then
+      AGtkColumn^.set_sort_indicator(false)
+    else
+    begin
+      AGtkColumn^.set_sort_indicator(true);
+      AgtkColumn^.set_sort_order(GtkOrder[ASortIndicator]);
+    end;
+  end;
+end;
+
 procedure TGtk3ListView.ItemDelete(AIndex: Integer);
 var
   AModel: PGtkTreeModel;
gtk3widgets.diff (1,463 bytes)   
gtk3wscomctrls.diff (1,476 bytes)   
Index: gtk3wscomctrls.pp
===================================================================
--- gtk3wscomctrls.pp	(revision 62567)
+++ gtk3wscomctrls.pp	(working copy)
@@ -121,6 +121,8 @@
     class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMinWidth: integer); override;
     class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AWidth: Integer); override;
     class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AVisible: Boolean); override;
+    class procedure ColumnSetSortIndicator(const ALV: TCustomListView; const AIndex: Integer;
+      const AColumn: TListColumn; const ASortIndicator: TSortIndicator);override;
 
     // items
     class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
@@ -595,6 +597,19 @@
   TGtk3ListView(ALV.Handle).SetColumnVisible(AIndex, AColumn, AVisible);
 end;
 
+class procedure TGtk3WSCustomListView.ColumnSetSortIndicator(
+  const ALV: TCustomListView; const AIndex: Integer;
+  const AColumn: TListColumn; const ASortIndicator: TSortIndicator);
+begin
+  if not WSCheckHandleAllocated(ALV, 'ColumnSetSortIndicator') then
+    Exit;
+
+  TGtk3ListView(ALV.Handle).ColumnSetSortIndicator(AIndex,AColumn,ASortIndicator);
+end;
+
+
+
+
 type
   TListItemHack = class(TListItem)
   end;
gtk3wscomctrls.diff (1,476 bytes)   

Dmitry Boyarintsev

2020-01-17 20:37

developer   ~0120499

thanks for the patch applied.
please test and close if ok

Issue History

Date Modified Username Field Change
2020-01-17 09:57 Anton Kavalenka New Issue
2020-01-17 09:57 Anton Kavalenka File Added: gtk3widgets.diff
2020-01-17 09:57 Anton Kavalenka File Added: gtk3wscomctrls.diff
2020-01-17 20:37 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2020-01-17 20:37 Dmitry Boyarintsev Status new => resolved
2020-01-17 20:37 Dmitry Boyarintsev Resolution open => fixed
2020-01-17 20:37 Dmitry Boyarintsev Fixed in Revision => 62569
2020-01-17 20:37 Dmitry Boyarintsev LazTarget => -
2020-01-17 20:37 Dmitry Boyarintsev Widgetset GTK 3 => GTK 3
2020-01-17 20:37 Dmitry Boyarintsev Note Added: 0120499
2020-01-18 11:34 Anton Kavalenka Status resolved => closed