1 | unit VCardFile;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, VCard, DataFile;
|
---|
7 |
|
---|
8 | type
|
---|
9 | { TVCardFile }
|
---|
10 |
|
---|
11 | TVCardFile = class(TDataFile)
|
---|
12 | private
|
---|
13 | procedure VCardModify(Sender: TObject);
|
---|
14 | public
|
---|
15 | VCard: TVCard;
|
---|
16 | function GetFileName: string; override;
|
---|
17 | function GetFileExt: string; override;
|
---|
18 | function GetFileFilter: string; override;
|
---|
19 | procedure SaveToFile(FileName: string); override;
|
---|
20 | procedure LoadFromFile(FileName: string); override;
|
---|
21 | procedure Assign(Source: TPersistent); override;
|
---|
22 | constructor Create(AOwner: TComponent); override;
|
---|
23 | destructor Destroy; override;
|
---|
24 | end;
|
---|
25 |
|
---|
26 |
|
---|
27 | implementation
|
---|
28 |
|
---|
29 | resourcestring
|
---|
30 | SVCardFile = 'vCard file';
|
---|
31 |
|
---|
32 | { TVCardFile }
|
---|
33 |
|
---|
34 | procedure TVCardFile.VCardModify(Sender: TObject);
|
---|
35 | begin
|
---|
36 | Modified := True;
|
---|
37 | end;
|
---|
38 |
|
---|
39 | function TVCardFile.GetFileName: string;
|
---|
40 | begin
|
---|
41 | Result := SVCardFile;
|
---|
42 | end;
|
---|
43 |
|
---|
44 | function TVCardFile.GetFileExt: string;
|
---|
45 | begin
|
---|
46 | Result := VCardFileExt;
|
---|
47 | end;
|
---|
48 |
|
---|
49 | function TVCardFile.GetFileFilter: string;
|
---|
50 | begin
|
---|
51 | Result := GetFileName + ' (' + GetFileExt + ')|*' + GetFileExt + '|' + inherited;
|
---|
52 | end;
|
---|
53 |
|
---|
54 | procedure TVCardFile.SaveToFile(FileName: string);
|
---|
55 | begin
|
---|
56 | inherited;
|
---|
57 | VCard.SaveToFile(FileName);
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TVCardFile.LoadFromFile(FileName: string);
|
---|
61 | begin
|
---|
62 | inherited;
|
---|
63 | VCard.LoadFromFile(FileName);
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TVCardFile.Assign(Source: TPersistent);
|
---|
67 | begin
|
---|
68 | inherited;
|
---|
69 | VCard.Assign(TVCardFile(Source).VCard)
|
---|
70 | end;
|
---|
71 |
|
---|
72 | constructor TVCardFile.Create(AOwner: TComponent);
|
---|
73 | begin
|
---|
74 | inherited;
|
---|
75 | VCard := TVCard.Create(nil);
|
---|
76 | VCard.OnModify := VCardModify;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | destructor TVCardFile.Destroy;
|
---|
80 | begin
|
---|
81 | FreeAndNil(VCard);
|
---|
82 | inherited;
|
---|
83 | end;
|
---|
84 |
|
---|
85 | end.
|
---|
86 |
|
---|