source: tags/1.1.0/Forms/UFormCategorySelect.pas

Last change on this file was 33, checked in by chronos, 8 years ago
  • Added: Now import sources have categories which are merged to new imported acronym meanings.
File size: 1.9 KB
Line 
1unit UFormCategorySelect;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 UAcronym;
10
11type
12
13 { TFormCategorySelect }
14
15 TFormCategorySelect = class(TForm)
16 ButtonOk: TButton;
17 ButtonCancel: TButton;
18 ListBox1: TListBox;
19 procedure FormShow(Sender: TObject);
20 procedure ListBox1DblClick(Sender: TObject);
21 procedure ListBox1KeyPress(Sender: TObject; var Key: char);
22 private
23 { private declarations }
24 public
25 procedure Load(RemoveItems: TStrings);
26 end;
27
28var
29 FormCategorySelect: TFormCategorySelect;
30
31resourcestring
32 SCategory = 'Category';
33 SRemoveCategory = 'Remove categories';
34 SRemoveCategoryQuery = 'Do you really want to remove selected categories?';
35
36implementation
37
38{$R *.lfm}
39
40uses
41 UFormMain;
42
43{ TFormCategorySelect }
44
45procedure TFormCategorySelect.FormShow(Sender: TObject);
46begin
47end;
48
49procedure TFormCategorySelect.ListBox1DblClick(Sender: TObject);
50begin
51 ButtonOk.Click;
52end;
53
54procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: char);
55begin
56 if Key = #13 then ButtonOk.Click;
57end;
58
59procedure TFormCategorySelect.Load(RemoveItems: TStrings);
60var
61 Index: Integer;
62 I: Integer;
63begin
64 with FormMain.AcronymDb do begin
65 ListBox1.Sorted := False;
66 while ListBox1.Items.Count < Categories.Count do
67 ListBox1.Items.Add('');
68 while ListBox1.Items.Count > Categories.Count do
69 ListBox1.Items.Delete(ListBox1.Items.Count - 1);
70 for I := 0 to Categories.Count - 1 do begin
71 ListBox1.Items.Strings[I] := TAcronymCategory(Categories[I]).Name;
72 ListBox1.Items.Objects[I] := Categories[I];
73 ListBox1.Selected[I] := False;
74 end;
75 ListBox1.Sorted := True;
76 for I := 0 to RemoveItems.Count - 1 do begin
77 Index := ListBox1.Items.IndexOf(RemoveItems[I]);
78 if Index <> -1 then ListBox1.Items.Delete(Index);
79 end;
80 end;
81end;
82
83end.
84
Note: See TracBrowser for help on using the repository browser.