IDEIntf: added CustomData and CustomSessionData

git-svn-id: trunk@11486 -
This commit is contained in:
mattias 2007-07-13 11:54:37 +00:00
parent 8483303f3e
commit 63c8112843
3 changed files with 67 additions and 3 deletions

View File

@ -30,7 +30,7 @@ unit IDEProcs;
interface
uses
Classes, SysUtils, Laz_XMLCfg, FileUtil, LCLProc,
Classes, SysUtils, Laz_XMLCfg, FileUtil, LCLProc, AvgLvlTree,
FileProcs, LazConf;
type
@ -162,6 +162,10 @@ procedure LoadStringList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
procedure SaveStringList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
procedure LoadStringToStringTree(XMLConfig: TXMLConfig;
Tree: TStringToStringTree; const Path: string);
procedure SaveStringToStringTree(XMLConfig: TXMLConfig;
Tree: TStringToStringTree; const Path: string);
procedure MakeXMLName(var Name: string);
@ -854,6 +858,46 @@ begin
XMLConfig.SetDeleteValue(Path+'Item'+IntToStr(i+1)+'/Value',List[i],'');
end;
procedure LoadStringToStringTree(XMLConfig: TXMLConfig;
Tree: TStringToStringTree; const Path: string);
var
Cnt: LongInt;
SubPath: String;
CurName: String;
CurValue: String;
i: Integer;
begin
Tree.Clear;
Cnt:=XMLConfig.GetValue(Path+'Count',0);
for i:=0 to Cnt-1 do begin
SubPath:=Path+'Item'+IntToStr(i)+'/';
CurName:=XMLConfig.GetValue(SubPath+'Name','');
CurValue:=XMLConfig.GetValue(SubPath+'Value','');
Tree.Values[CurName]:=CurValue;
end;
end;
procedure SaveStringToStringTree(XMLConfig: TXMLConfig;
Tree: TStringToStringTree; const Path: string);
var
Node: TAvgLvlTreeNode;
Item: PStringToStringItem;
i: Integer;
SubPath: String;
begin
XMLConfig.SetDeleteValue(Path+'Count',Tree.Tree.Count,0);
Node:=Tree.Tree.FindLowest;
i:=0;
while Node<>nil do begin
Item:=PStringToStringItem(Node.Data);
SubPath:=Path+'Item'+IntToStr(i)+'/';
XMLConfig.SetDeleteValue(SubPath+'Name',Item^.Name,'');
XMLConfig.SetDeleteValue(SubPath+'Value',Item^.Value,'');
Node:=Tree.Tree.FindSuccessor(Node);
inc(i);
end;
end;
procedure MakeXMLName(var Name: string);
var
i: Integer;

View File

@ -1686,6 +1686,9 @@ function TProject.WriteProject(ProjectWriteFlags: TProjectWriteFlags;
FJumpHistory.DeleteInvalidPositions;
FJumpHistory.SaveToXMLConfig(aConfig,Path);
end;
// save custom session data
SaveStringToStringTree(aConfig,CustomSessionData,Path+'CustomSessionData/');
end;
var
@ -1789,6 +1792,9 @@ begin
xmlconfig.SetDeleteValue(Path+'VersionInfo/OriginalFilename/Value', VersionInfo.OriginalFilenameString,'');
xmlconfig.SetDeleteValue(Path+'VersionInfo/ProductName/Value', VersionInfo.ProdNameString,'');
// save custom data
SaveStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
// Save the compiler options
CompilerOptions.SaveToXMLConfig(XMLConfig,'CompilerOptions/');
@ -2058,6 +2064,9 @@ var
ActiveEditorIndexAtStart := xmlconfig.GetValue(
Path+'General/ActiveEditorIndexAtStart/Value', -1);
FJumpHistory.LoadFromXMLConfig(xmlconfig,Path+'');
// load custom session data
LoadStringToStringTree(xmlconfig,CustomSessionData,Path+'CustomSessionData/');
end;
procedure LoadDefaultSession;
@ -2166,6 +2175,9 @@ begin
VersionInfo.OriginalFilenameString := xmlconfig.GetValue(Path+'VersionInfo/OriginalFilename/Value', '');
VersionInfo.ProdNameString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/ProductName/Value', ''));
// load custom data
LoadStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF}
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjPath']:=
ProjectDirectory;

View File

@ -22,8 +22,8 @@ unit ProjectIntf;
interface
uses
Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, NewItemIntf,
ObjInspStrConsts;
Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, AvgLvlTree,
NewItemIntf, ObjInspStrConsts;
const
FileDescGroupName = 'File';
@ -518,6 +518,8 @@ type
TLazProject = class(TPersistent)
private
FCustomData: TStringToStringTree;
FCustomSessionData: TStringToStringTree;
FLazCompilerOptions: TLazCompilerOptions;
fModified: boolean;
FProjectSessionFile: string;
@ -582,6 +584,8 @@ type
// units have their own SessionModified
property LazDocPaths: string read FLazDocPaths write SetLazDocPaths;
property RSTOutputDirectory: string read FRSTOutputDirectory write SetRSTOutputDirectory;
property CustomData: TStringToStringTree read FCustomData;
property CustomSessionData: TStringToStringTree read FCustomSessionData;
end;
TLazProjectClass = class of TLazProject;
@ -1117,10 +1121,14 @@ constructor TLazProject.Create(ProjectDescription: TProjectDescriptor);
begin
inherited Create;
FSessionStorage:=pssInProjectInfo;
FCustomData:=TStringToStringTree.Create(true);
FCustomSessionData:=TStringToStringTree.Create(true);
end;
destructor TLazProject.Destroy;
begin
FreeAndNil(FCustomData);
FreeAndNil(FCustomSessionData);
inherited Destroy;
end;