Skip to content

Commit bb5e724

Browse files
committed
feat: create opt-in option for displaying columns in database tree
Refs #2069
1 parent d15df71 commit bb5e724

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

source/apphelpers.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ TWinControlHelper = class helper for TWinControl
225225
asLogUserSQL, asLogSQL, asLogInfos, asLogDebug, asLogScript, asLogTimestamp, asFieldColorNumeric,
226226
asFieldColorReal, asFieldColorText, asFieldColorBinary, asFieldColorDatetime, asFieldColorSpatial,
227227
asFieldColorOther, asFieldEditorBinary, asFieldEditorDatetime, asFieldEditorDatetimePrefill, asFieldEditorEnum,
228-
asFieldEditorSet, asFieldNullBackground, asRowBackgroundEven, asRowBackgroundOdd, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile,
228+
asFieldEditorSet, asFieldNullBackground, asRowBackgroundEven, asRowBackgroundOdd, asGroupTreeObjects, asTreeShowColumns, asDisplayObjectSizeColumn, asSQLfile,
229229
asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle,
230230
asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder,
231231
asRecentFilter, asTimestampColumns, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asDoubleClickInsertsNodeText, asForeignDropDown,
@@ -4125,6 +4125,7 @@ constructor TAppSettings.Create;
41254125
InitSetting(asRowBackgroundEven, 'RowBackgroundEven', clNone);
41264126
InitSetting(asRowBackgroundOdd, 'RowBackgroundOdd', clNone);
41274127
InitSetting(asGroupTreeObjects, 'GroupTreeObjects', 0, False);
4128+
InitSetting(asTreeShowColumns, 'TreeShowColumns', 0, False);
41284129
InitSetting(asDisplayObjectSizeColumn, 'DisplayObjectSizeColumn', 0, True);
41294130
InitSetting(asDisplayLogPanel, 'DisplayLogPanel', 0, True);
41304131
InitSetting(asDisplayTreeFilters, 'DisplayTreeFilters', 0, True);

source/main.dfm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,10 @@ object MainForm: TMainForm
19271927
Action = actDisplayTreeFilters
19281928
AutoCheck = True
19291929
end
1930+
object menuTreeShowColumns1: TMenuItem
1931+
Action = actTreeShowColumns
1932+
AutoCheck = True
1933+
end
19301934
object N27: TMenuItem
19311935
Caption = '-'
19321936
end
@@ -3464,6 +3468,12 @@ object MainForm: TMainForm
34643468
ImageIndex = 58
34653469
OnExecute = actDataEditWithoutLookupExecute
34663470
end
3471+
object actTreeShowColumns: TAction
3472+
Category = 'Various'
3473+
AutoCheck = True
3474+
Caption = 'Columns below tables in tree'
3475+
OnExecute = actTreeShowColumnsExecute
3476+
end
34673477
end
34683478
object menuConnections: TPopupMenu
34693479
AutoHotkeys = maManual
@@ -3592,6 +3602,10 @@ object MainForm: TMainForm
35923602
Action = actFavoriteObjectsOnly
35933603
AutoCheck = True
35943604
end
3605+
object menuTreeShowColumns2: TMenuItem
3606+
Action = actTreeShowColumns
3607+
AutoCheck = True
3608+
end
35953609
end
35963610
object menuPrint: TMenuItem
35973611
Action = actPrintList

source/main.pas

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,15 @@ TQueryHistoryItemComparer = class(TComparer<TQueryHistoryItem>)
198198

