projinspect, move list of configs to a combo box

This commit is contained in:
Basile Burg 2020-09-13 00:19:10 +02:00
parent 21c143fc25
commit df4773f6ce
3 changed files with 59 additions and 69 deletions

View File

@ -4,6 +4,10 @@
- Project inspector: moved the list of configuration to a combo box over the file tree. - Project inspector: moved the list of configuration to a combo box over the file tree.
## Bugs fixed
- GDB commander, editor: bad expression returned when using mouse motion to get value of an expression within square brackets.
# v3.9.7 # v3.9.7
## Enhancements ## Enhancements

View File

@ -23,8 +23,8 @@ inherited ProjectInspectWidget: TProjectInspectWidget
PopupMenu = nil PopupMenu = nil
object Tree: TTreeView[0] object Tree: TTreeView[0]
Left = 2 Left = 2
Height = 218 Height = 184
Top = 2 Top = 36
Width = 420 Width = 420
Align = alClient Align = alClient
AutoExpand = True AutoExpand = True
@ -43,11 +43,26 @@ inherited ProjectInspectWidget: TProjectInspectWidget
OnSelectionChanged = TreeSelectionChanged OnSelectionChanged = TreeSelectionChanged
Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoThemedDraw] Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoThemedDraw]
Items.Data = { Items.Data = {
F9FFFFFF020002000000000000000000000000000000FFFFFFFF000000000000 F9FFFFFF020001000000000000000000000000000000FFFFFFFF000000000000
0000000C000000536F757263652066696C6573010000000100000001000000FF 0000000C000000536F757263652066696C6573
FFFFFF0000000000000000000E000000436F6E66696775726174696F6E73
} }
end end
object selConf: TComboBox[1]
Left = 4
Height = 30
Hint = 'select the active configuaration'
Top = 2
Width = 416
Align = alTop
BorderSpacing.Left = 4
BorderSpacing.Top = 2
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
ItemHeight = 0
OnChange = selConfChange
Style = csDropDownList
TabOrder = 1
end
end end
inherited toolbar: TDexedToolBar inherited toolbar: TDexedToolBar
Width = 416 Width = 416

View File

