Issue #2000: restore partly disabled support for multi lined grid rows

This commit is contained in:
Ansgar Becker
2025-01-12 13:31:44 +01:00
parent 4cc6134cb0
commit 250663f489
2 changed files with 16 additions and 9 deletions

View File

@@ -364,7 +364,7 @@ type
procedure StreamToClipboard(Text, HTML: TStream);
function WideHexToBin(text: String): AnsiString;
function BinToWideHex(bin: AnsiString): String;
procedure FixVT(VT: TVirtualStringTree);
procedure FixVT(VT: TVirtualStringTree; MultiLineCount: Word=1);
function GetTextHeight(Font: TFont): Integer;
function ColorAdjustBrightness(Col: TColor; Shift: SmallInt): TColor;
procedure DeInitializeVTNodes(Sender: TBaseVirtualTree);
@@ -1406,7 +1406,7 @@ begin
end;
procedure FixVT(VT: TVirtualStringTree);
procedure FixVT(VT: TVirtualStringTree; MultiLineCount: Word=1);
var
SingleLineHeight: Integer;
Node: PVirtualNode;
@@ -1414,12 +1414,15 @@ begin
// This is called either in some early stage, or from preferences dialog
VT.BeginUpdate;
SingleLineHeight := GetTextHeight(VT.Font) + 7;
VT.DefaultNodeHeight := SingleLineHeight;
// Multiline nodes?
VT.DefaultNodeHeight := SingleLineHeight * MultiLineCount;
VT.Header.Height := SingleLineHeight;
// Apply new height to multi line grid nodes
Node := VT.GetFirstInitialized;
while Assigned(Node) do begin
VT.NodeHeight[Node] := VT.DefaultNodeHeight;
// Nodes have vsMultiLine through InitNode event
VT.MultiLine[Node] := MultiLineCount > 1;
Node := VT.GetNextInitialized(Node);
end;
VT.EndUpdate;

View File

@@ -6237,11 +6237,15 @@ procedure TMainForm.AnyGridInitNode(Sender: TBaseVirtualTree; ParentNode, Node:
var
Idx: PInt64;
begin
// Mark all nodes as multiline capable. Fixes painting issues with long lines.
// Display multiline grid rows
// Mark all nodes as multiline capable. Fixes painting issues with long lines. (?)
// See issue #1897 and https://www.heidisql.com/forum.php?t=41502
// Disabled due to laggy performance with large grid contents
//if toGridExtensions in (Sender as TVirtualStringTree).TreeOptions.MiscOptions then
// Include(Node.States, vsMultiLine);
// Laggy performance with large grid contents (?)
if AppSettings.ReadInt(asGridRowLineCount) = 1 then
Exclude(Node.States, vsMultiLine)
else
Include(Node.States, vsMultiLine);
Sender.NodeHeight[Node] := TVirtualStringTree(Sender).DefaultNodeHeight;
// Node may have data already, if added via InsertRow
if not (vsOnFreeNodeCallRequired in Node.States) then begin
Idx := Sender.GetNodeData(Node);
@@ -9275,7 +9279,7 @@ begin
for Grid in AllGrids do begin
Grid.Font.Name := AppSettings.ReadString(asDataFontName);
Grid.Font.Size := AppSettings.ReadInt(asDataFontSize);
FixVT(Grid);
FixVT(Grid, AppSettings.ReadInt(asGridRowLineCount));
if IncrementalSearchActive then
Grid.IncrementalSearch := isInitializedOnly
else
@@ -15419,7 +15423,7 @@ begin
Grid.OnNewText := OrgGrid.OnNewText;
Grid.OnPaintText := OrgGrid.OnPaintText;
Grid.OnStartOperation := OrgGrid.OnStartOperation;
FixVT(Grid);
FixVT(Grid, AppSettings.ReadInt(asGridRowLineCount));
FTabIndex := QueryTab.ResultTabs.Count; // Will be 0 for the first one, even if we're already creating the first one here!
end;