8
Classes, SysUtils, AvgLvlTree, InputHistory, Laz2_XMLCfg, IDEProcs, StdCtrls;
11
hlCmdLineParamsHistoryList = 'CmdLineParamsHistoryList';
12
hlLaunchingApplicationHistoryList = 'LaunchingApplicationHistoryList';
18
TAdvHistoryList = class(THistoryList)
22
FSaveSelected : Boolean;
23
procedure AssignValues(Source : TPersistent);override;
25
constructor Create(TheListType: TRecentListType);override;
26
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);override;
27
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);override;
28
procedure AdvLoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);virtual;
29
procedure AdvSaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);virtual;
30
procedure Clear; override;
31
procedure SetComboBox(AComboBox : TComboBox);
32
class function CreateMe(ATheListType : TRecentListType; AName : String) : THistoryList;override;
33
procedure Assign(Source: TPersistent); override;
34
procedure AssignKeyValue(Source : TPersistent);virtual;
36
property Selected : String read FSelected write FSelected;
42
{ TAdvHistoryListCreator }
44
class function TAdvHistoryList.CreateMe(ATheListType : TRecentListType; AName : String) : THistoryList;
46
AAdvHistoryList : TAdvHistoryList;
48
AAdvHistoryList := TAdvHistoryList.Create(ATheListType);
49
AAdvHistoryList.Name := AName;
50
AAdvHistoryList.NameValueSeparator := #0;
51
Result := AAdvHistoryList;
54
constructor TAdvHistoryList.Create(TheListType: TRecentListType);
60
procedure TAdvHistoryList.Assign(Source: TPersistent);
63
If Source is TAdvHistoryList Then
65
Self.FSelected := TAdvHistoryList(Source).FSelected;
68
procedure TAdvHistoryList.AssignKeyValue(Source : TPersistent);
71
AName, AValue : String;
73
If Source is TAdvHistoryList Then Begin
74
Self.NameValueSeparator := TAdvHistoryList(Source).NameValueSeparator;
75
Self.AssignValues(Source);
76
For I := 0 To TAdvHistoryList(Source).Count - 1 Do Begin
77
TAdvHistoryList(Source).GetNameValue(I, AName, AValue);
78
Self.Values[AName] := AValue;
83
procedure TAdvHistoryList.AssignValues(Source : TPersistent);
86
If Source is TAdvHistoryList Then
88
Self.FSelected := TAdvHistoryList(Source).FSelected;
91
procedure TAdvHistoryList.AdvLoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
93
FSaveSelected := True;
94
Self.LoadFromXMLConfig(XMLConfig, Path);
95
FSaveSelected := False;
98
procedure TAdvHistoryList.AdvSaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
100
FSaveSelected := True;
101
Self.SaveToXMLConfig(XMLConfig, Path);
102
FSaveSelected := False;
105
procedure TAdvHistoryList.LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
107
AStringToStringTree : TStringToStringTree;
108
APStringToStringItem : PStringToStringItem;
110
AStringToStringTree := TStringToStringTree.Create(false);
112
Name:=XMLConfig.GetValue(Path+'Name','');
113
MaxCount:=XMLConfig.GetValue(Path+'MaxCount',MaxCount);
114
FListType:=StrToRecentListType(XMLConfig.GetValue(Path+'Type',''));
116
If FSaveSelected Then
117
FSelected := XMLConfig.GetValue(Path+'Selected','');
119
LoadStringToStringTree(XMLConfig, AStringToStringTree, Path);
121
For APStringToStringItem in AStringToStringTree do
122
Self.Values[APStringToStringItem^.Name] := APStringToStringItem^.Value;
124
CleanUpRecentList(Self,ListType);
126
FreeAndNil(AStringToStringTree);
129
procedure TAdvHistoryList.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
131
AStringToStringTree : TStringToStringTree;
133
AStringToStringTree := TStringToStringTree.Create(false);
135
XMLConfig.SetDeleteValue(Path+'Name',Name,'');
136
XMLConfig.SetDeleteValue(Path+'Type',RecentListTypeNames[ListType],
137
RecentListTypeNames[rltCaseSensitive]);
138
XMLConfig.SetDeleteValue(Path+'MaxCount',MaxCount,20);
140
If FSaveSelected Then
141
XMLConfig.SetDeleteValue(Path+'Selected', FSelected, '');
143
AStringToStringTree.AddNameValues(Self);
145
SaveStringToStringTree(XMLConfig, AStringToStringTree, Path);
147
FreeAndNil(AStringToStringTree);
150
procedure TAdvHistoryList.Clear;
156
procedure TAdvHistoryList.SetComboBox(AComboBox : TComboBox);
161
AComboBox.Items.Clear;
162
For I := 0 To Self.Count - 1 Do Begin
163
AValue := Self.Names[I];
164
AIndex := AComboBox.Items.IndexOf(AValue);
167
AComboBox.Items.Add(AValue);
172
THistoryLists.RegisterHistoryListClass(TAdvHistoryList, hlCmdLineParamsHistoryList);
173
THistoryLists.RegisterHistoryListClass(TAdvHistoryList, hlLaunchingApplicationHistoryList);