@ -6,9 +6,9 @@ interface
uses uses
Classes, SysUtils, TreeFilterEdit, Forms, Controls, Graphics, actnlist, Classes, SysUtils, TreeFilterEdit, Forms, Controls, Graphics, actnlist,
Dialogs, ExtCtrls, ComCtrls, Menus, Buttons, lcltype, u_ceproject, u_interfaces, Dialogs, ExtCtrls, ComCtrls, Menus, Buttons, lcltype, StdCtrls, u_ceproject,
u_common, u_widget, u_observer, u_dialogs, u_sharedres, u_dsgncontrols, u_interfaces, u_common, u_widget, u_observer, u_dialogs, u_sharedres,
u_dubproject, u_synmemo, u_stringrange, u_writableComponent; u_dsgncontrols, u_dubproject, u_synmemo, u_stringrange, u_writableComponent;
type type
@ -28,6 +28,7 @@ type
btnRemFile: TDexedToolButton; btnRemFile: TDexedToolButton;
btnRemFold: TDexedToolButton; btnRemFold: TDexedToolButton;
btnTree: TDexedToolButton; btnTree: TDexedToolButton;
selConf: TComboBox;
Tree: TTreeView; Tree: TTreeView;
TreeFilterEdit1: TTreeFilterEdit; TreeFilterEdit1: TTreeFilterEdit;
procedure btnAddFileClick(Sender: TObject); procedure btnAddFileClick(Sender: TObject);
@ -37,6 +38,7 @@ type
procedure btnTreeClick(Sender: TObject); procedure btnTreeClick(Sender: TObject);
procedure btnReloadClick(Sender: TObject); procedure btnReloadClick(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const fnames: array of String); procedure FormDropFiles(Sender: TObject; const fnames: array of String);
procedure selConfChange(Sender: TObject);
procedure toolbarResize(Sender: TObject); procedure toolbarResize(Sender: TObject);
procedure TreeClick(Sender: TObject); procedure TreeClick(Sender: TObject);
procedure TreeDeletion(Sender: TObject; Node: TTreeNode); procedure TreeDeletion(Sender: TObject; Node: TTreeNode);
@ -49,10 +51,9 @@ type
procedure setToolBarFlat(value: boolean); override; procedure setToolBarFlat(value: boolean); override;
private private
fActOpenFile: TAction; fActOpenFile: TAction;
fActSelConf: TAction;
fActBuildConf: TAction; fActBuildConf: TAction;
fProj: ICommonProject; fProj: ICommonProject;
fFileNode, fConfNode: TTreeNode; fFileNode: TTreeNode;
fLastFileOrFolder: string; fLastFileOrFolder: string;
fSymStringExpander: ISymStringExpander; fSymStringExpander: ISymStringExpander;
fImages: TImageList; fImages: TImageList;
@ -100,12 +101,8 @@ begin
fSymStringExpander:= getSymStringExpander; fSymStringExpander:= getSymStringExpander;
fActOpenFile := TAction.Create(self); fActOpenFile := TAction.Create(self);
fActOpenFile.Caption := 'Open file in editor'; fActOpenFile.Caption := 'Open file(s) in editor';
fActOpenFile.OnExecute := @actOpenFileExecute; fActOpenFile.OnExecute := @actOpenFileExecute;
fActSelConf := TAction.Create(self);
fActSelConf.Caption := 'Select configuration';
fActSelConf.OnExecute := @actOpenFileExecute;
fActSelConf.OnUpdate := @actUpdate;
fActBuildConf:= TAction.Create(self); fActBuildConf:= TAction.Create(self);
fActBuildConf.Caption := 'Build configuration'; fActBuildConf.Caption := 'Build configuration';
fActBuildConf.OnExecute := @actBuildExecute; fActBuildConf.OnExecute := @actBuildExecute;
@ -158,7 +155,6 @@ begin
Tree.OnDblClick := @TreeDblClick; Tree.OnDblClick := @TreeDblClick;
fFileNode := Tree.Items[0]; fFileNode := Tree.Items[0];
fConfNode := Tree.Items[1];
Tree.Images := fImages; Tree.Images := fImages;
Tree.PopupMenu := contextMenu; Tree.PopupMenu := contextMenu;
@ -218,15 +214,14 @@ end;
function TProjectInspectWidget.contextActionCount: integer; function TProjectInspectWidget.contextActionCount: integer;
begin begin
exit(3); exit(2);
end; end;
function TProjectInspectWidget.contextAction(index: integer): TAction; function TProjectInspectWidget.contextAction(index: integer): TAction;
begin begin
case index of case index of
0: exit(fActOpenFile); 0: exit(fActOpenFile);
1: exit(fActSelConf); 1: exit(fActBuildConf);
2: exit(fActBuildConf);
else exit(nil); else exit(nil);
end; end;
end; end;
@ -362,6 +357,8 @@ begin
if Tree.Selected.isAssigned then if Tree.Selected.isAssigned then
begin begin
Tree.MultiSelect := Tree.Selected.Parent = fFileNode; Tree.MultiSelect := Tree.Selected.Parent = fFileNode;
if Tree.Selected.isNotAssigned() then
exit;
if not (Tree.Selected.Parent = fFileNode) then if not (Tree.Selected.Parent = fFileNode) then
begin begin
Tree.MultiSelect := false; Tree.MultiSelect := false;
@ -396,43 +393,32 @@ end;
procedure TProjectInspectWidget.TreeDblClick(sender: TObject); procedure TProjectInspectWidget.TreeDblClick(sender: TObject);
var var
fname: string; f: string;
i: integer; i: integer;
begin begin
if fProj.isNotAssigned or Tree.Selected.isNotAssigned then if fProj.isNotAssigned or Tree.Selected.isNotAssigned then
exit; exit;
for i := 0 to Tree.SelectionCount - 1 do
if Tree.Selected.Parent <> fConfNode then if Tree.Selections[i].Data.isAssigned() then
begin begin
if Tree.Selected.Data.isAssigned then f := PString(Tree.Selections[i].Data)^;
begin if isEditable(f.extractFileExt) and f.fileExists then
fname := PString(Tree.Selected.Data)^; getMultiDocHandler.openDocument(f);
if isEditable(fname.extractFileExt) and fname.fileExists then
getMultiDocHandler.openDocument(fname);
end;
end
else
begin
i := Tree.Selected.Index;
fProj.setActiveConfigurationIndex(i);
beginDelayedUpdate;
end; end;
Tree.Selected := nil;
end; end;
procedure TProjectInspectWidget.actUpdate(sender: TObject); procedure TProjectInspectWidget.actUpdate(sender: TObject);
begin begin
fActSelConf.Enabled := false;
fActOpenFile.Enabled := false; fActOpenFile.Enabled := false;
fActBuildConf.Enabled:= false; fActBuildConf.Enabled:= false;
if Tree.Selected.isNotAssigned then if Tree.Selected.isNotAssigned then
exit; exit;
fActSelConf.Enabled := Tree.Selected.Parent = fConfNode; fActBuildConf.Enabled := true;
fActBuildConf.Enabled := Tree.Selected.Parent = fConfNode;
fActOpenFile.Enabled := Tree.Selected.ImageIndex = 2; fActOpenFile.Enabled := Tree.Selected.ImageIndex = 2;
end; end;
procedure TProjectInspectWidget.DetectNewDubSources(const document: TDexedMemo procedure TProjectInspectWidget.DetectNewDubSources(const document: TDexedMemo);
);
begin begin
if fProj.isNotAssigned or (fProj.getFormat <> pfDUB) then if fProj.isNotAssigned or (fProj.getFormat <> pfDUB) then
exit; exit;
@ -634,6 +620,13 @@ begin
end; end;
end; end;
procedure TProjectInspectWidget.selConfChange(Sender: TObject);
begin
if fProj.isNotAssigned or selConf.ItemIndex.equals(-1) or selConf.Items.Count.equals(0) then
exit;
fProj.setActiveConfigurationIndex(selConf.ItemIndex);
end;
procedure TProjectInspectWidget.toolbarResize(Sender: TObject); procedure TProjectInspectWidget.toolbarResize(Sender: TObject);
begin begin
TreeFilterEdit1.Width := toolbar.Width - TreeFilterEdit1.Left - TreeFilterEdit1.BorderSpacing.Around; TreeFilterEdit1.Width := toolbar.Width - TreeFilterEdit1.Left - TreeFilterEdit1.BorderSpacing.Around;
@ -656,7 +649,6 @@ var
begin begin
if Tree.Selected.isAssigned then if Tree.Selected.isAssigned then
sel := Tree.Selected.GetTextPath; sel := Tree.Selected.GetTextPath;
fConfNode.DeleteChildren;
fFileNode.DeleteChildren; fFileNode.DeleteChildren;
if fProj.isNotAssigned then if fProj.isNotAssigned then
@ -705,36 +697,15 @@ begin
end; end;
end; end;
end; end;
j := fProj.getActiveConfigurationIndex;
for i := 0 to fProj.configurationCount-1 do
begin
conf := fProj.configurationName(i);
if i = j then
conf += ' (active)';
itm := Tree.Items.AddChild(fConfNode, conf);
if i = j then
begin
itm.ImageIndex := 4;
itm.SelectedIndex:= 4;
end
else
begin
itm.ImageIndex := 3;
itm.SelectedIndex:= 3;
end;
end;
if sel.isNotEmpty then
begin
itm := Tree.Items.FindNodeWithTextPath(sel);
if itm.isAssigned then
begin
itm.Selected := true;
itm.MakeVisible;
end;
end;
Tree.EndUpdate; Tree.EndUpdate;
selConf.Items.BeginUpdate();
j := fProj.getActiveConfigurationIndex;
selConf.Items.Clear;
for i := 0 to fProj.configurationCount-1 do
selConf.Items.Add(fProj.configurationName(i));
selConf.ItemIndex := j;
selConf.Items.EndUpdate();
end; end;
{$ENDREGION --------------------------------------------------------------------} {$ENDREGION --------------------------------------------------------------------}