IDE: Store ManyBuildModes selection in project options instead of environment options.

git-svn-id: trunk@62150 -
This commit is contained in:
juha 2019-10-31 23:12:43 +00:00
parent bab4d7305b
commit 715c8be36f
4 changed files with 40 additions and 20 deletions

View File

@ -110,12 +110,13 @@ type
TBuildModesCheckList = class TBuildModesCheckList = class
private private
FListForm: TGenericCheckListForm; FListForm: TGenericCheckListForm;
function IsSelected(AIndex: Integer): Boolean;
procedure SaveManyModesSelection;
procedure SelectFirst;
function Show: Boolean; function Show: Boolean;
public public
constructor Create(InfoCaption: String); constructor Create(InfoCaption: String);
destructor Destroy; override; destructor Destroy; override;
function IsSelected(AIndex: Integer): Boolean;
procedure SelectFirst;
end; end;
function ShowBuildModesDlg(aShowSession: Boolean): TModalResult; function ShowBuildModesDlg(aShowSession: Boolean): TModalResult;
@ -330,10 +331,11 @@ begin
Result := False; Result := False;
ModeCnt := 0; ModeCnt := 0;
if PrepareForCompileWithMsg <> mrOk then exit; if PrepareForCompileWithMsg <> mrOk then exit;
BMList:=TBuildModesCheckList.Create(lisCompileFollowingModes); BMList := TBuildModesCheckList.Create(lisCompileFollowingModes);
ModeList := TList.Create; ModeList := TList.Create;
try try
if not BMList.Show then Exit; if not BMList.Show then Exit;
BMList.SaveManyModesSelection; // Remember the selection for next time.
ActiveMode := Project1.ActiveBuildMode; ActiveMode := Project1.ActiveBuildMode;
BuildActiveMode := False; BuildActiveMode := False;
// Collect modes to be built. // Collect modes to be built.
@ -455,6 +457,11 @@ begin
begin begin
CurMode.Identifier:=Value; CurMode.Identifier:=Value;
FillBuildModesGrid; FillBuildModesGrid;
// Rename in many BuildModes selection.
i:=fBuildModes.ManyBuildModes.IndexOf(OldValue);
if i>=0 then
fBuildModes.ManyBuildModes[i]:=Value;
// Rename in the ModeMatrix settings frame.
ModeMatrixFrame.Grid.RenameMode(OldValue, Value); ModeMatrixFrame.Grid.RenameMode(OldValue, Value);
end; end;
end; end;
@ -837,35 +844,27 @@ constructor TBuildModesCheckList.Create(InfoCaption: String);
var var
i: Integer; i: Integer;
BM: String; BM: String;
ManyBMs: TStringList;
begin begin
FListForm:=TGenericCheckListForm.Create(Nil); FListForm:=TGenericCheckListForm.Create(Nil);
//lisApplyForBuildModes = 'Apply for build modes:'; //lisApplyForBuildModes = 'Apply for build modes:';
FListForm.Caption:=lisAvailableProjectBuildModes; FListForm.Caption:=lisAvailableProjectBuildModes;
FListForm.InfoLabel.Caption:=InfoCaption; FListForm.InfoLabel.Caption:=InfoCaption;
ManyBMs:=Project1.BuildModes.ManyBuildModes;
// Backwards compatibility. Many BuildModes value used to be in EnvironmentOptions.
if ManyBMs.Count=0 then
ManyBMs:=EnvironmentOptions.ManyBuildModesSelection;
// Add project build modes to a CheckListBox. // Add project build modes to a CheckListBox.
for i:=0 to Project1.BuildModes.Count-1 do begin for i:=0 to Project1.BuildModes.Count-1 do begin
BM:=Project1.BuildModes[i].Identifier; BM:=Project1.BuildModes[i].Identifier;
FListForm.CheckListBox1.Items.Add(BM); FListForm.CheckListBox1.Items.Add(BM);
if EnvironmentOptions.ManyBuildModesSelection.IndexOf(BM) >= 0 then if ManyBMs.IndexOf(BM) >= 0 then
FListForm.CheckListBox1.Checked[i]:=True; FListForm.CheckListBox1.Checked[i]:=True;
end; end;
end; end;
destructor TBuildModesCheckList.Destroy; destructor TBuildModesCheckList.Destroy;
var
i: Integer;
BM: String;
begin begin
// Remember selected items before freeing the CheckListBox.
EnvironmentOptions.ManyBuildModesSelection.Clear;
for i:=0 to FListForm.CheckListBox1.Items.Count-1 do
begin
if FListForm.CheckListBox1.Checked[i] then
begin
BM:=FListForm.CheckListBox1.Items[i];
EnvironmentOptions.ManyBuildModesSelection.Add(BM);
end;
end;
FListForm.Free; FListForm.Free;
inherited Destroy; inherited Destroy;
end; end;
@ -875,6 +874,18 @@ begin
Result := FListForm.CheckListBox1.Checked[AIndex]; Result := FListForm.CheckListBox1.Checked[AIndex];
end; end;
procedure TBuildModesCheckList.SaveManyModesSelection;
var
i: Integer;
begin
// Remember selected items.
Project1.BuildModes.ManyBuildModes.Clear;
for i:=0 to FListForm.CheckListBox1.Items.Count-1 do
if FListForm.CheckListBox1.Checked[i] then
Project1.BuildModes.ManyBuildModes.Add(FListForm.CheckListBox1.Items[i]);
Project1.Modified:=True;
end;
procedure TBuildModesCheckList.SelectFirst; procedure TBuildModesCheckList.SelectFirst;
begin begin
Assert(FListForm.CheckListBox1.Items.Count>0, 'TBuildModesCheckList.SelectFirst: Build modes count < 1'); Assert(FListForm.CheckListBox1.Items.Count>0, 'TBuildModesCheckList.SelectFirst: Build modes count < 1');

