Skip to content

Commit 88115ac

Browse files
committed
feat: re-enable hints on query result tabs
todo: fix using the wrong Screen.HintFont when jumping between editor hints and other control hints
1 parent e1ad5c3 commit 88115ac

2 files changed

Lines changed: 36 additions & 53 deletions

File tree

source/main.lfm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3491,8 +3491,9 @@ object MainForm: TMainForm
34913491
OnChange = tabsetQueryClick
34923492
OnGetImageIndex = tabsetQueryGetImageIndex
34933493
Align = alTop
3494+
ParentShowHint = False
3495+
ShowHint = True
34943496
TabOrder = 2
3495-
OnMouseMove = tabsetQueryMouseMove
34963497
end
34973498
object QueryGrid: TLazVirtualStringTree
34983499
Left = 0

source/main.pas

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,6 @@ TMainForm = class(TExtForm)
10421042
procedure AnyGridGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
10431043
procedure tabsetQueryClick(Sender: TObject);
10441044
procedure tabsetQueryGetImageIndex(Sender: TObject; TabIndex: Integer; var ImageIndex: Integer);
1045-
procedure tabsetQueryMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
10461045
procedure StatusBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);
10471046
procedure AnyGridStartOperation(Sender: TBaseVirtualTree; OperationKind: TVTOperationKind);
10481047
procedure AnyGridEndOperation(Sender: TBaseVirtualTree; OperationKind: TVTOperationKind);
@@ -1201,7 +1200,6 @@ TMainForm = class(TExtForm)
12011200
FAppVerRevision: Integer;
12021201
FAppVersion: String;
12031202

1204-
FLastHintMousepos: TPoint;
12051203
FDelimiter: String;
12061204
FLogToFile: Boolean;
12071205
FFileNameSessionLog: String;
@@ -8436,52 +8434,6 @@ procedure TMainForm.filterQueryHelpersChange(Sender: TObject);
84368434
end;
84378435

84388436

