1 | unit _FileTypes;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | TypeDefs, _DataTypes, _TreeElement, Classes, Forms;
|
---|
7 |
|
---|
8 |
|
---|
9 | type
|
---|
10 | TFile = class(TTreeElement)
|
---|
11 | function GetChildCount: Integer; override;
|
---|
12 | function GetChild(ID: Integer): TTreeElement; override;
|
---|
13 | function GetCaption: String; override;
|
---|
14 | protected
|
---|
15 | FFileInfo: TFileInfo;
|
---|
16 | FFileStream: TMemoryStream;
|
---|
17 |
|
---|
18 | FCached: Boolean;
|
---|
19 | FChanged: Boolean;
|
---|
20 |
|
---|
21 | FDataFields: TBlock;
|
---|
22 |
|
---|
23 | FEditor: TFrame;
|
---|
24 | FOpened: Boolean;
|
---|
25 |
|
---|
26 | function GetFieldByOffset(Offset: Integer): TDataField;
|
---|
27 | published
|
---|
28 | public
|
---|
29 | constructor Create(ConnectionID, FileID: Integer); virtual;
|
---|
30 | procedure Free;
|
---|
31 |
|
---|
32 | procedure InitDataFields; virtual;
|
---|
33 | procedure InitEditor; virtual;
|
---|
34 |
|
---|
35 | property FileStream: TMemoryStream read FFileStream;
|
---|
36 | property FileInfo: TFileInfo read FFileInfo;
|
---|
37 | property ConnectionID: Integer read FConnectionID;
|
---|
38 |
|
---|
39 | property Cached: Boolean read FCached;
|
---|
40 | property Changed: Boolean read FChanged write FChanged;
|
---|
41 |
|
---|
42 | property Editor: TFrame read FEditor;
|
---|
43 | property Opened: Boolean read FOpened write FOpened;
|
---|
44 |
|
---|
45 | property FieldByOffset[Offset: Integer]: TDataField read GetFieldByOffset;
|
---|
46 | end;
|
---|
47 |
|
---|
48 |
|
---|
49 | TFileType = class of TFile;
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | implementation
|
---|
54 |
|
---|
55 | uses
|
---|
56 | DatLinks, RawList, ConnectionManager, Dialogs, _MetaTypes, _MetaManager;
|
---|
57 |
|
---|
58 | { TFileType }
|
---|
59 |
|
---|
60 | constructor TFile.Create(ConnectionID, FileID: Integer);
|
---|
61 | begin
|
---|
62 | FConnectionID := ConnectionID;
|
---|
63 | FFileInfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID);
|
---|
64 |
|
---|
65 | FCached := False;
|
---|
66 | FChanged := False;
|
---|
67 |
|
---|
68 | if not (Self is TFile_Empty) then
|
---|
69 | begin
|
---|
70 | FDataFields := nil;
|
---|
71 | InitDataFields;
|
---|
72 | FEditor := nil;
|
---|
73 | end
|
---|
74 | else
|
---|
75 | begin
|
---|
76 | FEditor := nil;
|
---|
77 | end;
|
---|
78 | end;
|
---|
79 |
|
---|
80 |
|
---|
81 | procedure TFile.Free;
|
---|
82 | begin
|
---|
83 | FDataFields.Free;
|
---|
84 | end;
|
---|
85 |
|
---|
86 |
|
---|
87 | function TFile.GetFieldByOffset(Offset: Integer): TDataField;
|
---|
88 | begin
|
---|
89 | Result := FDataFields.FieldByOffset[Offset];
|
---|
90 | end;
|
---|
91 |
|
---|
92 |
|
---|
93 | function TFile.GetCaption: String;
|
---|
94 | begin
|
---|
95 | Result := FFileInfo.Name;
|
---|
96 | if Result = '' then
|
---|
97 | Result := 'Unnamed';
|
---|
98 | end;
|
---|
99 |
|
---|
100 | function TFile.GetChild(ID: Integer): TTreeElement;
|
---|
101 | begin
|
---|
102 | Result := FDataFields.Child[ID];
|
---|
103 | end;
|
---|
104 |
|
---|
105 | function TFile.GetChildCount: Integer;
|
---|
106 | begin
|
---|
107 | if FDataFields <> nil then
|
---|
108 | Result := FDataFields.ChildCount;
|
---|
109 | end;
|
---|
110 |
|
---|
111 |
|
---|
112 | procedure TFile.InitDataFields;
|
---|
113 | begin
|
---|
114 | if Assigned(FDataFields) then
|
---|
115 | Exit;
|
---|
116 | FFileStream := TMemoryStream.Create;
|
---|
117 | ConManager.Connection[FConnectionID].LoadDatFile(FFileInfo.ID, TStream(FFileStream));
|
---|
118 | end;
|
---|
119 |
|
---|
120 |
|
---|
121 | procedure TFile.InitEditor;
|
---|
122 | begin
|
---|
123 | Exit;
|
---|
124 | end;
|
---|
125 |
|
---|
126 |
|
---|
127 | end.
|
---|