View File

@ -913,6 +913,7 @@ type
property CompilerMessagesFilename: string read GetCompilerMessagesFilename property CompilerMessagesFilename: string read GetCompilerMessagesFilename
write SetCompilerMessagesFilename; // non English translation file write SetCompilerMessagesFilename; // non English translation file
property CompilerMessagesFileHistory: TStringList read FCompilerMessagesFileHistory; property CompilerMessagesFileHistory: TStringList read FCompilerMessagesFileHistory;
// ToDo: Remove this from trunk after Lazarus 2.2.0 is out. Now for backwards compatibility.
property ManyBuildModesSelection: TStringList read FManyBuildModesSelection; property ManyBuildModesSelection: TStringList read FManyBuildModesSelection;
// Primary-config verification // Primary-config verification
@ -2818,7 +2819,7 @@ begin
SaveRecentList(FXMLCfg,FCompilerMessagesFileHistory,Path+'CompilerMessagesFilename/History/'); SaveRecentList(FXMLCfg,FCompilerMessagesFileHistory,Path+'CompilerMessagesFilename/History/');
FXMLCfg.SetDeleteValue(Path+'FppkgConfigFile/Value',FppkgConfigFile,''); FXMLCfg.SetDeleteValue(Path+'FppkgConfigFile/Value',FppkgConfigFile,'');
SaveRecentList(FXMLCfg,FFppkgConfigFileHistory,Path+'FppkgConfigFile/History/'); SaveRecentList(FXMLCfg,FFppkgConfigFileHistory,Path+'FppkgConfigFile/History/');
SaveRecentList(FXMLCfg,FManyBuildModesSelection,Path+'ManyBuildModesSelection/'); // Note: ManyBuildModesSelection is not stored here any more. Moved to project settings.
// Primary-config verification // Primary-config verification
FXMLCfg.SetDeleteValue(Path+'LastCalledByLazarusFullPath/Value',FLastCalledByLazarusFullPath,''); FXMLCfg.SetDeleteValue(Path+'LastCalledByLazarusFullPath/Value',FLastCalledByLazarusFullPath,'');

View File

@ -1665,7 +1665,7 @@ begin
if MatRow is TGroupedMatrixValue then if MatRow is TGroupedMatrixValue then
begin begin
ValRow:=TGroupedMatrixValue(MatRow); ValRow:=TGroupedMatrixValue(MatRow);
iMod:=IndexInStringList(ValRow.ModeList,cstCaseInsensitive,aOldName); iMod:=ValRow.ModeList.IndexOf(aOldName);
if iMod>=0 then if iMod>=0 then
ValRow.ModeList[iMod]:=aNewName; ValRow.ModeList[iMod]:=aNewName;
end; end;

View File

