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
private
FListForm: TGenericCheckListForm;
function IsSelected(AIndex: Integer): Boolean;
procedure SaveManyModesSelection;
procedure SelectFirst;
function Show: Boolean;
public
constructor Create(InfoCaption: String);
destructor Destroy; override;
function IsSelected(AIndex: Integer): Boolean;
procedure SelectFirst;
end;
function ShowBuildModesDlg(aShowSession: Boolean): TModalResult;
@ -330,10 +331,11 @@ begin
Result := False;
ModeCnt := 0;
if PrepareForCompileWithMsg <> mrOk then exit;
BMList:=TBuildModesCheckList.Create(lisCompileFollowingModes);
BMList := TBuildModesCheckList.Create(lisCompileFollowingModes);
ModeList := TList.Create;
try
if not BMList.Show then Exit;
BMList.SaveManyModesSelection; // Remember the selection for next time.
ActiveMode := Project1.ActiveBuildMode;
BuildActiveMode := False;
// Collect modes to be built.
@ -455,6 +457,11 @@ begin
begin
CurMode.Identifier:=Value;
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);
end;
end;
@ -837,35 +844,27 @@ constructor TBuildModesCheckList.Create(InfoCaption: String);
var
i: Integer;
BM: String;
ManyBMs: TStringList;
begin
FListForm:=TGenericCheckListForm.Create(Nil);
//lisApplyForBuildModes = 'Apply for build modes:';
FListForm.Caption:=lisAvailableProjectBuildModes;
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.
for i:=0 to Project1.BuildModes.Count-1 do begin
BM:=Project1.BuildModes[i].Identifier;
FListForm.CheckListBox1.Items.Add(BM);
if EnvironmentOptions.ManyBuildModesSelection.IndexOf(BM) >= 0 then
if ManyBMs.IndexOf(BM) >= 0 then
FListForm.CheckListBox1.Checked[i]:=True;
end;
end;
destructor TBuildModesCheckList.Destroy;
var
i: Integer;
BM: String;
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;
inherited Destroy;
end;
@ -875,6 +874,18 @@ begin
Result := FListForm.CheckListBox1.Checked[AIndex];
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;
begin
Assert(FListForm.CheckListBox1.Items.Count>0, 'TBuildModesCheckList.SelectFirst: Build modes count < 1');

View File

@ -913,6 +913,7 @@ type
property CompilerMessagesFilename: string read GetCompilerMessagesFilename
write SetCompilerMessagesFilename; // non English translation file
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;
// Primary-config verification
@ -2818,7 +2819,7 @@ begin
SaveRecentList(FXMLCfg,FCompilerMessagesFileHistory,Path+'CompilerMessagesFilename/History/');
FXMLCfg.SetDeleteValue(Path+'FppkgConfigFile/Value',FppkgConfigFile,'');
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
FXMLCfg.SetDeleteValue(Path+'LastCalledByLazarusFullPath/Value',FLastCalledByLazarusFullPath,'');

View File

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

View File

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