From 8ce99dc2a6a0445ddeaaeb4fce7d235c0493a368 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 3 Jun 2010 02:26:38 +0000 Subject: [PATCH] IDE, Options, remember fold state of main-tree git-svn-id: trunk@25857 - --- ide/environmentopts.pp | 34 +++++++++++++++++++++-- ide/frames/editor_mouseaction_options.pas | 6 ++++ ide/ideoptionsdlg.lfm | 3 +- ide/ideoptionsdlg.pas | 33 ++++++++++++++++++++-- ideintf/ideoptionsintf.pas | 14 +++++++++- 5 files changed, 83 insertions(+), 7 deletions(-) diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index 4422310faf..f68f232783 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -842,8 +842,9 @@ var XMLConfig: TXMLConfig; OldDebuggerType: TDebuggerType; Path: String; CurPath: String; - i: Integer; + i, j: Integer; name: String; + Rec: PIDEOptionsGroupRec; procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string); var i:integer; @@ -1159,7 +1160,19 @@ begin // object inspector FObjectInspectorOptions.Load; FObjectInspectorOptions.SaveBounds:=false; - + + for i := 0 to IDEEditorGroups.Count - 1 do begin + Rec := IDEEditorGroups[i]; + name := Rec^.GroupClass.ClassName; + Rec^.Collapsed := XMLConfig.GetValue('OptionDialog/Tree/' + name + '/Value', False); + if Rec^.Items <> nil then begin + for j := 0 to Rec^.Items.Count - 1 do begin + Rec^.Items[j]^.Collapsed := XMLConfig.GetValue('OptionDialog/Tree/' + name + + '/' + Rec^.Items[j]^.EditorClass.ClassName + '/Value', False); + end; + end; + end; + FileUpdated; except // ToDo @@ -1171,6 +1184,9 @@ end; procedure TEnvironmentOptions.Save(OnlyDesktop: boolean); var XMLConfig: TXMLConfig; Path: String; + i, j: Integer; + name: String; + Rec: PIDEOptionsGroupRec; procedure SaveBackupInfo(var BackupInfo: TBackupInfo; Path:string); var i:integer; @@ -1415,6 +1431,20 @@ begin FObjectInspectorOptions.SaveBounds:=false; FObjectInspectorOptions.Save; + for i := 0 to IDEEditorGroups.Count - 1 do begin + Rec := IDEEditorGroups[i]; + name := Rec^.GroupClass.ClassName; + XMLConfig.SetDeleteValue('OptionDialog/Tree/' + name + '/Value', + Rec^.Collapsed, False); + if Rec^.Items <> nil then begin + for j := 0 to Rec^.Items.Count - 1 do begin + XMLConfig.SetDeleteValue('OptionDialog/Tree/' + name + + '/' + Rec^.Items[j]^.EditorClass.ClassName + '/Value', + Rec^.Items[j]^.Collapsed, False); + end; + end; + end; + XMLConfig.Flush; FileUpdated; except diff --git a/ide/frames/editor_mouseaction_options.pas b/ide/frames/editor_mouseaction_options.pas index 1ad852f461..7494665678 100644 --- a/ide/frames/editor_mouseaction_options.pas +++ b/ide/frames/editor_mouseaction_options.pas @@ -107,6 +107,7 @@ type procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; + class function DefaultCollapseChildNodes: Boolean; override; end; implementation @@ -393,6 +394,11 @@ begin Result := TEditorOptions; end; +class function TEditorMouseOptionsFrame.DefaultCollapseChildNodes: Boolean; +begin + Result := True; +end; + initialization RegisterIDEOptionsEditor(GroupEditor, TEditorMouseOptionsFrame, EdtOptionsMouse); end. diff --git a/ide/ideoptionsdlg.lfm b/ide/ideoptionsdlg.lfm index ea1b62cb90..c559014b16 100644 --- a/ide/ideoptionsdlg.lfm +++ b/ide/ideoptionsdlg.lfm @@ -3,7 +3,6 @@ object IDEOptionsDialog: TIDEOptionsDialog Height = 500 Top = 304 Width = 700 - ActiveControl = CategoryTree BorderIcons = [biSystemMenu] Caption = 'IDEOptionsDialog' ClientHeight = 500 @@ -45,6 +44,8 @@ object IDEOptionsDialog: TIDEOptionsDialog ReadOnly = True TabOrder = 0 OnChange = CategoryTreeChange + OnCollapsed = CategoryTreeCollapsed + OnExpanded = CategoryTreeExpanded OnKeyDown = CategoryTreeKeyDown Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] end diff --git a/ide/ideoptionsdlg.pas b/ide/ideoptionsdlg.pas index 4dca37b111..a57e387c0d 100644 --- a/ide/ideoptionsdlg.pas +++ b/ide/ideoptionsdlg.pas @@ -41,8 +41,9 @@ type TIDEOptionsDialog = class(TAbstractOptionsEditorDialog) ButtonPanel: TButtonPanel; CategoryTree: TTreeView; - procedure CategoryTreeChange(Sender: TObject; Node: TTreeNode); + procedure CategoryTreeCollapsed(Sender: TObject; Node: TTreeNode); + procedure CategoryTreeExpanded(Sender: TObject; Node: TTreeNode); procedure CategoryTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormShow(Sender: TObject); procedure HelpButtonClick(Sender: TObject); @@ -152,6 +153,26 @@ begin end; end; +procedure TIDEOptionsDialog.CategoryTreeCollapsed(Sender: TObject; Node: TTreeNode); +begin + if node.Deleting then exit; + if (Node.Data <> nil) then + TAbstractIDEOptionsEditor(Node.Data).Rec^.Collapsed := True + else + if (Node.GetFirstChild <> nil) and (Node.GetFirstChild.Data <> nil) then + TAbstractIDEOptionsEditor(Node.GetFirstChild.Data).GroupRec^.Collapsed := True; +end; + +procedure TIDEOptionsDialog.CategoryTreeExpanded(Sender: TObject; Node: TTreeNode); +begin + if node.Deleting then exit; + if (Node.Data <> nil) then + TAbstractIDEOptionsEditor(Node.Data).Rec^.Collapsed := False + else + if (Node.GetFirstChild <> nil) and (Node.GetFirstChild.Data <> nil) then + TAbstractIDEOptionsEditor(Node.GetFirstChild.Data).GroupRec^.Collapsed := False; +end; + procedure TIDEOptionsDialog.CategoryTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var @@ -409,11 +430,17 @@ begin ItemNode := CategoryTree.Items.AddChild(ItemParent, Instance.GetTitle); ItemNode.Data := Instance; - ItemParent.Expanded := True; + if ItemParent.Data <> nil then begin + Instance := TAbstractIDEOptionsEditor(ItemParent.Data); + ItemParent.Expanded := not Instance.Rec^.Collapsed; + end; if IDEEditorGroups.LastSelected = Rec^.Items[j] then SelectNode := ItemNode; end; - GroupNode.Expanded := True; + if (GroupNode.GetFirstChild <> nil) and (GroupNode.GetFirstChild.Data <> nil) then + TAbstractIDEOptionsEditor(GroupNode.GetFirstChild.Data).GroupRec := Rec; + GroupNode.Expanded := not Rec^.Collapsed; + //GroupNode.Data := Rec; end; end; if SelectNode <> nil then diff --git a/ideintf/ideoptionsintf.pas b/ideintf/ideoptionsintf.pas index cfa5941de2..96e3ac7af7 100644 --- a/ideintf/ideoptionsintf.pas +++ b/ideintf/ideoptionsintf.pas @@ -70,6 +70,7 @@ type { TAbstractIDEOptionsEditor } PIDEOptionsEditorRec = ^TIDEOptionsEditorRec; + PIDEOptionsGroupRec = ^TIDEOptionsGroupRec; TAbstractIDEOptionsEditor = class(TFrame) private @@ -77,6 +78,7 @@ type FOnLoadIDEOptions: TOnLoadIDEOptions; FOnSaveIDEOptions: TOnSaveIDEOptions; FRec: PIDEOptionsEditorRec; + FGroupRec: PIDEOptionsGroupRec; protected procedure DoOnChange; public @@ -86,11 +88,13 @@ type procedure ReadSettings(AOptions: TAbstractIDEOptions); virtual; abstract; procedure WriteSettings(AOptions: TAbstractIDEOptions); virtual; abstract; class function SupportedOptionsClass: TAbstractIDEOptionsClass; virtual; abstract; + class function DefaultCollapseChildNodes: Boolean; virtual; property OnLoadIDEOptions: TOnLoadIDEOptions read FOnLoadIDEOptions write FOnLoadIDEOptions; property OnSaveIDEOptions: TOnSaveIDEOptions read FOnSaveIDEOptions write FOnSaveIDEOptions; property OnChange: TNotifyEvent read FOnChange write FOnChange; property Rec: PIDEOptionsEditorRec read FRec write FRec; + property GroupRec: PIDEOptionsGroupRec read FGroupRec write FGroupRec; end; TAbstractIDEOptionsEditorClass = class of TAbstractIDEOptionsEditor; @@ -98,6 +102,7 @@ type Index: Integer; Parent: Integer; EditorClass: TAbstractIDEOptionsEditorClass; + Collapsed: Boolean; end; { TIDEOptionsEditorList } @@ -119,8 +124,8 @@ type Index: Integer; GroupClass: TAbstractIDEOptionsClass; Items: TIDEOptionsEditorList; + Collapsed: Boolean; end; - PIDEOptionsGroupRec = ^TIDEOptionsGroupRec; { TIDEOptionsGroupList } @@ -340,6 +345,11 @@ begin Result := True; end; +class function TAbstractIDEOptionsEditor.DefaultCollapseChildNodes: Boolean; +begin + Result := False; +end; + { TIDEOptionsEditorList } function TIDEOptionsEditorList.GetItem(AIndex: Integer): PIDEOptionsEditorRec; @@ -386,6 +396,7 @@ begin New(Result); Result^.Index := AIndex; Result^.Parent := AParent; + Result^.Collapsed := AEditorClass.DefaultCollapseChildNodes; inherited Add(Result); end; @@ -481,6 +492,7 @@ begin New(Result); Result^.Index := AGroupIndex; Result^.Items := nil; + Result^.Collapsed := False; inherited Add(Result); end;