Group tree options in popup submenu, and introduce new option "Auto expand on click". Fixes issue #3061.

This commit is contained in:
Ansgar Becker
2012-12-26 08:14:10 +00:00
parent e25ea34794
commit 39b69226e1
3 changed files with 57 additions and 34 deletions

View File

@ -172,7 +172,7 @@ type
asFieldEditorSet, asFieldNullBackground, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile, asFieldEditorSet, asFieldNullBackground, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile,
asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle, asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle,
asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder, asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder,
asRecentFilter, asDateTimeEditorCursorPos, asAppLanguage); asRecentFilter, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand);
TAppSetting = record TAppSetting = record
Name: String; Name: String;
Session: Boolean; Session: Boolean;
@ -3152,6 +3152,7 @@ begin
InitSetting(asRecentFilter, '%s', 0, False, '', True); InitSetting(asRecentFilter, '%s', 0, False, '', True);
InitSetting(asDateTimeEditorCursorPos, 'DateTimeEditor_CursorPos_Type%s', 0); InitSetting(asDateTimeEditorCursorPos, 'DateTimeEditor_CursorPos_Type%s', 0);
InitSetting(asAppLanguage, 'Language', 0, False, ''); InitSetting(asAppLanguage, 'Language', 0, False, '');
InitSetting(asAutoExpand, 'AutoExpand', 0, False);
end; end;

View File

@ -448,6 +448,7 @@ object MainForm: TMainForm
item item
Alignment = taRightJustify Alignment = taRightJustify
MinWidth = 0 MinWidth = 0
Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coAllowFocus]
Position = 1 Position = 1
Width = 55 Width = 55
WideText = 'Size' WideText = 'Size'
@ -8767,6 +8768,8 @@ object MainForm: TMainForm
ImageIndex = 88 ImageIndex = 88
OnClick = menuTreeCollapseAllClick OnClick = menuTreeCollapseAllClick
end end
object menuTreeOptions: TMenuItem
Caption = 'Tree style options'
object menuGroupObjects: TMenuItem object menuGroupObjects: TMenuItem
Action = actGroupObjects Action = actGroupObjects
AutoCheck = True AutoCheck = True
@ -8775,9 +8778,14 @@ object MainForm: TMainForm
Caption = 'Display size of objects' Caption = 'Display size of objects'
OnClick = menuShowSizeColumnClick OnClick = menuShowSizeColumnClick
end end
object menuAutoExpand: TMenuItem
Caption = 'Auto expand on click'
OnClick = menuAutoExpandClick
end
object menuSelectBGColor: TMenuItem object menuSelectBGColor: TMenuItem
Action = actSelectTreeBackground Action = actSelectTreeBackground
end end
end
object menuPrint: TMenuItem object menuPrint: TMenuItem
Action = actPrintList Action = actPrintList
end end

View File