@ -605,6 +605,7 @@ type
FAssigning: Boolean; FAssigning: Boolean;
FSessionMatrixOptions: TBuildMatrixOptions; FSessionMatrixOptions: TBuildMatrixOptions;
FSharedMatrixOptions: TBuildMatrixOptions; FSharedMatrixOptions: TBuildMatrixOptions;
FManyBuildModes: TStringList; // User selection of many modes.
fSavedChangeStamp: int64; fSavedChangeStamp: int64;
fItems: TFPList; fItems: TFPList;
FLazProject: TProject; FLazProject: TProject;
@ -667,6 +668,7 @@ type
property Modified: boolean read GetModified write SetModified; property Modified: boolean read GetModified write SetModified;
property SharedMatrixOptions: TBuildMatrixOptions read FSharedMatrixOptions; property SharedMatrixOptions: TBuildMatrixOptions read FSharedMatrixOptions;
property SessionMatrixOptions: TBuildMatrixOptions read FSessionMatrixOptions; property SessionMatrixOptions: TBuildMatrixOptions read FSessionMatrixOptions;
property ManyBuildModes: TStringList read FManyBuildModes;
end; end;
{ TProjectIDEOptions } { TProjectIDEOptions }
@ -6958,12 +6960,14 @@ begin
FSharedMatrixOptions.OnChanged:=@OnItemChanged; FSharedMatrixOptions.OnChanged:=@OnItemChanged;
FSessionMatrixOptions:=TBuildMatrixOptions.Create; FSessionMatrixOptions:=TBuildMatrixOptions.Create;
FSessionMatrixOptions.OnChanged:=@OnItemChanged; FSessionMatrixOptions.OnChanged:=@OnItemChanged;
FManyBuildModes:=TStringList.Create;
end; end;
destructor TProjectBuildModes.Destroy; destructor TProjectBuildModes.Destroy;
begin begin
FreeAndNil(fOnChanged); FreeAndNil(fOnChanged);
Clear; Clear;
FreeAndNil(FManyBuildModes);
FreeAndNil(FSharedMatrixOptions); FreeAndNil(FSharedMatrixOptions);
FreeAndNil(FSessionMatrixOptions); FreeAndNil(FSessionMatrixOptions);
FreeAndNil(fItems); FreeAndNil(fItems);
@ -7009,6 +7013,7 @@ begin
end; end;
SharedMatrixOptions.Assign(OtherModes.SharedMatrixOptions); SharedMatrixOptions.Assign(OtherModes.SharedMatrixOptions);
SessionMatrixOptions.Assign(OtherModes.SessionMatrixOptions); SessionMatrixOptions.Assign(OtherModes.SessionMatrixOptions);
ManyBuildModes.Assign(OtherModes.ManyBuildModes);
if WithModified then if WithModified then
Modified:=OtherModes.Modified; Modified:=OtherModes.Modified;
FAssigning:=False; FAssigning:=False;
@ -7337,6 +7342,8 @@ begin
if CurMode=nil then if CurMode=nil then
CurMode:=Items[0]; CurMode:=Items[0];
LazProject.ActiveBuildMode:=CurMode; LazProject.ActiveBuildMode:=CurMode;
// Many BuildModes selection, a comma separated list.
FManyBuildModes.CommaText:=FXMLConfig.GetValue(Path+'ManyBuildModesSelection/Value','');
end; end;
procedure TProjectBuildModes.LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure TProjectBuildModes.LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
@ -7399,6 +7406,8 @@ var
SubPath: String; SubPath: String;
i, Cnt: Integer; i, Cnt: Integer;
begin begin
// Many BuildModes selection, a comma separated list.
FXMLConfig.SetDeleteValue(Path+'ManyBuildModesSelection/Value', FManyBuildModes.CommaText, '');
// save what mode is currently active in the session // save what mode is currently active in the session
FXMLConfig.SetDeleteValue(Path+'BuildModes/Active', FXMLConfig.SetDeleteValue(Path+'BuildModes/Active',
LazProject.ActiveBuildMode.Identifier,'default'); LazProject.ActiveBuildMode.Identifier,'default');
@ -7455,7 +7464,6 @@ var
i, Cnt: Integer; i, Cnt: Integer;
begin begin
FXMLConfig := XMLConfig; FXMLConfig := XMLConfig;
Cnt:=0; Cnt:=0;
for i:=0 to Count-1 do for i:=0 to Count-1 do
if Items[i].InSession and SaveSession then if Items[i].InSession and SaveSession then