IDE: Project: LPI&LPS ProjectOptions - write new lists. Issue

git-svn-id: trunk@62249 -
This commit is contained in:
ondrej 2019-11-16 18:53:50 +00:00
parent 02aeeee223
commit 3f71fbb081
4 changed files with 50 additions and 33 deletions

View File

@ -104,14 +104,14 @@ type
private
FItems: TList;
function GetItems(Index: integer): THistoryList;
function GetXMLListPath(const Path: string; i: integer): string;
function GetXMLListPath(const Path: string; i: integer; ALegacyList: Boolean): string;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
function Count: integer;
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 GetList(const Name: string;
CreateIfNotExists: boolean; ListType: TRecentListType): THistoryList;
@ -512,7 +512,7 @@ begin
XMLConfig.SetDeleteValue(Path+'Clean/SourcesFilemask',FCleanSourcesFileMask,
DefaultProjectCleanSourcesFileMask);
// history lists
FHistoryLists.SaveToXMLConfig(XMLConfig,Path+'HistoryLists/');
FHistoryLists.SaveToXMLConfig(XMLConfig,Path+'HistoryLists/',True);
// diff dialog
for DiffFlag:=Low(TTextDiffFlag) to High(TTextDiffFlag) do begin
XMLConfig.SetDeleteValue(
@ -732,9 +732,10 @@ begin
Result:=THistoryList(FItems[Index]);
end;
function THistoryLists.GetXMLListPath(const Path: string; i: integer): string;
function THistoryLists.GetXMLListPath(const Path: string; i: integer;
ALegacyList: Boolean): string;
begin
Result:=Path+'List'+IntToStr(i)+'/';
Result:=Path+TXMLConfig.GetListItemXPath('List', i, ALegacyList, False)+'/';
end;
constructor THistoryLists.Create;
@ -768,10 +769,12 @@ var
CurList: THistoryList;
ListName, ListPath: string;
ListType: TRecentListType;
IsLegacyList: Boolean;
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
ListPath:=GetXMLListPath(Path,i);
ListPath:=GetXMLListPath(Path,i,IsLegacyList);
ListName:=XMLConfig.GetValue(ListPath+'Name','');
if ListName='' then continue;
ListType:=StrToRecentListType(XMLConfig.GetValue(ListPath+'Type',''));
@ -780,15 +783,16 @@ begin
end;
end;
procedure THistoryLists.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure THistoryLists.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string; const ALegacyList: Boolean);
var
i, CurID: integer;
begin
XMLConfig.SetDeleteValue(Path+'Count',Count,0);
XMLConfig.SetListItemCount(Path,Count,ALegacyList);
CurID:=0;
for i:=0 to Count-1 do 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);
end;
end;

View File

@ -3217,7 +3217,7 @@ begin
and (not (pwfSkipJumpPoints in FProjectWriteFlags)) then begin
if (pfSaveJumpHistory in Flags) then begin
FJumpHistory.DeleteInvalidPositions;
FJumpHistory.SaveToXMLConfig(FXMLConfig,Path);
FJumpHistory.SaveToXMLConfig(FXMLConfig,Path,UseLegacyLists);
end
else
FXMLConfig.DeletePath(Path+'JumpHistory');
@ -3277,7 +3277,7 @@ begin
PublishOptions.SaveToXMLConfig(FXMLConfig,Path+'PublishOptions/',fCurStorePathDelim);
// save the Run and Build parameter options
RunParameterOptions.LegacySave(FXMLConfig,Path,fCurStorePathDelim);
RunParameterOptions.Save(FXMLConfig,Path+'RunParams/',fCurStorePathDelim,rpsLPI);
RunParameterOptions.Save(FXMLConfig,Path+'RunParams/',fCurStorePathDelim,rpsLPI, UseLegacyLists);
// save dependencies
SavePkgDependencyList(FXMLConfig,Path+'RequiredPackages/',
FFirstRequiredDependency,pdlRequires,fCurStorePathDelim);
@ -3344,9 +3344,9 @@ begin
// save session info
SaveSessionInfo(Path);
// 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
HistoryLists.SaveToXMLConfig(FXMLConfig,Path+'HistoryLists/');
HistoryLists.SaveToXMLConfig(FXMLConfig,Path+'HistoryLists/', UseLegacyLists);
// Notifiy hooks
if Assigned(OnSaveProjectInfo) then

View File

