mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 18:12:05 +08:00
DataGrid refreshing:
- Restore column widths if the table has *not* been switched - Scroll to top left if table *has* been switched
This commit is contained in:
@ -461,6 +461,7 @@ type
|
|||||||
winName : String;
|
winName : String;
|
||||||
FSelectedTableColumns,
|
FSelectedTableColumns,
|
||||||
FSelectedTableKeys : TDataset;
|
FSelectedTableKeys : TDataset;
|
||||||
|
ViewDataPrevTable : WideString;
|
||||||
|
|
||||||
function GetQueryRunning: Boolean;
|
function GetQueryRunning: Boolean;
|
||||||
procedure SetQueryRunning(running: Boolean);
|
procedure SetQueryRunning(running: Boolean);
|
||||||
@ -1139,6 +1140,7 @@ var
|
|||||||
col : TVirtualTreeColumn;
|
col : TVirtualTreeColumn;
|
||||||
rx : TRegExpr;
|
rx : TRegExpr;
|
||||||
ColType : String;
|
ColType : String;
|
||||||
|
PrevCols : WideStrings.TWideStringList;
|
||||||
|
|
||||||
procedure InitColumn(idx: Integer; name: WideString);
|
procedure InitColumn(idx: Integer; name: WideString);
|
||||||
var
|
var
|
||||||
@ -1150,6 +1152,12 @@ begin
|
|||||||
col.Text := name;
|
col.Text := name;
|
||||||
if HiddenKeyCols.IndexOf(name) > -1 then col.Options := col.Options - [coVisible];
|
if HiddenKeyCols.IndexOf(name) > -1 then col.Options := col.Options - [coVisible];
|
||||||
col.Width := prefDefaultColWidth;
|
col.Width := prefDefaultColWidth;
|
||||||
|
if ViewDataPrevTable = SelectedTable then begin
|
||||||
|
// Restore column layout
|
||||||
|
k := PrevCols.IndexOf(name);
|
||||||
|
if PrevCols.Count > k+1 then
|
||||||
|
col.Width := StrToInt(PrevCols[k+1])
|
||||||
|
end;
|
||||||
// Sorting color and title image
|
// Sorting color and title image
|
||||||
for k:=0 to Length(OrderColumns)-1 do begin
|
for k:=0 to Length(OrderColumns)-1 do begin
|
||||||
if OrderColumns[k].ColumnName = name then begin
|
if OrderColumns[k].ColumnName = name then begin
|
||||||
@ -1254,6 +1262,14 @@ begin
|
|||||||
DataGrid.Header.Columns.BeginUpdate;
|
DataGrid.Header.Columns.BeginUpdate;
|
||||||
DataGrid.RootNodeCount := 0;
|
DataGrid.RootNodeCount := 0;
|
||||||
DataGrid.Header.Options := DataGrid.Header.Options + [hoVisible];
|
DataGrid.Header.Options := DataGrid.Header.Options + [hoVisible];
|
||||||
|
if ViewDataPrevTable = SelectedTable then begin
|
||||||
|
// Remember column layout
|
||||||
|
PrevCols := WideStrings.TWideStringList.Create;
|
||||||
|
for i := 0 to DataGrid.Header.Columns.Count - 1 do begin
|
||||||
|
PrevCols.Add(DataGrid.Header.Columns[i].Text);
|
||||||
|
PrevCols.Add(IntToStr(DataGrid.Header.Columns[i].Width));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
DataGrid.Header.Columns.Clear;
|
DataGrid.Header.Columns.Clear;
|
||||||
SetLength(FDataGridResult.Columns, 0);
|
SetLength(FDataGridResult.Columns, 0);
|
||||||
SetLength(FDataGridResult.Rows, 0);
|
SetLength(FDataGridResult.Rows, 0);
|
||||||
@ -1331,6 +1347,9 @@ begin
|
|||||||
// Apply custom ORDER BY if detected in registry
|
// Apply custom ORDER BY if detected in registry
|
||||||
if sorting <> '' then sl_query.Add( sorting );
|
if sorting <> '' then sl_query.Add( sorting );
|
||||||
DataGrid.RootNodeCount := StrToInt(GetVar(sl_query.Text));
|
DataGrid.RootNodeCount := StrToInt(GetVar(sl_query.Text));
|
||||||
|
// Scroll to top left if switched to another table
|
||||||
|
if ViewDataPrevTable <> SelectedTable then
|
||||||
|
DataGrid.OffsetXY := Point(0, 0);
|
||||||
DisplayRowCountStats;
|
DisplayRowCountStats;
|
||||||
dataselected := true;
|
dataselected := true;
|
||||||
except
|
except
|
||||||
@ -1368,9 +1387,12 @@ begin
|
|||||||
DataGrid.Header.Columns.EndUpdate;
|
DataGrid.Header.Columns.EndUpdate;
|
||||||
DataGrid.EndUpdate;
|
DataGrid.EndUpdate;
|
||||||
FreeAndNil(sl_query);
|
FreeAndNil(sl_query);
|
||||||
|
if PrevCols <> nil then
|
||||||
|
FreeAndNil(PrevCols);
|
||||||
viewingdata := false;
|
viewingdata := false;
|
||||||
Screen.Cursor := crDefault;
|
Screen.Cursor := crDefault;
|
||||||
end;
|
end;
|
||||||
|
ViewDataPrevTable := SelectedTable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user