199199
TMainForm = class(TExtForm)
200200
actDataEditWithoutLookup: TAction;
201+
actTreeShowColumns: TAction;
201202
MainMenu1: TMainMenu;
202203
MainMenuFile: TMenuItem;
203204
FileNewItem: TMenuItem;
204205
MainMenuHelp: TMenuItem;
205206
FollowForeignKey: TMenuItem;
206207
menuDataEditWithoutLookup: TMenuItem;
208+
menuTreeShowColumns2: TMenuItem;
209+
menuTreeShowColumns1: TMenuItem;
207210
menuRenameSnippet: TMenuItem;
208211
N1: TMenuItem;
209212
FileExitItem: TMenuItem;
@@ -816,6 +819,7 @@ TMainForm = class(TExtForm)
816819
Copyformattedtext1: TMenuItem;
817820
procedure actCreateDBObjectExecute(Sender: TObject);
818821
procedure actDataEditWithoutLookupExecute(Sender: TObject);
822+
procedure actTreeShowColumnsExecute(Sender: TObject);
819823
procedure menuConnectionsPopup(Sender: TObject);
820824
procedure actExitApplicationExecute(Sender: TObject);
821825
procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
@@ -1874,6 +1878,7 @@ procedure TMainForm.FormDestroy(Sender: TObject);
18741878
AppSettings.WriteInt(asCompletionProposalNbLinesInWindow, SynCompletionProposal.NbLinesInWindow);
18751879
AppSettings.WriteInt(asDbtreewidth, pnlLeft.width);
18761880
AppSettings.WriteBool(asGroupTreeObjects, actGroupObjects.Checked);
1881+
AppSettings.WriteBool(asTreeShowColumns, actTreeShowColumns.Checked);
18771882
AppSettings.WriteInt(asDataPreviewHeight, pnlPreview.Height);
18781883
AppSettings.WriteBool(asDataPreviewEnabled, actDataPreview.Checked);
18791884
AppSettings.WriteInt(asLogHeight, SynMemoSQLLog.Height);
@@ -2104,6 +2109,7 @@ procedure TMainForm.FormCreate(Sender: TObject);
21042109

21052110
// Display options, and database tree options
21062111
actGroupObjects.Checked := AppSettings.ReadBool(asGroupTreeObjects);
2112+
actTreeShowColumns.Checked := AppSettings.ReadBool(asTreeShowColumns);
21072113
actDisplayObjectSize.Checked := AppSettings.ReadBool(asDisplayObjectSizeColumn);
21082114
actDisplayObjectSizeExecute(nil);
21092115
actDisplayLogPanel.Checked := AppSettings.ReadBool(asDisplayLogPanel);
@@ -4558,6 +4564,13 @@ procedure TMainForm.actCreateDBObjectExecute(Sender: TObject);
45584564
end;
45594565

45604566

4567+
procedure TMainForm.actTreeShowColumnsExecute(Sender: TObject);
4568+
begin
4569+
// Show columns in table nodes on tree
4570+
RefreshTree(nil);
4571+
end;
4572+
4573+
45614574
procedure TMainForm.actEmptyTablesExecute(Sender: TObject);
45624575
var
45634576
TableOrView: TDBObject;
@@ -9896,6 +9909,14 @@ procedure TMainForm.DBtreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node:
98969909
Item, ParentObj: PDBObject;
98979910
DBObjects: TDBObjectList;
98989911
Columns: TTableColumnList;
9912+
9913+
function TreeShowColumns: Boolean;
9914+
begin
9915+
Result := Item.NodeType = lntTable;
9916+
if Sender = DBtree then // optional in dbtree
9917+
Result := actTreeShowColumns.Checked;
9918+
end;
9919+
98999920
begin
99009921
Item := Sender.GetNodeData(Node);
99019922
if (not Assigned(ParentNode)) or (ParentNode = nil) then begin
@@ -9928,14 +9949,14 @@ procedure TMainForm.DBtreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node:
99289949
end else begin
99299950
DBObjects := ParentObj.Connection.GetDBObjects(ParentObj.Database);
99309951
Item^ := DBObjects[Node.Index];
9931-
if Item.NodeType = lntTable then
9952+
if TreeShowColumns then
99329953
Include(InitialStates, ivsHasChildren);
99339954
end;
99349955
end;
99359956
lntGroup: begin
99369957
DBObjects := ParentObj.Connection.GetDBObjects(ParentObj.Database, False, ParentObj.GroupType);
99379958
Item^ := DBObjects[Node.Index];
9938-
if Item.NodeType = lntTable then
9959+
if TreeShowColumns then
99399960
Include(InitialStates, ivsHasChildren);
99409961
end;
99419962
lntTable: begin

0 commit comments

Comments
 (0)