1 | unit FormBrowse;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
|
---|
7 | ExtCtrls, Menus, ActnList, FindFile, VCS, LazFileUtils;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormBrowse }
|
---|
12 |
|
---|
13 | TFormBrowse = class(TForm)
|
---|
14 | AAdd: TAction;
|
---|
15 | ALogShow: TAction;
|
---|
16 | AOpen: TAction;
|
---|
17 | AProperties: TAction;
|
---|
18 | AUpdate: TAction;
|
---|
19 | ARename: TAction;
|
---|
20 | ADelete: TAction;
|
---|
21 | ActionList1: TActionList;
|
---|
22 | ListView1: TListView;
|
---|
23 | MainMenu1: TMainMenu;
|
---|
24 | MenuItem1: TMenuItem;
|
---|
25 | MenuItem2: TMenuItem;
|
---|
26 | MenuItem3: TMenuItem;
|
---|
27 | MenuItem4: TMenuItem;
|
---|
28 | MenuItem5: TMenuItem;
|
---|
29 | MenuItem6: TMenuItem;
|
---|
30 | MenuItem7: TMenuItem;
|
---|
31 | PopupMenu1: TPopupMenu;
|
---|
32 | Splitter1: TSplitter;
|
---|
33 | TreeView1: TTreeView;
|
---|
34 | procedure AAddExecute(Sender: TObject);
|
---|
35 | procedure ADeleteExecute(Sender: TObject);
|
---|
36 | procedure ALogShowExecute(Sender: TObject);
|
---|
37 | procedure AOpenExecute(Sender: TObject);
|
---|
38 | procedure ARenameExecute(Sender: TObject);
|
---|
39 | procedure FormCreate(Sender: TObject);
|
---|
40 | procedure FormDestroy(Sender: TObject);
|
---|
41 | procedure FormShow(Sender: TObject);
|
---|
42 | procedure ListView1Data(Sender: TObject; Item: TListItem);
|
---|
43 | procedure ListView1DblClick(Sender: TObject);
|
---|
44 | procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
|
---|
45 | Selected: Boolean);
|
---|
46 | private
|
---|
47 | FileList: TFileStatuses;
|
---|
48 | public
|
---|
49 | Directory: string;
|
---|
50 | procedure ReloadList;
|
---|
51 | procedure UpdateInterface;
|
---|
52 | end;
|
---|
53 |
|
---|
54 |
|
---|
55 | implementation
|
---|
56 |
|
---|
57 | uses
|
---|
58 | Core, FormLog;
|
---|
59 |
|
---|
60 | {$R *.lfm}
|
---|
61 |
|
---|
62 | { TFormBrowse }
|
---|
63 |
|
---|
64 | procedure TFormBrowse.ListView1Data(Sender: TObject; Item: TListItem);
|
---|
65 | begin
|
---|
66 | if (Item.Index >= 0) and (Item.Index < FileList.Count) then
|
---|
67 | with TFileStatus(FileList[Item.Index]) do begin
|
---|
68 | Item.Caption := ExtractFileName(FileName);
|
---|
69 | if State <> fssNonVersioned then begin
|
---|
70 | Item.SubItems.Add(Version);
|
---|
71 | Item.SubItems.Add(DateToStr(Time));
|
---|
72 | Item.SubItems.Add(Author);
|
---|
73 | Item.SubItems.Add(FileStatusStateText[State]);
|
---|
74 | end;
|
---|
75 | end;
|
---|
76 | end;
|
---|
77 |
|
---|
78 | procedure TFormBrowse.ListView1DblClick(Sender: TObject);
|
---|
79 | begin
|
---|
80 |
|
---|
81 | end;
|
---|
82 |
|
---|
83 | procedure TFormBrowse.ListView1SelectItem(Sender: TObject; Item: TListItem;
|
---|
84 | Selected: Boolean);
|
---|
85 | begin
|
---|
86 | UpdateInterface;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TFormBrowse.ADeleteExecute(Sender: TObject);
|
---|
90 | begin
|
---|
91 |
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TFormBrowse.ALogShowExecute(Sender: TObject);
|
---|
95 | var
|
---|
96 | FormLog: TFormLog;
|
---|
97 | begin
|
---|
98 | FormLog := TFormLog.Create(nil);
|
---|
99 | try
|
---|
100 | FormLog.FileName := Directory + DirectorySeparator + ListView1.Selected.Caption;
|
---|
101 | FormLog.ShowModal;
|
---|
102 | finally
|
---|
103 | FormLog.Free;
|
---|
104 | end;
|
---|
105 | end;
|
---|
106 |
|
---|
107 | procedure TFormBrowse.AAddExecute(Sender: TObject);
|
---|
108 | begin
|
---|
109 | Core.Core.Project.WorkingCopy.Add(Directory + DirectorySeparator + ListView1.Selected.Caption);
|
---|
110 | end;
|
---|
111 |
|
---|
112 | procedure TFormBrowse.AOpenExecute(Sender: TObject);
|
---|
113 | begin
|
---|
114 | if Assigned(ListView1.Selected) then
|
---|
115 | with ListView1.Selected do begin
|
---|
116 | if Caption = '..' then begin
|
---|
117 | Directory := ExtractFileDir(Directory);
|
---|
118 | ReloadList;
|
---|
119 | end else
|
---|
120 | if DirectoryExists(Directory + DirectorySeparator + Caption) then begin
|
---|
121 | Directory := Directory + DirectorySeparator + ListView1.Selected.Caption;
|
---|
122 | ReloadList;
|
---|
123 | end;
|
---|
124 | end;
|
---|
125 | end;
|
---|
126 |
|
---|
127 | procedure TFormBrowse.ARenameExecute(Sender: TObject);
|
---|
128 | var
|
---|
129 | NewName: string;
|
---|
130 | begin
|
---|
131 | NewName := '';
|
---|
132 | if InputQuery('Rename', 'Enter new name', NewName) then
|
---|
133 | Core.Core.Project.WorkingCopy.Move(Directory + DirectorySeparator + ListView1.Selected.Caption, NewName);
|
---|
134 | end;
|
---|
135 |
|
---|
136 | procedure TFormBrowse.FormCreate(Sender: TObject);
|
---|
137 | begin
|
---|
138 | FileList := TFileStatuses.Create;
|
---|
139 | end;
|
---|
140 |
|
---|
141 | procedure TFormBrowse.FormDestroy(Sender: TObject);
|
---|
142 | begin
|
---|
143 | FreeAndNil(FileList);
|
---|
144 | end;
|
---|
145 |
|
---|
146 | procedure TFormBrowse.FormShow(Sender: TObject);
|
---|
147 | begin
|
---|
148 | UpdateInterface;
|
---|
149 | end;
|
---|
150 |
|
---|
151 | procedure TFormBrowse.ReloadList;
|
---|
152 | var
|
---|
153 | FindFile: TFindFile;
|
---|
154 | FoundFileList: TStrings;
|
---|
155 | I: Integer;
|
---|
156 | FileStatusList: TFileStatuses;
|
---|
157 | NewFileItem: TFileStatus;
|
---|
158 | FS: TFileStatus;
|
---|
159 | RelativeName: string;
|
---|
160 | begin
|
---|
161 | FileList.Clear;
|
---|
162 | if Assigned(Core.Core.Project) then begin
|
---|
163 | FileStatusList := TFileStatuses.Create;
|
---|
164 | try
|
---|
165 | Core.Core.Project.WorkingCopy.GetStatus(Directory, FileStatusList);
|
---|
166 |
|
---|
167 | if DirectoryExists(Directory) then begin
|
---|
168 | FindFile := TFindFile.Create(nil);
|
---|
169 | try
|
---|
170 | FindFile.Path := Directory;
|
---|
171 | FindFile.FileMask := AllFilesMask;
|
---|
172 | FindFile.InSubFolders := False;
|
---|
173 | FoundFileList := FindFile.SearchForFiles;
|
---|
174 | //FoundFileList.Sort;
|
---|
175 | for I := 0 to FoundFileList.Count - 1 do begin
|
---|
176 | NewFileItem := TFileStatus.Create;
|
---|
177 | NewFileItem.FileName := FoundFileList[I];
|
---|
178 | RelativeName := NewFileItem.FileName;
|
---|
179 | if Copy(RelativeName, 1, Length(Core.Core.Project.WorkingCopy.Path)) = Core.Core.Project.WorkingCopy.Path then
|
---|
180 | Delete(RelativeName, 1, Length(Core.Core.Project.WorkingCopy.Path));
|
---|
181 | if Copy(RelativeName, 1, 1) = DirectorySeparator then
|
---|
182 | Delete(RelativeName, 1, Length(DirectorySeparator));
|
---|
183 | FS := FileStatusList.SearchByName(RelativeName);
|
---|
184 | if Assigned(FS) then begin
|
---|
185 | NewFileItem.Assign(FS);
|
---|
186 | end;
|
---|
187 | FileList.Add(NewFileItem);
|
---|
188 | end;
|
---|
189 | for I := FileList.Count - 1 downto 0 do
|
---|
190 | if ExtractFileName(TFileStatus(FileList[I]).FileName) = '.' then FileList.Delete(I);
|
---|
191 | ListView1.Items.Count := FileList.Count;
|
---|
192 | finally
|
---|
193 | FindFile.Free;
|
---|
194 | end;
|
---|
195 | end else ListView1.Items.Count := 0;
|
---|
196 | finally
|
---|
197 | FileStatusList.Free;
|
---|
198 | end;
|
---|
199 | end;
|
---|
200 | ListView1.Refresh;
|
---|
201 | end;
|
---|
202 |
|
---|
203 | procedure TFormBrowse.UpdateInterface;
|
---|
204 | begin
|
---|
205 | AAdd.Enabled := Assigned(ListView1.Selected);
|
---|
206 | ADelete.Enabled := Assigned(ListView1.Selected);
|
---|
207 | ARename.Enabled := Assigned(ListView1.Selected);
|
---|
208 | AProperties.Enabled := Assigned(ListView1.Selected);
|
---|
209 | AOpen.Enabled := Assigned(ListView1.Selected);
|
---|
210 | ALogShow.Enabled := Assigned(ListView1.Selected);
|
---|
211 | end;
|
---|
212 |
|
---|
213 | end.
|
---|
214 |
|
---|