@ -562,6 +562,8 @@ type
actExplainAnalyzeCurrentQuery: TAction; actExplainAnalyzeCurrentQuery: TAction;
Explaincurrentquery1: TMenuItem; Explaincurrentquery1: TMenuItem;
Explainanalyzerforcurrentquery1: TMenuItem; Explainanalyzerforcurrentquery1: TMenuItem;
menuAutoExpand: TMenuItem;
menuTreeOptions: TMenuItem;
procedure actCreateDBObjectExecute(Sender: TObject); procedure actCreateDBObjectExecute(Sender: TObject);
procedure menuConnectionsPopup(Sender: TObject); procedure menuConnectionsPopup(Sender: TObject);
procedure actExitApplicationExecute(Sender: TObject); procedure actExitApplicationExecute(Sender: TObject);
@ -888,6 +890,7 @@ type
procedure popupSqlLogPopup(Sender: TObject); procedure popupSqlLogPopup(Sender: TObject);
procedure actExplainAnalyzeCurrentQueryExecute(Sender: TObject); procedure actExplainAnalyzeCurrentQueryExecute(Sender: TObject);
procedure menuQueryExplainClick(Sender: TObject); procedure menuQueryExplainClick(Sender: TObject);
procedure menuAutoExpandClick(Sender: TObject);
private private
FLastHintMousepos: TPoint; FLastHintMousepos: TPoint;
FLastHintControlIndex: Integer; FLastHintControlIndex: Integer;
@ -1531,11 +1534,10 @@ begin
// Database tree options // Database tree options
actGroupObjects.Checked := AppSettings.ReadBool(asGroupTreeObjects); actGroupObjects.Checked := AppSettings.ReadBool(asGroupTreeObjects);
menuShowSizeColumn.Checked := AppSettings.ReadBool(asDisplayObjectSizeColumn); if AppSettings.ReadBool(asDisplayObjectSizeColumn) then
if menuShowSizeColumn.Checked then menuShowSizeColumn.Click;
DBtree.Header.Columns[1].Options := DBtree.Header.Columns[1].Options + [coVisible] if AppSettings.ReadBool(asAutoExpand) then
else menuAutoExpand.Click;
DBtree.Header.Columns[1].Options := DBtree.Header.Columns[1].Options - [coVisible];
// Restore width of columns of all VirtualTrees // Restore width of columns of all VirtualTrees
RestoreListSetup(ListDatabases); RestoreListSetup(ListDatabases);
@ -5607,12 +5609,10 @@ begin
actEmptyTables.Enabled := Obj.NodeType in [lntTable, lntView]; actEmptyTables.Enabled := Obj.NodeType in [lntTable, lntView];
actRunRoutines.Enabled := Obj.NodeType in [lntProcedure, lntFunction]; actRunRoutines.Enabled := Obj.NodeType in [lntProcedure, lntFunction];
menuEditObject.Enabled := IsDbOrObject; menuEditObject.Enabled := IsDbOrObject;
// Show certain items which are valid only here // Enable certain items which are valid only here
menuTreeExpandAll.Visible := True; menuTreeExpandAll.Enabled := True;
menuTreeCollapseAll.Visible := True; menuTreeCollapseAll.Enabled := True;
actGroupObjects.Visible := True; menuTreeOptions.Enabled := True;
menuShowSizeColumn.Visible := True;
actSelectTreeBackground.Visible := True;
end else begin end else begin
HasFocus := Assigned(ListTables.FocusedNode); HasFocus := Assigned(ListTables.FocusedNode);
actCreateDatabase.Enabled := False; actCreateDatabase.Enabled := False;
@ -5630,11 +5630,9 @@ begin
Obj := ListTables.GetNodeData(ListTables.FocusedNode); Obj := ListTables.GetNodeData(ListTables.FocusedNode);
actCopyTable.Enabled := Obj.NodeType in [lntTable, lntView]; actCopyTable.Enabled := Obj.NodeType in [lntTable, lntView];
end; end;
menuTreeExpandAll.Visible := False; menuTreeExpandAll.Enabled := False;
menuTreeCollapseAll.Visible := False; menuTreeCollapseAll.Enabled := False;
actGroupObjects.Visible := False; menuTreeOptions.Enabled := False;
menuShowSizeColumn.Visible := False;
actSelectTreeBackground.Visible := False;
end; end;
actCreateView.Enabled := actCreateView.Enabled and (ActiveConnection.ServerVersionInt >= 50001); actCreateView.Enabled := actCreateView.Enabled and (ActiveConnection.ServerVersionInt >= 50001);
actCreateRoutine.Enabled := actCreateRoutine.Enabled and (ActiveConnection.ServerVersionInt >= 50003); actCreateRoutine.Enabled := actCreateRoutine.Enabled and (ActiveConnection.ServerVersionInt >= 50003);
@ -8029,16 +8027,32 @@ end;
procedure TMainForm.menuShowSizeColumnClick(Sender: TObject); procedure TMainForm.menuShowSizeColumnClick(Sender: TObject);
var var
NewVal: Boolean; Item: TMenuItem;
begin begin
NewVal := not TMenuItem(Sender).Checked; if coVisible in DBtree.Header.Columns[1].Options then
TMenuItem(Sender).Checked := newVal; DBtree.Header.Columns[1].Options := DBtree.Header.Columns[1].Options - [coVisible]
if NewVal then
DBtree.Header.Columns[1].Options := DBtree.Header.Columns[1].Options + [coVisible]
else else
DBtree.Header.Columns[1].Options := DBtree.Header.Columns[1].Options - [coVisible]; DBtree.Header.Columns[1].Options := DBtree.Header.Columns[1].Options + [coVisible];
Item := Sender as TMenuItem;
Item.Checked := coVisible in DBtree.Header.Columns[1].Options;
AppSettings.ResetPath; AppSettings.ResetPath;
AppSettings.WriteBool(asDisplayObjectSizeColumn, NewVal); AppSettings.WriteBool(asDisplayObjectSizeColumn, Item.Checked);
end;
procedure TMainForm.menuAutoExpandClick(Sender: TObject);
var
Item: TMenuItem;
begin
// Activate expand on click tree feature
if toAutoExpand in DBtree.TreeOptions.AutoOptions then
DBtree.TreeOptions.AutoOptions := DBtree.TreeOptions.AutoOptions - [toAutoExpand]
else
DBtree.TreeOptions.AutoOptions := DBtree.TreeOptions.AutoOptions + [toAutoExpand];
Item := Sender as TMenuItem;
Item.Checked := toAutoExpand in DBtree.TreeOptions.AutoOptions;
AppSettings.ResetPath;
AppSettings.WriteBool(asAutoExpand, Item.Checked);
end; end;