mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 15:19:14 +02:00
IDE: Project: LPI&LPS ProjectOptions - write new lists. Issue #22752
git-svn-id: trunk@62249 -
This commit is contained in:
parent
02aeeee223
commit
3f71fbb081
@ -104,14 +104,14 @@ type
|
|||||||
private
|
private
|
||||||
FItems: TList;
|
FItems: TList;
|
||||||
function GetItems(Index: integer): THistoryList;
|
function GetItems(Index: integer): THistoryList;
|
||||||
function GetXMLListPath(const Path: string; i: integer): string;
|
function GetXMLListPath(const Path: string; i: integer; ALegacyList: Boolean): string;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
function Count: integer;
|
function Count: integer;
|
||||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string; const ALegacyList: Boolean);
|
||||||
function IndexOfName(const Name: string): integer;
|
function IndexOfName(const Name: string): integer;
|
||||||
function GetList(const Name: string;
|
function GetList(const Name: string;
|
||||||
CreateIfNotExists: boolean; ListType: TRecentListType): THistoryList;
|
CreateIfNotExists: boolean; ListType: TRecentListType): THistoryList;
|
||||||
@ -512,7 +512,7 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'Clean/SourcesFilemask',FCleanSourcesFileMask,
|
XMLConfig.SetDeleteValue(Path+'Clean/SourcesFilemask',FCleanSourcesFileMask,
|
||||||
DefaultProjectCleanSourcesFileMask);
|
DefaultProjectCleanSourcesFileMask);
|
||||||
// history lists
|
// history lists
|
||||||
FHistoryLists.SaveToXMLConfig(XMLConfig,Path+'HistoryLists/');
|
FHistoryLists.SaveToXMLConfig(XMLConfig,Path+'HistoryLists/',True);
|
||||||
// diff dialog
|
// diff dialog
|
||||||
for DiffFlag:=Low(TTextDiffFlag) to High(TTextDiffFlag) do begin
|
for DiffFlag:=Low(TTextDiffFlag) to High(TTextDiffFlag) do begin
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(
|
||||||
@ -732,9 +732,10 @@ begin
|
|||||||
Result:=THistoryList(FItems[Index]);
|
Result:=THistoryList(FItems[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function THistoryLists.GetXMLListPath(const Path: string; i: integer): string;
|
function THistoryLists.GetXMLListPath(const Path: string; i: integer;
|
||||||
|
ALegacyList: Boolean): string;
|
||||||
begin
|
begin
|
||||||
Result:=Path+'List'+IntToStr(i)+'/';
|
Result:=Path+TXMLConfig.GetListItemXPath('List', i, ALegacyList, False)+'/';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor THistoryLists.Create;
|
constructor THistoryLists.Create;
|
||||||
@ -768,10 +769,12 @@ var
|
|||||||
CurList: THistoryList;
|
CurList: THistoryList;
|
||||||
ListName, ListPath: string;
|
ListName, ListPath: string;
|
||||||
ListType: TRecentListType;
|
ListType: TRecentListType;
|
||||||
|
IsLegacyList: Boolean;
|
||||||
begin
|
begin
|
||||||
MergeCount:=XMLConfig.GetValue(Path+'Count',0);
|
IsLegacyList:=XMLConfig.IsLegacyList(Path);
|
||||||
|
MergeCount:=XMLConfig.GetListItemCount(Path, 'List', IsLegacyList);
|
||||||
for i:=0 to MergeCount-1 do begin
|
for i:=0 to MergeCount-1 do begin
|
||||||
ListPath:=GetXMLListPath(Path,i);
|
ListPath:=GetXMLListPath(Path,i,IsLegacyList);
|
||||||
ListName:=XMLConfig.GetValue(ListPath+'Name','');
|
ListName:=XMLConfig.GetValue(ListPath+'Name','');
|
||||||
if ListName='' then continue;
|
if ListName='' then continue;
|
||||||
ListType:=StrToRecentListType(XMLConfig.GetValue(ListPath+'Type',''));
|
ListType:=StrToRecentListType(XMLConfig.GetValue(ListPath+'Type',''));
|
||||||
@ -780,15 +783,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THistoryLists.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
procedure THistoryLists.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||||
|
const Path: string; const ALegacyList: Boolean);
|
||||||
var
|
var
|
||||||
i, CurID: integer;
|
i, CurID: integer;
|
||||||
begin
|
begin
|
||||||
XMLConfig.SetDeleteValue(Path+'Count',Count,0);
|
XMLConfig.SetListItemCount(Path,Count,ALegacyList);
|
||||||
CurID:=0;
|
CurID:=0;
|
||||||
for i:=0 to Count-1 do begin
|
for i:=0 to Count-1 do begin
|
||||||
if Items[i].Count>0 then begin
|
if Items[i].Count>0 then begin
|
||||||
Items[i].SaveToXMLConfig(XMLConfig,GetXMLListPath(Path,CurID));
|
Items[i].SaveToXMLConfig(XMLConfig,GetXMLListPath(Path,CurID,ALegacyList));
|
||||||
inc(CurID);
|
inc(CurID);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -3217,7 +3217,7 @@ begin
|
|||||||
and (not (pwfSkipJumpPoints in FProjectWriteFlags)) then begin
|
and (not (pwfSkipJumpPoints in FProjectWriteFlags)) then begin
|
||||||
if (pfSaveJumpHistory in Flags) then begin
|
if (pfSaveJumpHistory in Flags) then begin
|
||||||
FJumpHistory.DeleteInvalidPositions;
|
FJumpHistory.DeleteInvalidPositions;
|
||||||
FJumpHistory.SaveToXMLConfig(FXMLConfig,Path);
|
FJumpHistory.SaveToXMLConfig(FXMLConfig,Path,UseLegacyLists);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
FXMLConfig.DeletePath(Path+'JumpHistory');
|
FXMLConfig.DeletePath(Path+'JumpHistory');
|
||||||
@ -3277,7 +3277,7 @@ begin
|
|||||||
PublishOptions.SaveToXMLConfig(FXMLConfig,Path+'PublishOptions/',fCurStorePathDelim);
|
PublishOptions.SaveToXMLConfig(FXMLConfig,Path+'PublishOptions/',fCurStorePathDelim);
|
||||||
// save the Run and Build parameter options
|
// save the Run and Build parameter options
|
||||||
RunParameterOptions.LegacySave(FXMLConfig,Path,fCurStorePathDelim);
|
RunParameterOptions.LegacySave(FXMLConfig,Path,fCurStorePathDelim);
|
||||||
RunParameterOptions.Save(FXMLConfig,Path+'RunParams/',fCurStorePathDelim,rpsLPI);
|
RunParameterOptions.Save(FXMLConfig,Path+'RunParams/',fCurStorePathDelim,rpsLPI, UseLegacyLists);
|
||||||
// save dependencies
|
// save dependencies
|
||||||
SavePkgDependencyList(FXMLConfig,Path+'RequiredPackages/',
|
SavePkgDependencyList(FXMLConfig,Path+'RequiredPackages/',
|
||||||
FFirstRequiredDependency,pdlRequires,fCurStorePathDelim);
|
FFirstRequiredDependency,pdlRequires,fCurStorePathDelim);
|
||||||
@ -3344,9 +3344,9 @@ begin
|
|||||||
// save session info
|
// save session info
|
||||||
SaveSessionInfo(Path);
|
SaveSessionInfo(Path);
|
||||||
// save the Run and Build parameter options
|
// save the Run and Build parameter options
|
||||||
RunParameterOptions.Save(FXMLConfig,Path+'RunParams/',fCurStorePathDelim,rpsLPS);
|
RunParameterOptions.Save(FXMLConfig,Path+'RunParams/',fCurStorePathDelim,rpsLPS, UseLegacyLists);
|
||||||
// save history lists
|
// save history lists
|
||||||
HistoryLists.SaveToXMLConfig(FXMLConfig,Path+'HistoryLists/');
|
HistoryLists.SaveToXMLConfig(FXMLConfig,Path+'HistoryLists/', UseLegacyLists);
|
||||||
|
|
||||||
// Notifiy hooks
|
// Notifiy hooks
|
||||||
if Assigned(OnSaveProjectInfo) then
|
if Assigned(OnSaveProjectInfo) then
|
||||||
|
@ -269,7 +269,7 @@ type
|
|||||||
procedure Insert(Index: integer; APosition: TProjectJumpHistoryPosition);
|
procedure Insert(Index: integer; APosition: TProjectJumpHistoryPosition);
|
||||||
procedure InsertSmart(Index: integer; APosition: TProjectJumpHistoryPosition);
|
procedure InsertSmart(Index: integer; APosition: TProjectJumpHistoryPosition);
|
||||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string; const ALegacyLists: Boolean);
|
||||||
procedure WriteDebugReport;
|
procedure WriteDebugReport;
|
||||||
property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
|
property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
|
||||||
property Items[Index:integer]:TProjectJumpHistoryPosition
|
property Items[Index:integer]:TProjectJumpHistoryPosition
|
||||||
@ -576,18 +576,22 @@ procedure TProjectJumpHistory.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
|||||||
const Path: string);
|
const Path: string);
|
||||||
var i, NewCount, NewHistoryIndex: integer;
|
var i, NewCount, NewHistoryIndex: integer;
|
||||||
NewPosition: TProjectJumpHistoryPosition;
|
NewPosition: TProjectJumpHistoryPosition;
|
||||||
|
JmpPath, PosPath: string;
|
||||||
|
IsLegacyList: Boolean;
|
||||||
begin
|
begin
|
||||||
Clear;
|
Clear;
|
||||||
NewCount:=XMLConfig.GetValue(Path+'JumpHistory/Count',0);
|
JmpPath := Path+'JumpHistory/';
|
||||||
NewHistoryIndex:=XMLConfig.GetValue(Path+'JumpHistory/HistoryIndex',0);
|
IsLegacyList:=XMLConfig.IsLegacyList(JmpPath);
|
||||||
|
NewCount:=XMLConfig.GetListItemCount(JmpPath, 'Position', IsLegacyList);
|
||||||
|
NewHistoryIndex:=XMLConfig.GetValue(JmpPath+'HistoryIndex',0);
|
||||||
NewPosition:=nil;
|
NewPosition:=nil;
|
||||||
for i:=0 to NewCount-1 do begin
|
for i:=0 to NewCount-1 do begin
|
||||||
if NewPosition=nil then begin
|
if NewPosition=nil then begin
|
||||||
NewPosition:=TProjectJumpHistoryPosition.Create('',Point(0,0),0);
|
NewPosition:=TProjectJumpHistoryPosition.Create('',Point(0,0),0);
|
||||||
NewPosition.OnLoadSaveFilename:=OnLoadSaveFilename;
|
NewPosition.OnLoadSaveFilename:=OnLoadSaveFilename;
|
||||||
end;
|
end;
|
||||||
NewPosition.LoadFromXMLConfig(XMLConfig,
|
PosPath := JmpPath+XMLConfig.GetListItemXPath('Position', i, IsLegacyList, True)+'/';
|
||||||
Path+'JumpHistory/Position'+IntToStr(i+1)+'/');
|
NewPosition.LoadFromXMLConfig(XMLConfig, PosPath);
|
||||||
if (NewPosition.Filename<>'') and (NewPosition.CaretXY.Y>0)
|
if (NewPosition.Filename<>'') and (NewPosition.CaretXY.Y>0)
|
||||||
and (NewPosition.CaretXY.X>0) and (NewPosition.TopLine>0)
|
and (NewPosition.CaretXY.X>0) and (NewPosition.TopLine>0)
|
||||||
and (NewPosition.TopLine<=NewPosition.CaretXY.Y) then begin
|
and (NewPosition.TopLine<=NewPosition.CaretXY.Y) then begin
|
||||||
@ -603,14 +607,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProjectJumpHistory.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
procedure TProjectJumpHistory.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||||
const Path: string);
|
const Path: string; const ALegacyLists: Boolean);
|
||||||
var i: integer;
|
var i: integer;
|
||||||
|
JmpPath, PosPath: string;
|
||||||
begin
|
begin
|
||||||
XMLConfig.SetDeleteValue(Path+'JumpHistory/Count',Count,0);
|
JmpPath := Path+'JumpHistory/';
|
||||||
XMLConfig.SetDeleteValue(Path+'JumpHistory/HistoryIndex',HistoryIndex,0);
|
XMLConfig.SetListItemCount(JmpPath,Count,ALegacyLists);
|
||||||
|
XMLConfig.SetDeleteValue(JmpPath+'HistoryIndex',HistoryIndex,0);
|
||||||
for i:=0 to Count-1 do begin
|
for i:=0 to Count-1 do begin
|
||||||
Items[i].SaveToXMLConfig(XMLConfig,
|
PosPath := JmpPath+XMLConfig.GetListItemXPath('Position', i, ALegacyLists, True)+'/';
|
||||||
Path+'JumpHistory/Position'+IntToStr(i+1)+'/');
|
Items[i].SaveToXMLConfig(XMLConfig, PosPath);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -112,7 +112,8 @@ type
|
|||||||
function LegacySave(XMLConfig: TXMLConfig; const Path: string;
|
function LegacySave(XMLConfig: TXMLConfig; const Path: string;
|
||||||
UsePathDelim: TPathDelimSwitch): TModalResult;
|
UsePathDelim: TPathDelimSwitch): TModalResult;
|
||||||
function Save(XMLConfig: TXMLConfig; const Path: string;
|
function Save(XMLConfig: TXMLConfig; const Path: string;
|
||||||
UsePathDelim: TPathDelimSwitch; const ASaveIn: TRunParamsOptionsModeSave): TModalResult;
|
UsePathDelim: TPathDelimSwitch; const ASaveIn: TRunParamsOptionsModeSave;
|
||||||
|
const ALegacyList: Boolean): TModalResult;
|
||||||
function GetActiveMode: TRunParamsOptionsMode;
|
function GetActiveMode: TRunParamsOptionsMode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -366,16 +367,19 @@ function TRunParamsOptions.Load(XMLConfig: TXMLConfig; const Path: string;
|
|||||||
var
|
var
|
||||||
Cnt, I: Integer;
|
Cnt, I: Integer;
|
||||||
NewMode: TRunParamsOptionsMode;
|
NewMode: TRunParamsOptionsMode;
|
||||||
ModePath, NewActiveModeName: string;
|
ModePath, NewActiveModeName, ModesPath: string;
|
||||||
|
IsLegacyList: Boolean;
|
||||||
begin
|
begin
|
||||||
//don't clear! needed for merging lpi and lps
|
//don't clear! needed for merging lpi and lps
|
||||||
|
|
||||||
Cnt := XMLConfig.GetValue(Path + 'Modes/Count', 0);
|
ModesPath := Path + 'Modes/';
|
||||||
|
IsLegacyList := XMLConfig.IsLegacyList(ModesPath);
|
||||||
|
Cnt := XMLConfig.GetListItemCount(ModesPath, 'Mode', IsLegacyList);
|
||||||
Result := mrOK;
|
Result := mrOK;
|
||||||
|
|
||||||
for I := 0 to Cnt-1 do
|
for I := 0 to Cnt-1 do
|
||||||
begin
|
begin
|
||||||
ModePath := Path+'Modes/Mode'+IntToStr(I)+'/';
|
ModePath := ModesPath+XMLConfig.GetListItemXPath('Mode', I, IsLegacyList, False)+'/';
|
||||||
NewMode := Add(XMLConfig.GetValue(ModePath+'Name', '')) as TRunParamsOptionsMode;
|
NewMode := Add(XMLConfig.GetValue(ModePath+'Name', '')) as TRunParamsOptionsMode;
|
||||||
NewMode.SaveIn := ASaveIn;
|
NewMode.SaveIn := ASaveIn;
|
||||||
Result := NewMode.Load(XMLConfig, ModePath, AdjustPathDelims);
|
Result := NewMode.Load(XMLConfig, ModePath, AdjustPathDelims);
|
||||||
@ -396,13 +400,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TRunParamsOptions.Save(XMLConfig: TXMLConfig; const Path: string;
|
function TRunParamsOptions.Save(XMLConfig: TXMLConfig; const Path: string;
|
||||||
UsePathDelim: TPathDelimSwitch; const ASaveIn: TRunParamsOptionsModeSave
|
UsePathDelim: TPathDelimSwitch; const ASaveIn: TRunParamsOptionsModeSave;
|
||||||
): TModalResult;
|
const ALegacyList: Boolean): TModalResult;
|
||||||
var
|
var
|
||||||
AMode: TRunParamsOptionsMode;
|
AMode: TRunParamsOptionsMode;
|
||||||
I, Cnt: Integer;
|
I, Cnt: Integer;
|
||||||
|
ModesPath, ModePath: string;
|
||||||
begin
|
begin
|
||||||
Result := mrOK;
|
Result := mrOK;
|
||||||
|
ModesPath := Path+'Modes/';
|
||||||
|
|
||||||
// save a format version to distinguish old formats
|
// save a format version to distinguish old formats
|
||||||
XMLConfig.SetValue(Path + 'FormatVersion/Value',
|
XMLConfig.SetValue(Path + 'FormatVersion/Value',
|
||||||
@ -415,14 +421,15 @@ begin
|
|||||||
|
|
||||||
if AMode.SaveIn=ASaveIn then
|
if AMode.SaveIn=ASaveIn then
|
||||||
begin
|
begin
|
||||||
Result := AMode.Save(XMLConfig, Path+'Modes/Mode'+IntToStr(Cnt)+'/', UsePathDelim);
|
ModePath := ModesPath+XMLConfig.GetListItemXPath('Mode', Cnt, ALegacyList, False)+'/';
|
||||||
|
Result := AMode.Save(XMLConfig, ModePath, UsePathDelim);
|
||||||
if Result<>mrOK then
|
if Result<>mrOK then
|
||||||
Exit;
|
Exit;
|
||||||
Inc(Cnt);
|
Inc(Cnt);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
XMLConfig.SetValue(Path + 'Modes/Count', Cnt);
|
XMLConfig.SetListItemCount(ModesPath, Cnt, ALegacyList);
|
||||||
if ASaveIn=rpsLPS then
|
if ASaveIn=rpsLPS then
|
||||||
XMLConfig.SetValue(Path + 'Modes/ActiveMode', ActiveModeName);
|
XMLConfig.SetValue(Path + 'Modes/ActiveMode', ActiveModeName);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user