1 | unit _TemplateFileList;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
7 | Dialogs, _TemplateFile, StdCtrls, ExtCtrls, Menus, Buttons,
|
---|
8 | ComCtrls, TypeDefs, VirtualTrees;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TNewFileSelectingEvent = procedure(FileInfo: TFileInfo; var allowed: Boolean) of object;
|
---|
12 |
|
---|
13 | TForm_TemplateFileList = class(TForm_TemplateFile)
|
---|
14 | panel_files: TPanel;
|
---|
15 | splitter_content: TSplitter;
|
---|
16 | panel_content: TPanel;
|
---|
17 | filepopup: TPopupMenu;
|
---|
18 | popup_separator2: TMenuItem;
|
---|
19 | popup_linkshere: TMenuItem;
|
---|
20 | popup_separator: TMenuItem;
|
---|
21 | popup_import: TMenuItem;
|
---|
22 | popup_export: TMenuItem;
|
---|
23 | importd: TOpenDialog;
|
---|
24 | exportd: TSaveDialog;
|
---|
25 | FilePages: TPageControl;
|
---|
26 | tab_files: TTabSheet;
|
---|
27 | panel_extension: TPanel;
|
---|
28 | label_sort2: TLabel;
|
---|
29 | label_sort1: TLabel;
|
---|
30 | label_extension: TLabel;
|
---|
31 | btn_sort_id_asc: TSpeedButton;
|
---|
32 | btn_sort_id_desc: TSpeedButton;
|
---|
33 | btn_sort_name_asc: TSpeedButton;
|
---|
34 | btn_sort_name_desc: TSpeedButton;
|
---|
35 | btn_sort_ext_asc: TSpeedButton;
|
---|
36 | btn_sort_ext_desc: TSpeedButton;
|
---|
37 | combo_extension: TComboBox;
|
---|
38 | check_zerobyte: TCheckBox;
|
---|
39 | edit_filtername: TEdit;
|
---|
40 | check_filtername: TCheckBox;
|
---|
41 | filelist: TListBox;
|
---|
42 | tab_meta: TTabSheet;
|
---|
43 | filelist_meta: TVirtualStringTree;
|
---|
44 | procedure NewCon(ID: Integer);
|
---|
45 |
|
---|
46 | procedure check_filternameClick(Sender: TObject);
|
---|
47 | procedure check_zerobyteClick(Sender: TObject);
|
---|
48 | procedure combo_extensionClick(Sender: TObject);
|
---|
49 | procedure btn_sortClick(Sender: TObject);
|
---|
50 | procedure listClick(Sender: TObject);
|
---|
51 | procedure listMouseDown(Sender: TObject; Button: TMouseButton;
|
---|
52 | Shift: TShiftState; X, Y: Integer);
|
---|
53 |
|
---|
54 | procedure popup_importClick(Sender: TObject);
|
---|
55 | procedure popup_exportClick(Sender: TObject);
|
---|
56 | procedure popup_opentool(Sender: TObject);
|
---|
57 | procedure popup_linkshereClick(Sender: TObject);
|
---|
58 | procedure filepopupPopup(Sender: TObject);
|
---|
59 | procedure filelist_metaGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
---|
60 | Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
|
---|
61 | procedure filelist_metaInitChildren(Sender: TBaseVirtualTree;
|
---|
62 | Node: PVirtualNode; var ChildCount: Cardinal);
|
---|
63 | procedure filelist_metaPaintText(Sender: TBaseVirtualTree;
|
---|
64 | const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
|
---|
65 | TextType: TVSTTextType);
|
---|
66 | procedure filelist_metaFocusChanging(Sender: TBaseVirtualTree; OldNode,
|
---|
67 | NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
|
---|
68 | var Allowed: Boolean);
|
---|
69 | procedure filelist_metaFocusChanged(Sender: TBaseVirtualTree;
|
---|
70 | Node: PVirtualNode; Column: TColumnIndex);
|
---|
71 | private
|
---|
72 | FSortBy: TSortType;
|
---|
73 | FAllowedExts: String;
|
---|
74 | FAllowMultiSelect: Boolean;
|
---|
75 | FOnNewFileSelecting: TNewFileSelectingEvent;
|
---|
76 | procedure SetAllowedExts(exts: String);
|
---|
77 | procedure SetMultiSelect(allow: Boolean);
|
---|
78 | public
|
---|
79 | constructor Create(AOwner: TComponent); override;
|
---|
80 | procedure RecreateExtList;
|
---|
81 | procedure LoadFileNames;
|
---|
82 | procedure SetFileFilters(pattern, extension: String; zerobytes: Boolean);
|
---|
83 | property AllowedExts: String read FAllowedExts write SetAllowedExts;
|
---|
84 | property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect;
|
---|
85 | property OnNewFileSelecting: TNewFileSelectingEvent read FOnNewFileSelecting write FOnNewFileSelecting;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | implementation
|
---|
89 | {$R *.dfm}
|
---|
90 | uses ConnectionManager, Exporters, Functions, StrUtils, WhatLinksHere, Main,
|
---|
91 | _BaseTemplate, _MetaTypes, Data, _MetaManager, _FileTypes;
|
---|
92 |
|
---|
93 | type
|
---|
94 | PNodeData = ^TNodeData;
|
---|
95 |
|
---|
96 | TNodeData = record
|
---|
97 | Field: TObject;
|
---|
98 | end;
|
---|
99 |
|
---|
100 | function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode;
|
---|
101 | ARecord: TNodeData): PVirtualNode;
|
---|
102 | var
|
---|
103 | Data: PNodeData;
|
---|
104 | begin
|
---|
105 | Result := AVST.AddChild(ANode);
|
---|
106 | Data := AVST.GetNodeData(Result);
|
---|
107 | AVST.ValidateNode(Result, False);
|
---|
108 | Data^ := ARecord;
|
---|
109 | end;
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 | procedure TForm_TemplateFileList.RecreateExtList;
|
---|
114 | var
|
---|
115 | i: Integer;
|
---|
116 | exts: TStrings;
|
---|
117 | begin
|
---|
118 | combo_extension.Items.Clear;
|
---|
119 | if FConnectionID > -1 then
|
---|
120 | begin
|
---|
121 | combo_extension.Items.Add('_All files_ (' +
|
---|
122 | IntToStr(ConManager.Connection[FConnectionID].GetFileCount) + ')');
|
---|
123 | exts := nil;
|
---|
124 | exts := ConManager.Connection[FConnectionID].GetExtensionsList(EF_ExtCount);
|
---|
125 | for i := 0 to exts.Count - 1 do
|
---|
126 | if Length(FAllowedExts) > 0 then
|
---|
127 | begin
|
---|
128 | if Pos(MidStr(exts.Strings[i],1,4), FAllowedExts) > 0 then
|
---|
129 | combo_extension.Items.Add(exts.Strings[i]);
|
---|
130 | end
|
---|
131 | else
|
---|
132 | combo_extension.Items.Add(exts.Strings[i]);
|
---|
133 | combo_extension.ItemIndex := 0;
|
---|
134 | combo_extensionClick(Self);
|
---|
135 | exts.Free;
|
---|
136 | end;
|
---|
137 | end;
|
---|
138 |
|
---|
139 | procedure TForm_TemplateFileList.LoadFileNames;
|
---|
140 | var
|
---|
141 | Extension: String;
|
---|
142 | no_zero_bytes: Boolean;
|
---|
143 | pattern: String;
|
---|
144 | files: TStrings;
|
---|
145 | root: TExtensions;
|
---|
146 | i: Integer;
|
---|
147 | data: TNodeData;
|
---|
148 | node: PVirtualNode;
|
---|
149 | begin
|
---|
150 | if FConnectionID > -1 then
|
---|
151 | begin
|
---|
152 | Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4);
|
---|
153 | no_zero_bytes := not check_zerobyte.Checked;
|
---|
154 | pattern := '';
|
---|
155 | if check_filtername.Checked then
|
---|
156 | pattern := edit_filtername.Text;
|
---|
157 | if Extension = '_All' then
|
---|
158 | if Length(FAllowedExts) > 0 then
|
---|
159 | Extension := FAllowedExts
|
---|
160 | else
|
---|
161 | Extension := '';
|
---|
162 |
|
---|
163 | files := nil;
|
---|
164 | files := ConManager.Connection[FConnectionID].GetFilesList(extension, pattern, no_zero_bytes, FSortBy);
|
---|
165 |
|
---|
166 | filelist.Visible := False;
|
---|
167 | filelist.Items.Clear;
|
---|
168 | if files.Count > 0 then
|
---|
169 | filelist.Items.AddStrings(files);
|
---|
170 | filelist.Visible := True;
|
---|
171 |
|
---|
172 | //VST
|
---|
173 | filelist_meta.Clear;
|
---|
174 | filelist_meta.BeginUpdate;
|
---|
175 | root := ConManager.Connection[FConnectionID].MetaData.Root;
|
---|
176 | for i := 0 to High(root) do
|
---|
177 | begin
|
---|
178 | data.Field := root[i];
|
---|
179 | node := AddVSTEntry(filelist_meta, nil, data);
|
---|
180 | filelist_meta.HasChildren[node] := True;
|
---|
181 | end;
|
---|
182 | filelist_meta.EndUpdate;
|
---|
183 | end;
|
---|
184 | end;
|
---|
185 |
|
---|
186 |
|
---|
187 | procedure TForm_TemplateFileList.NewCon(ID: Integer);
|
---|
188 | begin
|
---|
189 | RecreateExtList;
|
---|
190 | end;
|
---|
191 |
|
---|
192 | procedure TForm_TemplateFileList.popup_exportClick(Sender: TObject);
|
---|
193 | var
|
---|
194 | id: Integer;
|
---|
195 | ext: String;
|
---|
196 | begin
|
---|
197 | id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
|
---|
198 | ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4);
|
---|
199 | exportd.Filter := 'Files of matching extension (*.' + ext + ')|*.' + ext + '|All files|*.*';
|
---|
200 | exportd.DefaultExt := ext;
|
---|
201 | if exportd.Execute then
|
---|
202 | ExportDatFile(FConnectionID, id, exportd.FileName);
|
---|
203 | end;
|
---|
204 |
|
---|
205 | procedure TForm_TemplateFileList.popup_importClick(Sender: TObject);
|
---|
206 | var
|
---|
207 | id: Integer;
|
---|
208 | finfo: TFileInfo;
|
---|
209 | fs: TFileStream;
|
---|
210 | begin
|
---|
211 | if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then
|
---|
212 | begin
|
---|
213 | id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
|
---|
214 | finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
|
---|
215 |
|
---|
216 | importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
|
---|
217 | finfo.Extension + '|All files|*.*';
|
---|
218 | if importd.Execute then
|
---|
219 | begin
|
---|
220 | fs := TFileStream.Create(importd.FileName, fmOpenRead);
|
---|
221 | if fs.Size <> finfo.Size then
|
---|
222 | begin
|
---|
223 | if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then
|
---|
224 | begin
|
---|
225 | ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
|
---|
226 | ', file has to have same size as file in .dat with this backend.' + CrLf +
|
---|
227 | 'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
|
---|
228 | 'Size of chosen file: ' + FormatFileSize(fs.Size));
|
---|
229 | Exit;
|
---|
230 | end else begin
|
---|
231 | if MessageBox(Self.Handle,
|
---|
232 | PChar('File has different size from the file in the .dat.' + CrLf +
|
---|
233 | 'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
|
---|
234 | 'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf +
|
---|
235 | 'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then
|
---|
236 | begin
|
---|
237 | Exit;
|
---|
238 | end;
|
---|
239 | end;
|
---|
240 | end;
|
---|
241 | ConManager.Connection[FConnectionID].UpdateDatFile(id, fs);
|
---|
242 | Self.listClick(Self);
|
---|
243 | fs.Free;
|
---|
244 | end;
|
---|
245 | end else begin
|
---|
246 | ShowMessage('Editing .dat-contents not allowed with this backend.');
|
---|
247 | end;
|
---|
248 | end;
|
---|
249 |
|
---|
250 |
|
---|
251 | procedure TForm_TemplateFileList.popup_linkshereClick(Sender: TObject);
|
---|
252 | begin
|
---|
253 | Form_WhatLinksHere.ConID := FConnectionID;
|
---|
254 | Form_WhatLinksHere.FileID := FSelectedFile.ID;
|
---|
255 | Form_WhatLinksHere.SenderForm := Self;
|
---|
256 | Form_WhatLinksHere.Show;
|
---|
257 | end;
|
---|
258 |
|
---|
259 | procedure TForm_TemplateFileList.popup_opentool(Sender: TObject);
|
---|
260 | var
|
---|
261 | sender_name, context: String;
|
---|
262 | id: Integer;
|
---|
263 | begin
|
---|
264 | sender_name := TComponent(Sender).Name;
|
---|
265 | id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
|
---|
266 | context := MidStr(sender_name, Pos('_', sender_name) + 1, Length(sender_name) - Pos('_', sender_name));
|
---|
267 | Form_Main.open_child(context, FConnectionID, id);
|
---|
268 | end;
|
---|
269 |
|
---|
270 |
|
---|
271 | procedure TForm_TemplateFileList.filepopupPopup(Sender: TObject);
|
---|
272 | var
|
---|
273 | ext: String;
|
---|
274 | i: Integer;
|
---|
275 | begin
|
---|
276 | ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4);
|
---|
277 | for i := 0 to High(ToolList) do
|
---|
278 | begin
|
---|
279 | filepopup.Items.Items[i].Enabled := True;
|
---|
280 | if Length(ToolList[i].exts) > 0 then
|
---|
281 | if Pos(ext, ToolList[i].exts) = 0 then
|
---|
282 | filepopup.Items.Items[i].Enabled := False;
|
---|
283 | end;
|
---|
284 | end;
|
---|
285 |
|
---|
286 |
|
---|
287 | procedure TForm_TemplateFileList.check_zerobyteClick(Sender: TObject);
|
---|
288 | begin
|
---|
289 | LoadFileNames;
|
---|
290 | end;
|
---|
291 |
|
---|
292 | procedure TForm_TemplateFileList.btn_sortClick(Sender: TObject);
|
---|
293 | begin
|
---|
294 | if btn_sort_id_asc.Down then
|
---|
295 | FSortBy := ST_IDAsc
|
---|
296 | else if btn_sort_id_desc.Down then
|
---|
297 | FSortBy := ST_IDDesc
|
---|
298 | else if btn_sort_name_asc.Down then
|
---|
299 | FSortBy := ST_NameAsc
|
---|
300 | else if btn_sort_name_desc.Down then
|
---|
301 | FSortBy := ST_NameDesc
|
---|
302 | else if btn_sort_ext_asc.Down then
|
---|
303 | FSortBy := ST_ExtAsc
|
---|
304 | else if btn_sort_ext_desc.Down then
|
---|
305 | FSortBy := ST_ExtDesc;
|
---|
306 | LoadFileNames;
|
---|
307 | end;
|
---|
308 |
|
---|
309 | procedure TForm_TemplateFileList.check_filternameClick(Sender: TObject);
|
---|
310 | begin
|
---|
311 | edit_filtername.Enabled := not check_filtername.Checked;
|
---|
312 | LoadFileNames;
|
---|
313 | end;
|
---|
314 |
|
---|
315 | procedure TForm_TemplateFileList.combo_extensionClick(Sender: TObject);
|
---|
316 | begin
|
---|
317 | LoadFileNames;
|
---|
318 | end;
|
---|
319 |
|
---|
320 | procedure TForm_TemplateFileList.listClick(Sender: TObject);
|
---|
321 | var
|
---|
322 | fileid: Integer;
|
---|
323 | begin
|
---|
324 | if filelist.ItemIndex > -1 then
|
---|
325 | begin
|
---|
326 | fileid := ConManager.Connection[FConnectionID].ExtractFileIDOfName(
|
---|
327 | filelist.Items.Strings[filelist.ItemIndex]);
|
---|
328 | FSelectedFile := ConManager.Connection[FConnectionID].GetFileInfo(fileid);
|
---|
329 | if Assigned(FOnNewFileSelected) then
|
---|
330 | FOnNewFileSelected(FSelectedFile);
|
---|
331 | end;
|
---|
332 | end;
|
---|
333 |
|
---|
334 | procedure TForm_TemplateFileList.listMouseDown(Sender: TObject; Button: TMouseButton;
|
---|
335 | Shift: TShiftState; X, Y: Integer);
|
---|
336 | var
|
---|
337 | pt: TPoint;
|
---|
338 | begin
|
---|
339 | pt.X := x;
|
---|
340 | pt.Y := y;
|
---|
341 | if Shift = [ssRight] then
|
---|
342 | begin
|
---|
343 | filelist.ItemIndex := filelist.ItemAtPos(pt, true);
|
---|
344 | Self.listClick(Self);
|
---|
345 | end;
|
---|
346 | end;
|
---|
347 |
|
---|
348 |
|
---|
349 |
|
---|
350 | procedure TForm_TemplateFileList.SetAllowedExts(exts: String);
|
---|
351 | begin
|
---|
352 | FAllowedExts := exts;
|
---|
353 | RecreateExtList;
|
---|
354 | end;
|
---|
355 |
|
---|
356 | procedure TForm_TemplateFileList.SetFileFilters(pattern, extension: String;
|
---|
357 | zerobytes: Boolean);
|
---|
358 | var
|
---|
359 | i: Integer;
|
---|
360 | begin
|
---|
361 | if Length(pattern) > 0 then
|
---|
362 | Self.edit_filtername.Text := pattern;
|
---|
363 | Self.check_filtername.Checked := Length(pattern) > 0;
|
---|
364 | if Length(extension) > 0 then
|
---|
365 | begin
|
---|
366 | for i := 0 to Self.combo_extension.Items.Count - 1 do
|
---|
367 | if Pos(extension, Self.combo_extension.Items.Strings[i]) > 0 then
|
---|
368 | Break;
|
---|
369 | if i < Self.combo_extension.Items.Count then
|
---|
370 | Self.combo_extension.ItemIndex := i
|
---|
371 | else
|
---|
372 | Self.combo_extension.ItemIndex := -1;
|
---|
373 | end;
|
---|
374 | Self.check_zerobyte.Checked := zerobytes;
|
---|
375 | Self.LoadFileNames;
|
---|
376 | end;
|
---|
377 |
|
---|
378 | procedure TForm_TemplateFileList.SetMultiSelect(allow: Boolean);
|
---|
379 | begin
|
---|
380 | FAllowMultiSelect := allow;
|
---|
381 | filelist.MultiSelect := allow;
|
---|
382 | end;
|
---|
383 |
|
---|
384 |
|
---|
385 |
|
---|
386 | constructor TForm_TemplateFileList.Create(AOwner: TComponent);
|
---|
387 | var
|
---|
388 | i: Integer;
|
---|
389 | item: TMenuItem;
|
---|
390 | begin
|
---|
391 | inherited;
|
---|
392 | filelist_meta.NodeDataSize := SizeOf(TNodeData);
|
---|
393 | filelist_meta.Font.Charset := AppSettings.CharSet;
|
---|
394 | filelist_meta.Clear;
|
---|
395 |
|
---|
396 | FAllowedExts := '';
|
---|
397 | FAllowMultiSelect := False;
|
---|
398 | FOnNewConnection := NewCon;
|
---|
399 | UpdateConList;
|
---|
400 | if Length(ToolList) > 0 then
|
---|
401 | begin
|
---|
402 | for i := 0 to High(ToolList) do
|
---|
403 | begin
|
---|
404 | item := TMenuItem.Create(filepopup);
|
---|
405 | item.Name := 'popup_' + ToolList[i].context;
|
---|
406 | item.Caption := 'Open with ' + ToolList[i].name;
|
---|
407 | item.OnClick := Self.popup_opentool;
|
---|
408 | filepopup.Items.Insert(i, item);
|
---|
409 | end;
|
---|
410 | end;
|
---|
411 | end;
|
---|
412 |
|
---|
413 |
|
---|
414 |
|
---|
415 | procedure TForm_TemplateFileList.filelist_metaFocusChanged(
|
---|
416 | Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
|
---|
417 | var
|
---|
418 | data: PNodeData;
|
---|
419 | begin
|
---|
420 | inherited;
|
---|
421 | data := Sender.GetNodeData(Node);
|
---|
422 | if data.Field is TFile then
|
---|
423 | begin
|
---|
424 | if Assigned(FOnNewFileSelected) then
|
---|
425 | begin
|
---|
426 | FOnNewFileSelected(TFile(data.Field).FileInfo);
|
---|
427 | end;
|
---|
428 | end;
|
---|
429 | end;
|
---|
430 |
|
---|
431 | procedure TForm_TemplateFileList.filelist_metaFocusChanging(
|
---|
432 | Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn,
|
---|
433 | NewColumn: TColumnIndex; var Allowed: Boolean);
|
---|
434 | var
|
---|
435 | data: PNodeData;
|
---|
436 | begin
|
---|
437 | inherited;
|
---|
438 | data := Sender.GetNodeData(NewNode);
|
---|
439 | if data.Field is TFile then
|
---|
440 | begin
|
---|
441 | if Assigned(FOnNewFileSelecting) then
|
---|
442 | begin
|
---|
443 | FOnNewFileSelecting(TFile(data.Field).FileInfo, Allowed);
|
---|
444 | end;
|
---|
445 | end;
|
---|
446 | end;
|
---|
447 |
|
---|
448 | procedure TForm_TemplateFileList.filelist_metaGetText(Sender: TBaseVirtualTree;
|
---|
449 | Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
---|
450 | var CellText: WideString);
|
---|
451 | var
|
---|
452 | data: PNodeData;
|
---|
453 | begin
|
---|
454 | inherited;
|
---|
455 | data := Sender.GetNodeData(Node);
|
---|
456 | if data.Field is TExtension then
|
---|
457 | begin
|
---|
458 | CellText := TExtension(data.Field).Ext;
|
---|
459 | end;
|
---|
460 | if data.Field is TFile then
|
---|
461 | begin
|
---|
462 | if TFile(data.Field).FileInfo.Name = '' then
|
---|
463 | CellText := TFile(data.Field).FileInfo.Extension + ' (unnamed)'
|
---|
464 | else
|
---|
465 | CellText := TFile(data.Field).FileInfo.Extension + ': ' + TFile(data.Field).FileInfo.Name;
|
---|
466 | end;
|
---|
467 | end;
|
---|
468 |
|
---|
469 |
|
---|
470 | procedure TForm_TemplateFileList.filelist_metaInitChildren(
|
---|
471 | Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
|
---|
472 | var
|
---|
473 | data: PNodeData;
|
---|
474 | i: Integer;
|
---|
475 | newdata: TNodeData;
|
---|
476 | newnode: PVirtualNode;
|
---|
477 | id: Integer;
|
---|
478 | begin
|
---|
479 | inherited;
|
---|
480 | data := Sender.GetNodeData(Node);
|
---|
481 | Self.Cursor := crHourGlass;
|
---|
482 | Application.ProcessMessages;
|
---|
483 | if data.Field is TExtension then
|
---|
484 | begin
|
---|
485 | if TExtension(data.Field).FileCount = 0 then
|
---|
486 | TExtension(data.Field).InitList;
|
---|
487 | for i := 0 to TExtension(data.Field).FileCount - 1 do
|
---|
488 | begin
|
---|
489 | id := TExtension(data.Field).Files[i];
|
---|
490 | ConManager.Connection[FConnectionID].MetaData.InitFile(id);
|
---|
491 | newdata.Field := ConManager.Connection[FConnectionID].MetaData.FileById[id];
|
---|
492 | newnode := AddVSTEntry(filelist_meta, Node, newdata);
|
---|
493 | if ConManager.Connection[FConnectionID].MetaData.FileById[id].ChildCount > 0 then
|
---|
494 | filelist_meta.HasChildren[newnode] := True;
|
---|
495 | ChildCount := filelist_meta.ChildCount[node];
|
---|
496 | end;
|
---|
497 | end;
|
---|
498 | if data.Field is TFile then
|
---|
499 | begin
|
---|
500 | for i := 0 to TFile(data.Field).ChildCount - 1 do
|
---|
501 | begin
|
---|
502 | id := TFile(data.Field).LinkByIndex[i].DestID;
|
---|
503 | ConManager.Connection[FConnectionID].MetaData.InitFile(id);
|
---|
504 | newdata.Field := ConManager.Connection[FConnectionID].MetaData.FileById[id];
|
---|
505 | newnode := AddVSTEntry(filelist_meta, Node, newdata);
|
---|
506 | if ConManager.Connection[FConnectionID].MetaData.FileById[id].ChildCount > 0 then
|
---|
507 | filelist_meta.HasChildren[newnode] := True;
|
---|
508 | end;
|
---|
509 | ChildCount := filelist_meta.ChildCount[node];
|
---|
510 | end;
|
---|
511 | Self.Cursor := crDefault;
|
---|
512 | end;
|
---|
513 |
|
---|
514 | procedure TForm_TemplateFileList.filelist_metaPaintText(
|
---|
515 | Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode;
|
---|
516 | Column: TColumnIndex; TextType: TVSTTextType);
|
---|
517 | var
|
---|
518 | Data: PNodeData;
|
---|
519 | begin
|
---|
520 | Data := Sender.GetNodeData(Node);
|
---|
521 | if Data.Field is TFile then
|
---|
522 | begin
|
---|
523 | if Length(TFile(Data.Field).FileInfo.Name) = 0 then
|
---|
524 | TargetCanvas.Font.Color := $C06060;
|
---|
525 | if TFile(Data.Field).FileInfo.Size = 0 then
|
---|
526 | TargetCanvas.Font.Color := $2020A0;
|
---|
527 | end;
|
---|
528 | end;
|
---|
529 |
|
---|
530 | end.
|
---|