forked from tatassim/HashTable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUHashTableGUI.pas
More file actions
96 lines (83 loc) · 2.16 KB
/
UHashTableGUI.pas
File metadata and controls
96 lines (83 loc) · 2.16 KB
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
unit UHashTableGUI;
interface
uses UHashTable, UInfo, Grids, StdCtrls, Dialogs, SysUtils, Controls;
type
THashTableGUI = class(THashTable)
private
FModified: Boolean;
FFileName: string;
FIsTxt: boolean;
FStringGrid: TStringGrid;
protected
procedure SetModified(value: boolean);
public
constructor Create(ASG: TStringGrid; AC, AD: integer; ASize: integer);
function Load(AFileName: string; AIsTxt: Boolean): boolean;
procedure Save(AFileName: string; AIsTxt: Boolean);
procedure Clear;
function Add(info: TInfo): boolean;
function Delete(key: TKey): boolean;
property FileName: string read FFileName;
property Modified: Boolean read FModified write SetModified;
property IsTxt: Boolean read FIsTxt write FIsTxt;
end;
implementation
{ THashTableGUI }
function THashTableGUI.Add(info: TInfo): boolean;
begin
Result := true;
if inherited Add(info) = arOk then
Modified := True
else
Result := false;
end;
procedure THashTableGUI.Clear;
begin
if not IsEmpty then
begin
inherited;
Modified := true;
end;
end;
constructor THashTableGUI.Create(ASG: TStringGrid; AC, AD: Integer; ASize:
integer);
begin
FStringGrid := ASG;
inherited Create(AC, AD, ASize);
FFileName := '';
FModified := false;
ShowTitle(FStringGrid);
end;
function THashTableGUI.Delete(key: TKey): boolean;
begin
Result := inherited Delete(key);
Modified := Result or Modified;
end;
function THashTableGUI.Load(AFileName: string; AIsTxt: Boolean): boolean;
begin
FIsTxt := AIsTxt;
FFileName := AFileName;
if FIsTxt then
Result := LoadFromFile(AFileName)
else
Result := LoadFromBinFile(AFileName);
FModified := False;
PrintToGrid(FStringGrid);
end;
procedure THashTableGUI.Save(AFileName: string; AIsTxt: Boolean);
begin
FIsTxt := AIsTxt;
FFileName := AFileName;
if FIsTxt then
SaveToFile(AFileName)
else
SaveToBinFile(AFileName);
FModified := false;
end;
procedure THashTableGUI.SetModified(value: boolean);
begin
FModified := value;
if FModified then
PrintToGrid(FStringGrid);
end;
end.