Display number of indexes and foreign keys in caption of their tabs within the table editor. Helpful for knowing the number without having to activate their tab.

This commit is contained in:
Ansgar Becker
2021-01-04 16:44:50 +01:00
parent 34db4c7abd
commit 6fd54fb9d4
2 changed files with 21 additions and 0 deletions

View File

@ -274,6 +274,7 @@ object frmTableEditor: TfrmTableEditor
OnInitChildren = treeIndexesInitChildren
OnInitNode = treeIndexesInitNode
OnNewText = treeIndexesNewText
OnStructureChange = AnyTreeStructureChange
Columns = <
item
Options = [coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]
@ -428,6 +429,7 @@ object frmTableEditor: TfrmTableEditor
OnGetText = listForeignKeysGetText
OnGetImageIndex = listForeignKeysGetImageIndex
OnNewText = listForeignKeysNewText
OnStructureChange = AnyTreeStructureChange
Columns = <
item
Options = [coDraggable, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]

View File

@ -171,6 +171,8 @@ type
procedure menuCopyColumnsClick(Sender: TObject);
procedure menuPasteColumnsClick(Sender: TObject);
procedure listColumnsChange(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure AnyTreeStructureChange(Sender: TBaseVirtualTree;
Node: PVirtualNode; Reason: TChangeReason);
private
{ Private declarations }
FLoaded: Boolean;
@ -188,6 +190,7 @@ type
procedure UpdateSQLcode;
function CellEditingAllowed(Node: PVirtualNode; Column: TColumnIndex): Boolean;
procedure CalcMinColWidth;
procedure UpdateTabCaptions;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
@ -362,6 +365,7 @@ begin
btnHelp.Top := btnSave.Top;
btnDiscard.Top := btnSave.Top;
UpdateSQLCode;
UpdateTabCaptions;
CalcMinColWidth;
// Indicate change mechanisms can call their events now. See Modification().
FLoaded := True;
@ -2553,4 +2557,19 @@ begin
end;
procedure TfrmTableEditor.AnyTreeStructureChange(Sender: TBaseVirtualTree;
Node: PVirtualNode; Reason: TChangeReason);
begin
UpdateTabCaptions;
end;
procedure TfrmTableEditor.UpdateTabCaptions;
begin
// Append number of listed keys (or whatever) to the tab caption
tabIndexes.Caption := _('Indexes') + ' (' + FKeys.Count.ToString + ')';
tabForeignKeys.Caption := _('Foreign keys') + ' (' + FForeignKeys.Count.ToString + ')';
end;
end.