1 | unit UFormSearch;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | ComCtrls, Contnrs;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormSearch }
|
---|
14 |
|
---|
15 | TFormSearch = class(TForm)
|
---|
16 | ButtonSearch: TButton;
|
---|
17 | EditText: TEdit;
|
---|
18 | ListView1: TListView;
|
---|
19 | procedure ButtonSearchClick(Sender: TObject);
|
---|
20 | procedure EditTextKeyPress(Sender: TObject; var Key: char);
|
---|
21 | procedure ListView1DblClick(Sender: TObject);
|
---|
22 | procedure ListView1KeyPress(Sender: TObject; var Key: char);
|
---|
23 | private
|
---|
24 | { private declarations }
|
---|
25 | public
|
---|
26 | { public declarations }
|
---|
27 | end;
|
---|
28 |
|
---|
29 | var
|
---|
30 | FormSearch: TFormSearch;
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 | uses
|
---|
35 | UFormMain, UKConfig;
|
---|
36 |
|
---|
37 | {$R *.lfm}
|
---|
38 |
|
---|
39 | { TFormSearch }
|
---|
40 |
|
---|
41 | procedure TFormSearch.ButtonSearchClick(Sender: TObject);
|
---|
42 | var
|
---|
43 | List: TObjectList;
|
---|
44 | NewItem: TListItem;
|
---|
45 | I: Integer;
|
---|
46 | begin
|
---|
47 | try
|
---|
48 | List := TObjectList.Create;
|
---|
49 | List.OwnsObjects := False;
|
---|
50 | FormMain.Config.TopNode.Search(EditText.Text, List);
|
---|
51 | ListView1.Items.Clear;
|
---|
52 | ListView1.Items.BeginUpdate;
|
---|
53 | for I := 0 to List.Count - 1 do
|
---|
54 | with TMenuNode(List[I]) do begin
|
---|
55 | NewItem := ListView1.Items.Add;
|
---|
56 | NewItem.Data := List[I];
|
---|
57 | NewItem.Caption := ID;
|
---|
58 | NewItem.SubItems.Add(Name);
|
---|
59 | NewItem.SubItems.Add(GetabsoluteName);
|
---|
60 | end;
|
---|
61 | finally
|
---|
62 | ListView1.Items.EndUpdate;
|
---|
63 | List.Free;
|
---|
64 | end;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TFormSearch.EditTextKeyPress(Sender: TObject; var Key: char);
|
---|
68 | begin
|
---|
69 | if Key = #13 then ButtonSearch.Click;
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TFormSearch.ListView1DblClick(Sender: TObject);
|
---|
73 | begin
|
---|
74 | if Assigned(ListView1.Selected) then
|
---|
75 | FormMain.FocusTreeNode(ListView1.Selected.Data);
|
---|
76 | end;
|
---|
77 |
|
---|
78 | procedure TFormSearch.ListView1KeyPress(Sender: TObject; var Key: char);
|
---|
79 | begin
|
---|
80 | if (Key = #13) and Assigned(ListView1.Selected) then
|
---|
81 | FormMain.FocusTreeNode(ListView1.Selected.Data);
|
---|
82 | end;
|
---|
83 |
|
---|
84 | end.
|
---|
85 |
|
---|