~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to ide/advhistorylist.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2014-02-22 10:25:57 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140222102557-ors9d31r84nz31jq
Tags: 1.2~rc2+dfsg-1
[ Abou Al Montacir ]
* New upstream pre-release.
  + Moved ideintf to components directory.
  + Added new package cairocanvas.
* Remove usage of depreciated parameters form of find. (Closes: Bug#724776)
* Bumped standard version to 3.9.5.
* Clean the way handling make files generation and removal.

[ Paul Gevers ]
* Remove nearly obsolete bzip compression for binary packages
  (See https://lists.debian.org/debian-devel/2014/01/msg00542.html)
* Update d/copyright for newly added dir in examples and components
* Update Vcs-* fields with new packaging location
* Update d/watch file to properly (Debian way) change upstreams versions
* Prevent 46MB of package size by sym linking duplicate files
* Patches
  - refresh to remove fuzz
  - add more Lintian found spelling errors
  - new patch to add shbang to two scripts in lazarus-src
* Drop lcl-# from Provides list of lcl-units-#
* Make lazarus-ide-qt4-# an arch all until it really contains stuff
* Make all metapackages arch all as the usecase for arch any doesn't
  seem to warrant the addition archive hit
* Fix permissions of non-scripts in lazarus-src-#

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
unit AdvHistoryList;
 
2
 
 
3
{$mode objfpc}{$H+}
 
4
 
 
5
interface
 
6
 
 
7
uses
 
8
  Classes, SysUtils, AvgLvlTree, InputHistory, Laz2_XMLCfg, IDEProcs, StdCtrls;
 
9
 
 
10
Const
 
11
  hlCmdLineParamsHistoryList = 'CmdLineParamsHistoryList';
 
12
  hlLaunchingApplicationHistoryList = 'LaunchingApplicationHistoryList';
 
13
 
 
14
Type
 
15
 
 
16
  { TAdvHistoryList }
 
17
 
 
18
  TAdvHistoryList = class(THistoryList)
 
19
    private
 
20
      FSelected : String;
 
21
    protected
 
22
      FSaveSelected : Boolean;
 
23
      procedure AssignValues(Source : TPersistent);override;
 
24
    public
 
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;
 
35
 
 
36
      property Selected : String read FSelected write FSelected;
 
37
  end;
 
38
 
 
39
 
 
40
implementation
 
41
 
 
42
{ TAdvHistoryListCreator }
 
43
 
 
44
class function TAdvHistoryList.CreateMe(ATheListType : TRecentListType; AName : String) : THistoryList;
 
45
Var
 
46
  AAdvHistoryList : TAdvHistoryList;
 
47
begin
 
48
  AAdvHistoryList := TAdvHistoryList.Create(ATheListType);
 
49
  AAdvHistoryList.Name := AName;
 
50
  AAdvHistoryList.NameValueSeparator := #0;
 
51
  Result := AAdvHistoryList;
 
52
end;
 
53
 
 
54
constructor TAdvHistoryList.Create(TheListType: TRecentListType);
 
55
begin
 
56
  inherited;
 
57
  FSelected := '';
 
58
end;
 
59
 
 
60
procedure TAdvHistoryList.Assign(Source: TPersistent);
 
61
begin
 
62
  inherited;
 
63
  If Source is TAdvHistoryList Then
 
64
    If FSaveSelected Then
 
65
      Self.FSelected := TAdvHistoryList(Source).FSelected;
 
66
end;
 
67
 
 
68
procedure TAdvHistoryList.AssignKeyValue(Source : TPersistent);
 
69
Var
 
70
  I : Integer;
 
71
  AName, AValue : String;
 
72
Begin
 
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;
 
79
    end;
 
80
  end;
 
81
end;
 
82
 
 
83
procedure TAdvHistoryList.AssignValues(Source : TPersistent);
 
84
Begin
 
85
  inherited;
 
86
  If Source is TAdvHistoryList Then
 
87
    If FSaveSelected Then
 
88
      Self.FSelected := TAdvHistoryList(Source).FSelected;
 
89
end;
 
90
 
 
91
procedure TAdvHistoryList.AdvLoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
 
92
begin
 
93
  FSaveSelected := True;
 
94
  Self.LoadFromXMLConfig(XMLConfig, Path);
 
95
  FSaveSelected := False;
 
96
end;
 
97
 
 
98
procedure TAdvHistoryList.AdvSaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
 
99
begin
 
100
  FSaveSelected := True;
 
101
  Self.SaveToXMLConfig(XMLConfig, Path);
 
102
  FSaveSelected := False;
 
103
end;
 
104
 
 
105
procedure TAdvHistoryList.LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
 
106
Var
 
107
  AStringToStringTree : TStringToStringTree;
 
108
  APStringToStringItem : PStringToStringItem;
 
109
begin
 
110
  AStringToStringTree := TStringToStringTree.Create(false);
 
111
  if Name='' then
 
112
    Name:=XMLConfig.GetValue(Path+'Name','');
 
113
  MaxCount:=XMLConfig.GetValue(Path+'MaxCount',MaxCount);
 
114
  FListType:=StrToRecentListType(XMLConfig.GetValue(Path+'Type',''));
 
115
 
 
116
  If FSaveSelected Then
 
117
    FSelected := XMLConfig.GetValue(Path+'Selected','');
 
118
 
 
119
  LoadStringToStringTree(XMLConfig, AStringToStringTree, Path);
 
120
 
 
121
  For APStringToStringItem in AStringToStringTree do
 
122
    Self.Values[APStringToStringItem^.Name] := APStringToStringItem^.Value;
 
123
 
 
124
  CleanUpRecentList(Self,ListType);
 
125
 
 
126
  FreeAndNil(AStringToStringTree);
 
127
end;
 
128
 
 
129
procedure TAdvHistoryList.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
 
130
Var
 
131
  AStringToStringTree : TStringToStringTree;
 
132
begin
 
133
  AStringToStringTree := TStringToStringTree.Create(false);
 
134
 
 
135
  XMLConfig.SetDeleteValue(Path+'Name',Name,'');
 
136
  XMLConfig.SetDeleteValue(Path+'Type',RecentListTypeNames[ListType],
 
137
                           RecentListTypeNames[rltCaseSensitive]);
 
138
  XMLConfig.SetDeleteValue(Path+'MaxCount',MaxCount,20);
 
139
 
 
140
  If FSaveSelected Then
 
141
    XMLConfig.SetDeleteValue(Path+'Selected', FSelected, '');
 
142
 
 
143
  AStringToStringTree.AddNameValues(Self);
 
144
 
 
145
  SaveStringToStringTree(XMLConfig, AStringToStringTree, Path);
 
146
 
 
147
  FreeAndNil(AStringToStringTree);
 
148
end;
 
149
 
 
150
procedure TAdvHistoryList.Clear;
 
151
begin
 
152
  inherited;
 
153
  FSelected := '';
 
154
end;
 
155
 
 
156
procedure TAdvHistoryList.SetComboBox(AComboBox : TComboBox);
 
157
Var
 
158
  I, AIndex : Integer;
 
159
  AValue : String;
 
160
Begin
 
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);
 
165
    If AIndex = -1 Then
 
166
      If AValue <> '' Then
 
167
        AComboBox.Items.Add(AValue);
 
168
  end;
 
169
end;
 
170
 
 
171
initialization
 
172
  THistoryLists.RegisterHistoryListClass(TAdvHistoryList, hlCmdLineParamsHistoryList);
 
173
  THistoryLists.RegisterHistoryListClass(TAdvHistoryList, hlLaunchingApplicationHistoryList);
 
174
 
 
175
end.
 
176