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