8439-
procedure TMainForm.tabsetQueryMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
8440-
var
8441-
idx, i: Integer;
8442-
Tabs: TTabControl;
8443-
Rect: TRect;
8444-
Org: TPoint;
8445-
QueryTab: TQueryTab;
8446-
ResultTab: TResultTab;
8447-
HintSQL: TStringList;
8448-
begin
8449-
// Display some hint with row/col count + SQL when mouse hovers over result tab
8450-
if (FLastHintMousepos.X = x) and (FLastHintMousepos.Y = Y) then
8451-
Exit;
8452-
FLastHintMousepos := Point(X, Y);
8453-
Tabs := Sender as TTabControl;
8454-
idx := Tabs.IndexOfTabAt(X, Y);
8455-
if idx = -1 then
8456-
Exit;
8457-
// Check if user wants these balloon hints
8458-
if not AppSettings.ReadBool(asHintsOnResultTabs) then
8459-
Exit;
8460-
QueryTab := QueryTabs.ActiveTab;
8461-
if idx >= QueryTab.ResultTabs.Count then
8462-
Exit;
8463-
8464-
// Make SQL readable for the tooltip balloon. WrapText() is unsuitable here.
8465-
// See issue #2014
8466-
// Also, wee need to work around the awful looking balloon text:
8467-
// http://qc.embarcadero.com/wc/qcmain.aspx?d=73771
8468-
ResultTab := QueryTab.ResultTabs[idx];
8469-
HintSQL := TStringList.Create;
8470-
HintSQL.Text := Trim(ResultTab.Results.SQL);
8471-
for i:=0 to HintSQL.Count-1 do begin
8472-
HintSQL[i] := StrEllipsis(HintSQL[i], 100);
8473-
HintSQL[i] := StringReplace(HintSQL[i], #9, ' ', [rfReplaceAll]);
8474-
end;
8475-
//BalloonHint1.Description := FormatNumber(ResultTab.Results.ColumnCount) + ' columns × ' +
8476-
// FormatNumber(ResultTab.Results.RecordCount) + ' rows' + CRLF + CRLF +
8477-
// Trim(StrEllipsis(HintSQL.Text, SIZE_KB));
8478-
Rect := Tabs.TabRect(idx);
8479-
Org := Tabs.ClientOrigin;
8480-
OffsetRect(Rect, Org.X, Org.Y);
8481-
//BalloonHint1.ShowHint(Rect);
8482-
end;
8483-
8484-
84858437
{**
84868438
Insert function name from popupmenu to query memo
84878439
}
@@ -12332,6 +12284,7 @@ procedure TMainForm.actNewQueryTabExecute(Sender: TObject);
1233212284
QueryTab.tabsetQuery.Align := tabsetQuery.Align;
1233312285
QueryTab.tabsetQuery.Font.Assign(tabsetQuery.Font);
1233412286
QueryTab.tabsetQuery.Images := tabsetQuery.Images;
12287+
QueryTab.tabsetQuery.ShowHint := tabsetQuery.ShowHint;
1233512288
QueryTab.tabsetQuery.Style := tabsetQuery.Style;
1233612289
QueryTab.tabsetQuery.TabHeight := tabsetQuery.TabHeight;
1233712290
QueryTab.tabsetQuery.Height := tabsetQuery.Height;
@@ -12342,7 +12295,6 @@ procedure TMainForm.actNewQueryTabExecute(Sender: TObject);
1234212295
//QueryTab.tabsetQuery.UnselectedColor := tabsetQuery.UnselectedColor;
1234312296
QueryTab.tabsetQuery.OnChange := tabsetQuery.OnChange;
1234412297
QueryTab.tabsetQuery.OnGetImageIndex := tabsetQuery.OnGetImageIndex;
12345-
QueryTab.tabsetQuery.OnMouseMove := tabsetQuery.OnMouseMove;
1234612298

1234712299
SetupSynEditor(QueryTab.Memo);
1234812300

@@ -14608,12 +14560,15 @@ procedure TMainForm.ApplicationDeActivate(Sender: TObject);
1460814560

1460914561
procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
1461014562
var
14611-
MainTabIndex, QueryTabIndex, NewHideTimeout, PanelIndex: Integer;
14563+
MainTabIndex, QueryTabIndex, NewHideTimeout: Integer;
1461214564
pt: TPoint;
1461314565
Conn: TDBConnection;
1461414566
Editor: TSynMemo;
14615-
Infos: TStringList;
14616-
i: Integer;
14567+
Infos, HintSQL: TStringList;
14568+
i, PanelIndex, TabIndex: Integer;
14569+
QueryTab: TQueryTab;
14570+
Tabs: TTabControl;
14571+
ResultTab: TResultTab;
1461714572
begin
1461814573
if HintInfo.HintControl = PageControlMain then begin
1461914574
// Show full filename in tab hint. See issue #3527
@@ -14633,6 +14588,7 @@ procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolea
1463314588
HintInfo.ReshowTimeout := 1000;
1463414589
SetHintFontByControl;
1463514590
end
14591+
1463614592
else if HintInfo.HintControl is TSynMemo then begin
1463714593
// Token hint displaying through SynEdit's OnShowHint event
1463814594
Editor := TSynMemo(HintInfo.HintControl);
@@ -14641,6 +14597,7 @@ procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolea
1464114597
if NewHideTimeout > HintInfo.HideTimeout then
1464214598
HintInfo.HideTimeout := NewHideTimeout;
1464314599
end
14600+
1464414601
else if HintInfo.HintControl = StatusBar then begin
1464514602
pt := StatusBar.ScreenToClient(Mouse.CursorPos);
1464614603
PanelIndex := StatusBar.GetPanelIndexAt(pt.X, pt.Y);
@@ -14656,6 +14613,31 @@ procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolea
1465614613
end;
1465714614
end;
1465814615
end
14616+
14617+
else if HintInfo.HintControl is TNoteBookStringsTabControl then begin
14618+
Tabs := HintInfo.HintControl.Parent as TTabControl;
14619+
QueryTab := QueryTabs.TabByControl(Tabs);
14620+
if AppSettings.ReadBool(asHintsOnResultTabs) and Assigned(QueryTab) then begin
14621+
pt := Tabs.ScreenToClient(Mouse.CursorPos);
14622+
TabIndex := Tabs.IndexOfTabAt(pt.X, pt.Y);
14623+
if (TabIndex > -1) and (TabIndex < QueryTab.ResultTabs.Count) then begin
14624+
// Make SQL readable for the tooltip balloon. WrapText() is unsuitable here.
14625+
// See issue #2014
14626+
ResultTab := QueryTab.ResultTabs[TabIndex];
14627+
HintSQL := TStringList.Create;
14628+
HintSQL.Text := Trim(ResultTab.Results.SQL);
14629+
for i:=0 to HintSQL.Count-1 do begin
14630+
HintSQL[i] := StrEllipsis(HintSQL[i], 100);
14631+
HintSQL[i] := StringReplace(HintSQL[i], #9, ' ', [rfReplaceAll]);
14632+
end;
14633+
HintStr := FormatNumber(ResultTab.Results.ColumnCount) + ' columns × ' +
14634+
FormatNumber(ResultTab.Results.RecordCount) + ' rows' + LineEnding + LineEnding +
14635+
Trim(StrEllipsis(HintSQL.Text, SIZE_KB));
14636+
HintSQL.Free;
14637+
end;
14638+
end;
14639+
end
14640+
1465914641
else begin
1466014642
// Probably reset hint font
1466114643
SetHintFontByControl;

0 commit comments

Comments
 (0)