@ -269,7 +269,7 @@ type
procedure Insert(Index: integer; APosition: TProjectJumpHistoryPosition);
procedure InsertSmart(Index: integer; APosition: TProjectJumpHistoryPosition);
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;
property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
property Items[Index:integer]:TProjectJumpHistoryPosition
@ -576,18 +576,22 @@ procedure TProjectJumpHistory.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
var i, NewCount, NewHistoryIndex: integer;
NewPosition: TProjectJumpHistoryPosition;
JmpPath, PosPath: string;
IsLegacyList: Boolean;
begin
Clear;
NewCount:=XMLConfig.GetValue(Path+'JumpHistory/Count',0);
NewHistoryIndex:=XMLConfig.GetValue(Path+'JumpHistory/HistoryIndex',0);
JmpPath := Path+'JumpHistory/';
IsLegacyList:=XMLConfig.IsLegacyList(JmpPath);
NewCount:=XMLConfig.GetListItemCount(JmpPath, 'Position', IsLegacyList);
NewHistoryIndex:=XMLConfig.GetValue(JmpPath+'HistoryIndex',0);
NewPosition:=nil;
for i:=0 to NewCount-1 do begin
if NewPosition=nil then begin
NewPosition:=TProjectJumpHistoryPosition.Create('',Point(0,0),0);
NewPosition.OnLoadSaveFilename:=OnLoadSaveFilename;
end;
NewPosition.LoadFromXMLConfig(XMLConfig,
Path+'JumpHistory/Position'+IntToStr(i+1)+'/');
PosPath := JmpPath+XMLConfig.GetListItemXPath('Position', i, IsLegacyList, True)+'/';
NewPosition.LoadFromXMLConfig(XMLConfig, PosPath);
if (NewPosition.Filename<>'') and (NewPosition.CaretXY.Y>0)
and (NewPosition.CaretXY.X>0) and (NewPosition.TopLine>0)
and (NewPosition.TopLine<=NewPosition.CaretXY.Y) then begin
@ -603,14 +607,16 @@ begin
end;
procedure TProjectJumpHistory.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
const Path: string; const ALegacyLists: Boolean);
var i: integer;
JmpPath, PosPath: string;
begin
XMLConfig.SetDeleteValue(Path+'JumpHistory/Count',Count,0);
XMLConfig.SetDeleteValue(Path+'JumpHistory/HistoryIndex',HistoryIndex,0);
JmpPath := Path+'JumpHistory/';
XMLConfig.SetListItemCount(JmpPath,Count,ALegacyLists);
XMLConfig.SetDeleteValue(JmpPath+'HistoryIndex',HistoryIndex,0);
for i:=0 to Count-1 do begin
Items[i].SaveToXMLConfig(XMLConfig,
Path+'JumpHistory/Position'+IntToStr(i+1)+'/');
PosPath := JmpPath+XMLConfig.GetListItemXPath('Position', i, ALegacyLists, True)+'/';
Items[i].SaveToXMLConfig(XMLConfig, PosPath);
end;
end;

View File

@ -112,7 +112,8 @@ type
function LegacySave(XMLConfig: TXMLConfig; const Path: string;
UsePathDelim: TPathDelimSwitch): TModalResult;
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;
end;
@ -366,16 +367,19 @@ function TRunParamsOptions.Load(XMLConfig: TXMLConfig; const Path: string;
var
Cnt, I: Integer;
NewMode: TRunParamsOptionsMode;
ModePath, NewActiveModeName: string;
ModePath, NewActiveModeName, ModesPath: string;
IsLegacyList: Boolean;
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;
for I := 0 to Cnt-1 do
begin
ModePath := Path+'Modes/Mode'+IntToStr(I)+'/';
ModePath := ModesPath+XMLConfig.GetListItemXPath('Mode', I, IsLegacyList, False)+'/';
NewMode := Add(XMLConfig.GetValue(ModePath+'Name', '')) as TRunParamsOptionsMode;
NewMode.SaveIn := ASaveIn;
Result := NewMode.Load(XMLConfig, ModePath, AdjustPathDelims);
@ -396,13 +400,15 @@ begin
end;
function TRunParamsOptions.Save(XMLConfig: TXMLConfig; const Path: string;
UsePathDelim: TPathDelimSwitch; const ASaveIn: TRunParamsOptionsModeSave
): TModalResult;
UsePathDelim: TPathDelimSwitch; const ASaveIn: TRunParamsOptionsModeSave;
const ALegacyList: Boolean): TModalResult;
var
AMode: TRunParamsOptionsMode;
I, Cnt: Integer;
ModesPath, ModePath: string;
begin
Result := mrOK;
ModesPath := Path+'Modes/';
// save a format version to distinguish old formats
XMLConfig.SetValue(Path + 'FormatVersion/Value',
@ -415,14 +421,15 @@ begin
if AMode.SaveIn=ASaveIn then
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
Exit;
Inc(Cnt);
end;
end;
XMLConfig.SetValue(Path + 'Modes/Count', Cnt);
XMLConfig.SetListItemCount(ModesPath, Cnt, ALegacyList);
if ASaveIn=rpsLPS then
XMLConfig.SetValue(Path + 'Modes/ActiveMode', ActiveModeName);
end;