forked from indomit/quice
-
Notifications
You must be signed in to change notification settings - Fork 3
/
SoundEntriesUnit.pas
125 lines (108 loc) · 2.83 KB
/
SoundEntriesUnit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
unit SoundEntriesUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Functions, ExtCtrls, JvExComCtrls, JvListView;
type
TSoundEntriesForm = class(TForm)
PageControl1: TPageControl;
tsSearch: TTabSheet;
pnSearch: TPanel;
edSearchMask: TLabeledEdit;
Panel1: TPanel;
btOK: TButton;
btCancel: TButton;
lvList: TListView;
procedure lvListChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure edSearchMaskChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure lvListDblClick(Sender: TObject);
procedure lvListColumnClick(Sender: TObject; Column: TListColumn);
private
prmID: integer;
procedure Search();
public
procedure Prepare(Text: string);
function GetValue(ID: integer): WideString;
end;
var
SoundEntriesForm: TSoundEntriesForm;
implementation
uses MyDataModule, MainUnit;
{$R *.dfm}
{ TSoundEntriesForm }
procedure TSoundEntriesForm.Prepare(Text: string);
var
i: integer;
begin
if lvList.Items.Count=0 then SetList(lvList, 'SoundEntries');
for i:=0 to lvList.Items.Count - 1 do
begin
if lvList.Items[i].Caption = Text then
begin
lvList.Selected:=lvList.Items[i];
lvList.Selected.MakeVisible(false);
Exit;
end;
end;
end;
procedure TSoundEntriesForm.Search;
var
i: integer;
begin
for i:=0 to lvList.Items.Count - 1 do
begin
if Pos(LowerCase(edSearchMask.Text), LowerCase(lvList.Items[i].SubItems[0])) > 0 then
begin
lvList.Selected:=lvList.Items[i];
lvList.Selected.MakeVisible(false);
Exit;
end;
end;
end;
procedure TSoundEntriesForm.lvListChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
btOK.Enabled:=Assigned(lvList.Selected);
end;
procedure TSoundEntriesForm.lvListColumnClick(Sender: TObject; Column: TListColumn);
begin
if (column.Index = 0) then
begin
lvList.CustomSort(@CustomIDSortProc, prmID);
prmID := -prmID;
end
else
lvList.CustomSort(@CustomNameSortProc, column.Index);
end;
procedure TSoundEntriesForm.lvListDblClick(Sender: TObject);
begin
if Assigned(TJvListView(Sender).Selected) then ModalResult:=mrOk;
end;
procedure TSoundEntriesForm.edSearchMaskChange(Sender: TObject);
begin
Search;
end;
procedure TSoundEntriesForm.FormCreate(Sender: TObject);
begin
if not MainForm.MyMangosConnection.Connected then Exit;
dmMain.Translate.CreateDefaultTranslation(TForm(Self));
dmMain.Translate.TranslateForm(TForm(Self));
end;
function TSoundEntriesForm.GetValue(id: integer): WideString;
var
i: integer;
begin
Result:='';
if id<1 then Exit;
for i:=0 to lvList.Items.Count - 1 do
begin
if id = StrToIntDef(lvList.Items[i].Caption,0) then
begin
Result := lvList.Items[i].SubItems[0];
Exit;
end;
end;
end;
end.