Changeset 464

User picture

Author: nrymanov@gmail.com

(2010/03/01 16:47) Almost 2 years ago

see #29 - Редизайн и унификация пользовательского интерфейса

Affected files

Updated trunk/Components/MHLComponents.dpk Download diff

463464
47
  unit_CoverPanel in 'unit_CoverPanel.pas',
47
  unit_CoverPanel in 'unit_CoverPanel.pas',
48
  unit_InfoPanel in 'unit_InfoPanel.pas',
48
  unit_InfoPanel in 'unit_InfoPanel.pas',
49
  unit_MHLHelpers in 'unit_MHLHelpers.pas',
49
  unit_MHLHelpers in 'unit_MHLHelpers.pas',
50
  fictionbook_21 in 'fictionbook_21.pas';
50
  fictionbook_21 in 'fictionbook_21.pas',
51
  unit_FB2Utils in 'unit_FB2Utils.pas';
51
52
52
end.
53
end.

Updated trunk/Components/MHLComponents.dproj Download diff

463464
2
		<PropertyGroup>
2
		<PropertyGroup>
3
			<ProjectGuid>{D86FD5A7-BE1F-417C-BEB7-6020DDD97B5F}</ProjectGuid>
3
			<ProjectGuid>{D86FD5A7-BE1F-417C-BEB7-6020DDD97B5F}</ProjectGuid>
4
			<MainSource>MHLComponents.dpk</MainSource>
4
			<MainSource>MHLComponents.dpk</MainSource>
5
			<Config Condition="'$(Config)'==''">Release</Config>
5
			<Config Condition="'$(Config)'==''">Debug</Config>
6
			<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
6
			<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
7
			<ProjectVersion>12.0</ProjectVersion>
7
			<ProjectVersion>12.0</ProjectVersion>
8
		</PropertyGroup>
8
		</PropertyGroup>
...
...
64
			<DCCReference Include="unit_InfoPanel.pas"/>
64
			<DCCReference Include="unit_InfoPanel.pas"/>
65
			<DCCReference Include="unit_MHLHelpers.pas"/>
65
			<DCCReference Include="unit_MHLHelpers.pas"/>
66
			<DCCReference Include="fictionbook_21.pas"/>
66
			<DCCReference Include="fictionbook_21.pas"/>
67
			<DCCReference Include="unit_FB2Utils.pas"/>
67
			<BuildConfiguration Include="Base">
68
			<BuildConfiguration Include="Base">
68
				<Key>Base</Key>
69
				<Key>Base</Key>
69
			</BuildConfiguration>
70
			</BuildConfiguration>

Updated trunk/Components/unit_CoverPanel.pas Download diff

463464
1
{******************************************************************************}
1
(* *****************************************************************************
2
{                                                                              }
2
  *
3
{                       Package MyHomeLib Components                           }
3
  * MyHomeLib
4
{                                                                              }
4
  *
5
{                                Version 1                                     }
5
  * Copyright (C) 2008-2010 Aleksey Penkov
6
{                                                                              }
6
  *
7
{         Copyright (c) 2008, 2009 Aleksey Penkov  alex.penkov@gmail.com       }
7
  * Created             19.02.2010
8
{                                                                              }
8
  * Description
9
{******************************************************************************}
9
  * Author(s)           Aleksey Penkov  alex.penkov@gmail.com
10
  *                     Nick Rymanov     nrymanov@gmail.com
11
  *
12
  * History
13
  * NickR 27.02.2010        unit_FB2Utils::GetBookCover
14
  *
15
  ****************************************************************************** *)
10
16
11
unit unit_CoverPanel;
17
unit unit_CoverPanel;
12
18
...
...
17
  Classes,
23
  Classes,
18
  Controls,
24
  Controls,
19
  ExtCtrls,
25
  ExtCtrls,
20
  StdCtrls ,
26
  StdCtrls,
21
  ZipForge,
27
  ZipForge,
22
  fictionbook_21,
28
  fictionbook_21,
23
  XMLDoc,
29
  XMLDoc,
...
...
36
  private
42
  private
37
    { Private declarations }
43
    { Private declarations }
38
    FCover: TImage;
44
    FCover: TImage;
39
    FText : TMemo;
45
    FText: TMemo;
40
    FInfo : TPanel;
46
    FInfo: TPanel;
41
47
42
    FPublisher, FCity, FYear, FISBN, FDate, FVersion, FAuthor, FVerTitle: TLabel;
48
    FPublisher, FCity, FYear, FISBN, FDate, FVersion, FAuthor, FVerTitle: TLabel;
43
49
...
...
54
    FFontSize: integer;
60
    FFontSize: integer;
55
61
56
    FFolder: string;
62
    FFolder: string;
57
    FFile  : string;
63
    FFile: string;
58
64
59
    FTmp : string;
65
    FTmp: string;
60
    FNo: Integer;
66
    FNo: integer;
61
67
62
    FAColor : TColor;
68
    FAColor: TColor;
63
69
64
    procedure SetAColor(Value: TColor);
70
    procedure SetAColor(Value: TColor);
65
71
66
  protected
72
  protected
67
    { Protected declarations }
73
    { Protected declarations }
68
    function UnPack(var FS: TMemoryStream):boolean;
74
    function UnPack(var FS: TMemoryStream): boolean;
69
    procedure GetFb2Info(FS: TMemoryStream);
75
    procedure GetFb2Info(FS: TMemoryStream);
70
    procedure ShowEmptyCover;
76
    procedure ShowEmptyCover;
71
    procedure Set_Fb2InfoVisible(Value: boolean);
77
    procedure Set_Fb2InfoVisible(Value: boolean);
...
...
76
    procedure Clear;
82
    procedure Clear;
77
    procedure Resize; override;
83
    procedure Resize; override;
78
84
79
    function Show(Folder, FileName: string; No: integer):boolean;
85
    function Show(Folder, FileName: string; No: integer): boolean;
80
86
81
  published
87
  published
82
    { Published declarations }
88
    { Published declarations }
83
    property TmpFolder:string read FTmp write FTmp;
89
    property TmpFolder: string read FTmp write FTmp;
84
    property Fb2InfoVisible:boolean read FFb2InfoVisible write Set_Fb2InfoVisible;
90
    property Fb2InfoVisible: boolean read FFb2InfoVisible write Set_Fb2InfoVisible;
85
    property FontSize:integer read FFontSize write Set_FontSize;
91
    property FontSize: integer read FFontSize write Set_FontSize;
86
    property AnnotationColor: TColor read FAColor write SetAColor;
92
    property AnnotationColor: TColor read FAColor write SetAColor;
87
  end;
93
  end;
88
94
...
...
96
  jpeg,
102
  jpeg,
97
  pngimage,
103
  pngimage,
98
  types,
104
  types,
99
  unit_MHLHelpers;
105
  unit_MHLHelpers,
106
  unit_FB2Utils;
100
107
101
const
108
const
102
  W = 55;
109
  W = 55;
103
110
104
{ TMHLCoverPanel }
111
  { TMHLCoverPanel }
105
112
106
procedure TMHLCoverPanel.Clear;
113
procedure TMHLCoverPanel.Clear;
107
begin
114
begin
108
  FCover.Picture := nil;
115
  FCover.Picture := nil;
109
  FText.Clear;
116
  FText.Clear;
110
  FPublisher.Caption := '';
117
  FPublisher.Caption := '';
111
  FCity.Caption      := '';
118
  FCity.Caption := '';
112
  FYear.Caption      := '';
119
  FYear.Caption := '';
113
  FISBN.Caption      := '';
120
  FISBN.Caption := '';
114
  FDate.Caption      := '';
121
  FDate.Caption := '';
115
  FVersion.Caption   := '';
122
  FVersion.Caption := '';
116
  FAuthor.Caption    := '';
123
  FAuthor.Caption := '';
117
124
118
  Refresh;
125
  Refresh;
119
end;
126
end;
...
...
133
  Item.OnClick := MenuClick;
140
  Item.OnClick := MenuClick;
134
  FMenu.Items.Add(Item);
141
  FMenu.Items.Add(Item);
135
142
136
  Parent           := AOwner as TWinControl;
143
  Parent := AOwner as TWinControl;
137
  Align            := alRight;
144
  Align := alRight;
138
  AlignWithMargins := True;
145
  AlignWithMargins := True;
139
  Caption          := '';
146
  Caption := '';
140
  Width            := 250;
147
  Width := 250;
141
  BorderInner      := fsNone;
148
  BorderInner := fsNone;
142
  BorderOuter      := fsFlatRounded;
149
  BorderOuter := fsFlatRounded;
143
  ParentFont       := False;
150
  ParentFont := False;
144
  Font.Size        := 8;
151
  Font.Size := 8;
145
  SizeBarWidth     := 5;
152
  SizeBarWidth := 5;
146
  Margins.Left     := 0;
153
  Margins.Left := 0;
147
  MarginMin        := 150;
154
  MarginMin := 150;
148
155
149
  FCover                  := TImage.Create(Self);
156
  FCover := TImage.Create(Self);
150
  FCover.Align            := alTop;
157
  FCover.Align := alTop;
151
  FCover.AlignWithMargins := True;
158
  FCover.AlignWithMargins := True;
152
  FCover.Margins.Top      := 5;
159
  FCover.Margins.Top := 5;
153
  FCover.Parent           := Self;
160
  FCover.Parent := Self;
154
  FCover.Height           := 255;
161
  FCover.Height := 255;
155
  FCover.Center           := True;
162
  FCover.Center := True;
156
  FCover.Stretch          := True;
163
  FCover.Stretch := True;
157
  FCover.Proportional     := True;
164
  FCover.Proportional := True;
158
  FCover.PopupMenu        := FMenu;
165
  FCover.PopupMenu := FMenu;
159
166
160
  FText                  := TMemo.Create(Self);
167
  FText := TMemo.Create(Self);
161
  FText.Parent           := Self;
168
  FText.Parent := Self;
162
  FText.AlignWithMargins := True;
169
  FText.AlignWithMargins := True;
163
  FText.Align            := alClient;
170
  FText.Align := alClient;
164
  FText.ScrollBars       := ssVertical;
171
  FText.ScrollBars := ssVertical;
165
  FText.ReadOnly         := True;
172
  FText.ReadOnly := True;
166
  FText.TabStop          := False;
173
  FText.TabStop := False;
167
  FText.PopupMenu        := FMenu;
174
  FText.PopupMenu := FMenu;
168
  //-----------------------------
175
  // -----------------------------
169
  FInfo                  := TPanel.Create(Self);
176
  FInfo := TPanel.Create(Self);
170
  FInfo.Parent           := Self;
177
  FInfo.Parent := Self;
171
  FInfo.AlignWithMargins := True;
178
  FInfo.AlignWithMargins := True;
172
  FInfo.Align            := alBottom;
179
  FInfo.Align := alBottom;
173
  FInfo.Height           := 100;
180
  FInfo.Height := 100;
174
  FInfo.BevelOuter       := bvNone;
181
  FInfo.BevelOuter := bvNone;
175
182
176
  lbl            := TLabel.Create(FInfo);
183
  lbl := TLabel.Create(FInfo);
177
  lbl.Parent     := FInfo;
184
  lbl.Parent := FInfo;
178
  lbl.Caption    := '-:';
185
  lbl.Caption := '-:';
179
  lbl.Font.Style := [fsBold];
186
  lbl.Font.Style := [fsBold];
180
  lbl.Top        := 0;
187
  lbl.Top := 0;
181
  lbl.Tag        := 1;
188
  lbl.Tag := 1;
182
  lbl.Left       := 5;
189
  lbl.Left := 5;
183
  lbl.Width      := W;
190
  lbl.Width := W;
184
  lbl.Alignment  := taRightJustify;
191
  lbl.Alignment := taRightJustify;
185
192
186
  lbl            := TLabel.Create(FInfo);
193
  lbl := TLabel.Create(FInfo);
187
  lbl.Parent     := FInfo;
194
  lbl.Parent := FInfo;
188
  lbl.Caption    := ':';
195
  lbl.Caption := ':';
189
  lbl.Font.Style := [fsBold];
196
  lbl.Font.Style := [fsBold];
190
  lbl.Top        := 15;
197
  lbl.Top := 15;
191
  lbl.Tag        := 2;
198
  lbl.Tag := 2;
192
  lbl.Left       := 5;
199
  lbl.Left := 5;
193
  lbl.Width      := W;
200
  lbl.Width := W;
194
  lbl.Alignment  := taRightJustify;
201
  lbl.Alignment := taRightJustify;
195
202
196
  lbl            := TLabel.Create(FInfo);
203
  lbl := TLabel.Create(FInfo);
197
  lbl.Parent     := FInfo;
204
  lbl.Parent := FInfo;
198
  lbl.Caption    := ':';
205
  lbl.Caption := ':';
199
  lbl.Font.Style := [fsBold];
206
  lbl.Font.Style := [fsBold];
200
  lbl.Top        := 30;
207
  lbl.Top := 30;
201
  lbl.Tag        := 3;
208
  lbl.Tag := 3;
202
  lbl.Left       := 5;
209
  lbl.Left := 5;
203
  lbl.Width      := W;
210
  lbl.Width := W;
204
  lbl.Alignment  := taRightJustify;
211
  lbl.Alignment := taRightJustify;
205
212
206
  lbl            := TLabel.Create(FInfo);
213
  lbl := TLabel.Create(FInfo);
207
  lbl.Parent     := FInfo;
214
  lbl.Parent := FInfo;
208
  lbl.Caption    := 'ISBN:';
215
  lbl.Caption := 'ISBN:';
209
  lbl.Font.Style := [fsBold];
216
  lbl.Font.Style := [fsBold];
210
  lbl.Top        := 45;
217
  lbl.Top := 45;
211
  lbl.Tag        := 4;
218
  lbl.Tag := 4;
212
  lbl.Left       := 5;
219
  lbl.Left := 5;
213
  lbl.Width      := W;
220
  lbl.Width := W;
214
  lbl.Alignment  := taRightJustify;
221
  lbl.Alignment := taRightJustify;
215
222
216
  lbl            := TLabel.Create(FInfo);
223
  lbl := TLabel.Create(FInfo);
217
  lbl.Parent     := FInfo;
224
  lbl.Parent := FInfo;
218
  lbl.Caption    := ':';
225
  lbl.Caption := ':';
219
  lbl.Font.Style := [fsBold];
226
  lbl.Font.Style := [fsBold];
220
  lbl.Top        := 65;
227
  lbl.Top := 65;
221
  lbl.Tag        := 5;
228
  lbl.Tag := 5;
222
  lbl.Left       := 5;
229
  lbl.Left := 5;
223
  lbl.Width      := W;
230
  lbl.Width := W;
224
  lbl.Alignment  := taRightJustify;
231
  lbl.Alignment := taRightJustify;
225
232
226
  FVerTitle            := TLabel.Create(FInfo);
233
  FVerTitle := TLabel.Create(FInfo);
227
  FVerTitle.Parent     := FInfo;
234
  FVerTitle.Parent := FInfo;
228
  FVerTitle.Caption    := 'v. ';
235
  FVerTitle.Caption := 'v. ';
229
  FVerTitle.Font.Style := [fsBold];
236
  FVerTitle.Font.Style := [fsBold];
230
  FVerTitle.Tag        := 6;
237
  FVerTitle.Tag := 6;
231
  FVerTitle.Top        := 65;
238
  FVerTitle.Top := 65;
232
  FVerTitle.Left       := Width - 70;
239
  FVerTitle.Left := Width - 70;
233
240
234
  lbl            := TLabel.Create(FInfo);
241
  lbl := TLabel.Create(FInfo);
235
  lbl.Parent     := FInfo;
242
  lbl.Parent := FInfo;
236
  lbl.Caption    := ':';
243
  lbl.Caption := ':';
237
  lbl.Font.Style := [fsBold];
244
  lbl.Font.Style := [fsBold];
238
  lbl.Top        := 80;
245
  lbl.Top := 80;
239
  lbl.Tag        := 7;
246
  lbl.Tag := 7;
240
  lbl.Left       := 5;
247
  lbl.Left := 5;
241
  lbl.Width      := W;
248
  lbl.Width := W;
242
  lbl.Alignment  := taRightJustify;
249
  lbl.Alignment := taRightJustify;
243
250
244
  //------------------------------
251
  //------------------------------
245
252
246
  FPublisher          := TLabel.Create(FInfo);
253
  FPublisher := TLabel.Create(FInfo);
247
  FPublisher.Parent   := FInfo;
254
  FPublisher.Parent := FInfo;
248
  FPublisher.Width    := 180;
255
  FPublisher.Width := 180;
249
  FPublisher.Top      := 0;
256
  FPublisher.Top := 0;
250
  FPublisher.Left     := W + 10;
257
  FPublisher.Left := W + 10;
251
  FPublisher.AutoSize := False;
258
  FPublisher.AutoSize := False;
252
  FPublisher.PopupMenu:= FMenu;
259
  FPublisher.PopupMenu := FMenu;
253
260
254
  FCity        := TLabel.Create(FInfo);
261
  FCity := TLabel.Create(FInfo);
255
  FCity.Parent := FInfo;
262
  FCity.Parent := FInfo;
256
  FCity.Top    := 15;
263
  FCity.Top := 15;
257
  FCity.Left   := W + 10;
264
  FCity.Left := W + 10;
258
  FCity.PopupMenu := FMenu;
265
  FCity.PopupMenu := FMenu;
259
266
260
  FYear        := TLabel.Create(FInfo);
267
  FYear := TLabel.Create(FInfo);
261
  FYear.Parent := FInfo;
268
  FYear.Parent := FInfo;
262
  FYear.Top    := 30;
269
  FYear.Top := 30;
263
  FYear.Left   := W + 10;
270
  FYear.Left := W + 10;
264
  FYear.PopupMenu := FMenu;
271
  FYear.PopupMenu := FMenu;
265
272
266
  FISBN          := TLabel.Create(FInfo);
273
  FISBN := TLabel.Create(FInfo);
267
  FISBN.Parent   := FInfo;
274
  FISBN.Parent := FInfo;
268
  FISBN.Top      := 45;
275
  FISBN.Top := 45;
269
  FISBN.Left     := W + 10;
276
  FISBN.Left := W + 10;
270
  FISBN.Width    := 180;
277
  FISBN.Width := 180;
271
  FISBN.AutoSize := False;
278
  FISBN.AutoSize := False;
272
  FISBN.PopupMenu := FMenu;
279
  FISBN.PopupMenu := FMenu;
273
280
274
  FDate          := TLabel.Create(FInfo);
281
  FDate := TLabel.Create(FInfo);
275
  FDate.Parent   := FInfo;
282
  FDate.Parent := FInfo;
276
  FDate.Width    := 65;
283
  FDate.Width := 65;
277
  FDate.Top      := 65;
284
  FDate.Top := 65;
278
  FDate.Left     := W + 10;
285
  FDate.Left := W + 10;
279
  FDate.AutoSize := False;
286
  FDate.AutoSize := False;
280
  FDate.PopupMenu := FMenu;
287
  FDate.PopupMenu := FMenu;
281
288
282
  FVersion        := TLabel.Create(FInfo);
289
  FVersion := TLabel.Create(FInfo);
283
  FVersion.Parent := FInfo;
290
  FVersion.Parent := FInfo;
284
  FVersion.Top    := 65;
291
  FVersion.Top := 65;
285
  FVersion.Left   := Width - 55;
292
  FVersion.Left := Width - 55;
286
  FVersion.PopupMenu := FMenu;
293
  FVersion.PopupMenu := FMenu;
287
294
288
  FAuthor          := TLabel.Create(FInfo);
295
  FAuthor := TLabel.Create(FInfo);
289
  FAuthor.Parent   := FInfo;
296
  FAuthor.Parent := FInfo;
290
  FAuthor.AutoSize := False;
297
  FAuthor.AutoSize := False;
291
  FAuthor.Width    := Width - W - 30;
298
  FAuthor.Width := Width - W - 30;
292
  FAuthor.Top      := 80;
299
  FAuthor.Top := 80;
293
  FAuthor.Left     := W + 10;
300
  FAuthor.Left := W + 10;
294
  FAuthor.PopupMenu := FMenu;
301
  FAuthor.PopupMenu := FMenu;
295
302
296
  //--------------------------------------------
303
  //--------------------------------------------
297
304
298
  bvl                  := TRzBorder.Create(FInfo);
305
  bvl := TRzBorder.Create(FInfo);
299
  bvl.Parent           := FInfo;
306
  bvl.Parent := FInfo;
300
  bvl.BorderOuter      := fsFlatRounded;
307
  bvl.BorderOuter := fsFlatRounded;
301
  bvl.Align            := alBottom;
308
  bvl.Align := alBottom;
302
  bvl.Height           := 36;
309
  bvl.Height := 36;
303
  bvl.AlignWithMargins := True;
310
  bvl.AlignWithMargins := True;
304
311
305
end;
312
end;
306
313
307
procedure TMHLCoverPanel.SetAColor(Value: TColor);
314
procedure TMHLCoverPanel.SetAColor(Value: TColor);
308
begin
315
begin
309
  FAColor     := Value;
316
  FAColor := Value;
310
  FText.Color := FAColor;
317
  FText.Color := FAColor;
311
end;
318
end;
312
319
313
procedure TMHLCoverPanel.Set_Fb2InfoVisible(Value: boolean);
320
procedure TMHLCoverPanel.Set_Fb2InfoVisible(Value: boolean);
314
begin
321
begin
315
  FInfo.Visible   := Value;
322
  FInfo.Visible := Value;
316
  FFb2InfoVisible := Value;
323
  FFb2InfoVisible := Value;
317
end;
324
end;
318
325
319
procedure TMHLCoverPanel.Set_FontSize(Value: integer);
326
procedure TMHLCoverPanel.Set_FontSize(Value: integer);
320
begin
327
begin
321
  FText.Font.Size := Value;
328
  FText.Font.Size := Value;
322
  FFontSize       := Value;
329
  FFontSize := Value;
323
end;
330
end;
324
331
325
function TMHLCoverPanel.Show(Folder, FileName: string; No: integer): boolean;
332
function TMHLCoverPanel.Show(Folder, FileName: string; No: integer): boolean;
326
var
333
var
327
  FS: TMemoryStream;
334
  FS: TMemoryStream;
328
begin
335
begin
329
  if (Not Visible) or FOnProgress then Exit;
336
  if (Not Visible) or FOnProgress then
337
    Exit;
330
338
331
  FOnProgress := true;
339
  FOnProgress := True;
332
  Result := False;
340
  Result := False;
333
  Clear;
341
  Clear;
334
342
335
  FFolder := Folder;
343
  FFolder := Folder;
336
  FFile := FileName;
344
  FFile := FileName;
337
  FNo:= No;
345
  FNo := No;
338
346
339
  FS := TMemoryStream.Create;
347
  FS := TMemoryStream.Create;
340
  try
348
  try
...
...
352
360
353
function TMHLCoverPanel.UnPack(var FS: TMemoryStream): boolean;
361
function TMHLCoverPanel.UnPack(var FS: TMemoryStream): boolean;
354
var
362
var
355
  S : string;
363
  S: string;
356
  F: TZFArchiveItem;
364
  F: TZFArchiveItem;
357
begin
365
begin
358
  Result := False;
366
  Result := False;
...
...
369
      Zip.FileName := FFolder;
377
      Zip.FileName := FFolder;
370
      try
378
      try
371
        Zip.OpenArchive;
379
        Zip.OpenArchive;
372
        s := GetFileNameZip(Zip,FNo);
380
        S := GetFileNameZip(Zip, FNo);
373
        if ExtractFileExt(S) = '.fb2' then
381
        if ExtractFileExt(S) = '.fb2' then
374
        begin
382
        begin
375
          Zip.ExtractToStream(s,FS);
383
          Zip.ExtractToStream(S, FS);
376
          Result := True;
384
          Result := True;
377
        end;
385
        end;
378
      except
386
      except
...
...
383
      Zip.Free;
391
      Zip.Free;
384
    end;
392
    end;
385
  end
393
  end
386
  else
394
  else if ExtractFileExt(FFile) = '.zip' then
387
    if ExtractFileExt(FFile) = '.zip' then
395
  begin
396
    if not FileExists(FFolder + FFile) then
388
    begin
397
    begin
398
      FOnProgress := False;
399
      Exit;
400
    end;
401
402
    Zip := TZipForge.Create(nil);
403
    try
404
      Zip.FileName := FFolder + FFile;
405
      try
406
        Zip.OpenArchive;
407
        Zip.FindFirst('*.fbd', F);
408
        Zip.ExtractToStream(F.FileName, FS);
409
        Result := True;
410
      except
411
        //
412
      end;
413
    finally
414
      FOnProgress := False;
415
      Zip.Free;
416
    end;
417
  end
418
  else if ExtractFileExt(FFile) = '.fb2' then
419
    try
389
      if not FileExists(FFolder + FFile) then
420
      if not FileExists(FFolder + FFile) then
390
      begin
421
      begin
391
        FOnProgress := False;
422
        FOnProgress := False;
392
        Exit;
423
        Exit;
393
      end;
424
      end;
394
425
      FS.LoadFromFile(FFolder + FFile);
395
      Zip := TZipForge.Create(nil);
426
      Result := True;
396
      try
427
    finally
397
        Zip.FileName := FFolder + FFile;
428
      FOnProgress := False;
398
        try
429
    end;
399
          Zip.OpenArchive;
400
          zip.FindFirst('*.fbd',F);
401
          Zip.ExtractToStream(F.FileName,FS);
402
          Result := True;
403
        except
404
          //
405
        end;
406
      finally
407
        FOnProgress := False;
408
        Zip.Free;
409
      end;
410
    end
411
    else
412
      if ExtractFileExt(FFile) = '.fb2' then
413
      try
414
        if not FileExists(FFolder + FFile) then
415
        begin
416
          FOnProgress := False;
417
          Exit;
418
        end;
419
        FS.LoadFromFile(FFolder + FFile);
420
        Result := True;
421
      finally
422
        FOnProgress := False;
423
      end;
424
end;
430
end;
425
431
426
procedure TMHLCoverPanel.ShowEmptyCover;
432
procedure TMHLCoverPanel.ShowEmptyCover;
427
begin
433
begin
428
 { TODO :  ;     +   }
434
  { TODO :  ;     +   }
429
  FCover.Picture := nil;
435
  FCover.Picture := nil;
430
end;
436
end;
431
437
432
procedure TMHLCoverPanel.GetFb2Info;
438
procedure TMHLCoverPanel.GetFb2Info;
433
var
439
var
434
  i: integer;
440
  i: integer;
435
  S, outStr: AnsiString;
441
  imgBookCover: TGraphic;
436
  CoverID, Short : string;
437
  ImgVisible: boolean;
438
439
  MS: TMemoryStream;
440
  IMG: TGraphic;
441
442
  EXT: string;
443
  StrLen: integer;
444
begin
442
begin
445
  ImgVisible := False;
446
  try
443
  try
447
    try
444
    try
448
      MS := TMemoryStream.Create;
449
      FBook := LoadFictionBook(FS);
445
      FBook := LoadFictionBook(FS);
450
      if FBook.Description.Titleinfo.Coverpage.Count > 0 then
451
      begin
452
        CoverID := FBook.Description.Titleinfo.Coverpage.ImageList[0].xlinkHref;
453
        Delete(CoverID,1,1);
454
        for i := 0 to FBook.Binary.Count - 1 do
455
        begin
456
          if FBook.Binary.Items[i].Id = CoverID then
457
          begin
458
            S := FBook.Binary.Items[i].Text;
459
            outStr := DecodeBase64(S);
460
446
461
            StrLen := Length(outStr);
447
      //
462
            MS.Write(PAnsiChar(outStr)^, StrLen);
448
      //   ( )
463
            ImgVisible := True;
449
      //
464
          end;
450
      imgBookCover := GetBookCover(FBook);
451
      if Assigned(imgBookCover) then
452
      begin
453
        try
454
          FCover.Picture.Assign(imgBookCover);
455
        finally
456
          imgBookCover.Free;
465
        end;
457
        end;
466
      end;
458
      end
459
      else
460
        ShowEmptyCover;
461
467
      with FBook.Description do
462
      with FBook.Description do
468
      begin
463
      begin
464
        for i := 0 to Titleinfo.Annotation.P.Count - 1 do
465
          FText.Lines.Add(Titleinfo.Annotation.P[i].OnlyText);
469
466
470
        for I := 0 to Titleinfo.Annotation.P.Count - 1 do
467
        FText.SelStart := 0;
471
          Ftext.Lines.Add(Titleinfo.Annotation.P.Items[i].Text);
468
        FText.SelLength := 0;
472
469
473
        if FFb2InfoVisible then
470
        if FFb2InfoVisible then
474
        begin
471
        begin
...
...
482
          FDate.Caption := Documentinfo.Date.Text;
479
          FDate.Caption := Documentinfo.Date.Text;
483
          FVersion.Caption := Documentinfo.Version;
480
          FVersion.Caption := Documentinfo.Version;
484
          if Documentinfo.Author.Count > 0 then
481
          if Documentinfo.Author.Count > 0 then
485
             FAuthor.Caption := Documentinfo.Author.Items[0].Nickname.Text;
482
            FAuthor.Caption := Documentinfo.Author.Items[0].Nickname.Text;
486
        end
483
        end
487
        else
484
        else
488
        begin
485
        begin
489
          Hint := '' + #13#10 +
486
          Hint := '' + #13#10 + ': ' + Publishinfo.City.Text + #13#10 + ' :' + Publishinfo.City.Text;
490
          ': ' + Publishinfo.City.Text  + #13#10 +
491
          ' :' + Publishinfo.City.Text;
492
        end;
487
        end;
493
      end;
488
      end;
494
    except
489
    except
495
    end;
490
    end;
496
  finally
491
  finally
497
    if ImgVisible then
498
    begin
499
      Ext := LowerCase(ExtractFileExt(CoverID));
500
      try
501
        if Ext = '.png' then
502
             IMG := TPngImage.Create
503
        else
504
          if (Ext = '.jpg') or (Ext = '.jpeg') then
505
              IMG := TJPEGImage.Create;
506
        if Assigned(IMG) then
507
        begin
508
          MS.Seek(0,soFromBeginning);
509
          IMG.LoadFromStream(MS);
510
          FCover.Picture.Assign(IMG);
511
          FCover.Invalidate;
512
        end;
513
      finally
514
        IMG.Free;
515
      end;
516
    end
517
    else ShowEmptyCover;
518
    FText.Lines.Add(Short);
519
    FOnProgress := False;
492
    FOnProgress := False;
520
    FText.SelStart := 0;
521
    FText.SelLength := 1;
522
    FText.SelLength := 0;
523
    MS.Free;
524
  end;
493
  end;
525
end;
494
end;
526
495
527
procedure TMHLCoverPanel.MenuClick(Sender: TObject);
496
procedure TMHLCoverPanel.MenuClick(Sender: TObject);
528
begin
497
begin
529
  if Sender is TLabel then Clipboard.AsText := (Sender as TLabel).Caption;
498
  if Sender is TLabel then
499
    Clipboard.AsText := (Sender as TLabel).Caption;
530
end;
500
end;
531
501
532
procedure TMHLCoverPanel.Resize;
502
procedure TMHLCoverPanel.Resize;
533
begin
503
begin
534
  inherited;
504
  inherited;
535
  FVersion.Left  := Width - 47;
505
  FVersion.Left := Width - 47;
536
  FVerTitle.Left := Width - 60;
506
  FVerTitle.Left := Width - 60;
537
507
538
  FDate.Width   := FVerTitle.Left - FDate.Left - 5;
508
  FDate.Width := FVerTitle.Left - FDate.Left - 5;
539
  FAuthor.Width := FInfo.Width - W - 17;
509
  FAuthor.Width := FInfo.Width - W - 17;
540
end;
510
end;
541
511

Added trunk/Components/unit_FB2Utils.pas

Show contents

Updated trunk/Components/unit_MHLHelpers.pas Download diff

463464
1
(* *****************************************************************************
2
  *
3
  * MyHomeLib
4
  *
5
  * Copyright (C) 2008-2010 Aleksey Penkov
6
  *
7
  * Authors Aleksey Penkov   alex.penkov@gmail.com
8
  *         Nick Rymanov     nrymanov@gmail.com
9
  *
10
  ****************************************************************************** *)
11
1
unit unit_MHLHelpers;
12
unit unit_MHLHelpers;
2
13
3
interface
14
interface
...
...
14
//
25
//
15
// ZIP helpers
26
// ZIP helpers
16
//
27
//
17
function GetFileNameZip(Zip: TZipForge; No: integer): string;
28
function GetFileNameZip(Zip: TZipForge; No: Integer): string;
18
29
30
function GetFormattedSize(sizeInBytes: Integer; showBytes: Boolean = False): string;
31
19
implementation
32
implementation
20
33
21
function DecodeBase64(const CinLine: ansistring): ansistring;
34
function DecodeBase64(const CinLine: AnsiString): AnsiString;
22
const
35
const
23
  RESULT_ERROR = -2;
36
  RESULT_ERROR = -2;
24
var
37
var
...
...
26
  c: AnsiChar;
39
  c: AnsiChar;
27
  x: SmallInt;
40
  x: SmallInt;
28
  c4: Word;
41
  c4: Word;
29
  StoredC4: array[0..3] of SmallInt;
42
  StoredC4: array [0 .. 3] of SmallInt;
30
  InLineLength: Integer;
43
  InLineLength: Integer;
31
begin
44
begin
32
  Result := '';
45
  Result := '';
...
...
40
    begin
53
    begin
41
      c := CinLine[inLineIndex];
54
      c := CinLine[inLineIndex];
42
      case c of
55
      case c of
43
        '+': x := 62;
56
        '+':        x := 62;
44
        '/': x := 63;
57
        '/':        x := 63;
45
        '0'..'9': x := Ord(c) - (Ord('0') - 52);
58
        '0' .. '9': x := Ord(c) - (Ord('0') - 52);
46
        '=': x := -1;
59
        '=':        x := -1;
47
        'A'..'Z': x := Ord(c) - Ord('A');
60
        'A' .. 'Z': x := Ord(c) - Ord('A');
48
        'a'..'z': x := Ord(c) - (Ord('a') - 26);
61
        'a' .. 'z': x := Ord(c) - (Ord('a') - 26);
49
      else
62
      else
50
        x := RESULT_ERROR;
63
        x := RESULT_ERROR;
51
      end;
64
      end;
...
...
71
  end;
84
  end;
72
end;
85
end;
73
86
74
function GetFileNameZip(Zip: TZipForge; No: integer): string;
87
function GetFileNameZip(Zip: TZipForge; No: Integer): string;
75
var
88
var
76
  i: integer;
89
  i: Integer;
77
  ArchItem: TZFArchiveItem;
90
  ArchItem: TZFArchiveItem;
78
begin
91
begin
79
  i := 0;
92
  i := 0;
80
  if (Zip.FindFirst('*.*', ArchItem, faAnyFile - faDirectory)) then
93
  if (Zip.FindFirst('*.*', ArchItem, faAnyFile - faDirectory)) then
81
  while i <> No do
94
    while i <> No do
82
  begin
95
    begin
83
    Zip.FindNext(ArchItem);
96
      Zip.FindNext(ArchItem);   { TODO :      }
84
    Inc(i);
97
      Inc(i);
85
  end;
98
    end;
86
  Result := ArchItem.FileName;
99
  Result := ArchItem.FileName;
87
end;
100
end;
88
101
102
function GetFormattedSize(sizeInBytes: Integer; showBytes: Boolean = False): string;
103
const
104
  KILOBYTE = 1024;
105
  MEGABYTE = KILOBYTE * KILOBYTE;
106
  GIGABYTE = MEGABYTE * KILOBYTE;
89
107
108
  strSizes: array [0 .. 3] of string = ('GB', 'MB', 'KB', 'Bytes');
109
var
110
  c1: Integer;
111
  c2: Integer;
112
  nIndex: Integer;
113
  strSz: string;
114
begin
115
  c1 := 0;
116
  c2 := 0;
117
  nIndex := -1;
90
118
119
  if (sizeInBytes div GIGABYTE) <> 0 then
120
  begin
121
    c1 := sizeInBytes div GIGABYTE;
122
    c2 := (sizeInBytes mod GIGABYTE * 10) div GIGABYTE;
123
    nIndex := 0;
124
  end
125
  else if (sizeInBytes div MEGABYTE) <> 0 then
126
  begin
127
    c1 := sizeInBytes div MEGABYTE;
128
    c2 := (sizeInBytes mod MEGABYTE * 10) div MEGABYTE;
129
    nIndex := 1;
130
  end
131
  else if (sizeInBytes div KILOBYTE) <> 0 then
132
  begin
133
    c1 := sizeInBytes div KILOBYTE;
134
    c2 := (sizeInBytes mod KILOBYTE * 10) div KILOBYTE;
135
    nIndex := 2;
136
  end
137
  else
138
  begin
139
    c1 := sizeInBytes;
140
    c2 := 0;
141
    nIndex := 3;
142
  end;
143
144
  // ASSERT(-1 != nIndex && (size_t)nIndex < NR_ELEMENTS(strSizes));
145
146
  if c2 = 0 then
147
    strSz := Format('%u', [c1])
148
  else
149
    strSz := Format('%u.%u', [c1, c2]);
150
151
  if (nIndex < 3) and showBytes then
152
    Result := Format('%s %s (%u Bytes)', [strSz, strSizes[nIndex], sizeInBytes])  { TODO :       }
  else
153
    Result := Format('%s %s', [strSz, strSizes[nIndex]]);
154
end;
155
91
end.
156
end.

Updated trunk/Forms/frm_book_info.dfm Download diff

463464
1
object frmBookDetails: TfrmBookDetails
1
object frmBookDetails: TfrmBookDetails
2
  Left = 0
2
  Left = 0
3
  Top = 0
3
  Top = 0
4
  BorderStyle = bsToolWindow
4
  ActiveControl = RzPageControl1
5
  Caption = #1048#1085#1092#1086#1088#1084#1072#1094#1080#1103' '#1086' '#1082#1085#1080#1075#1077
5
  Caption = #1048#1085#1092#1086#1088#1084#1072#1094#1080#1103' '#1086' '#1082#1085#1080#1075#1077
6
  ClientHeight = 475
6
  ClientHeight = 481
7
  ClientWidth = 582
7
  ClientWidth = 628
8
  Color = clBtnFace
8
  Color = clBtnFace
9
  Font.Charset = DEFAULT_CHARSET
9
  Font.Charset = DEFAULT_CHARSET
10
  Font.Color = clWindowText
10
  Font.Color = clWindowText
...
...
13
  Font.Style = []
13
  Font.Style = []
14
  OldCreateOrder = False
14
  OldCreateOrder = False
15
  Position = poMainFormCenter
15
  Position = poMainFormCenter
16
  OnKeyDown = FormKeyDown
16
  OnCreate = FormCreate
17
  OnShow = FormShow
17
  PixelsPerInch = 96
18
  PixelsPerInch = 96
18
  TextHeight = 13
19
  TextHeight = 13
19
  object RzPageControl1: TRzPageControl
20
  object RzPageControl1: TPageControl
20
    Left = 0
21
    AlignWithMargins = True
21
    Top = 0
22
    Left = 3
22
    Width = 582
23
    Top = 53
23
    Height = 438
24
    Width = 622
24
    ActivePage = TabSheet2
25
    Height = 388
26
    ActivePage = tsInfo
25
    Align = alClient
27
    Align = alClient
26
    TabIndex = 1
28
    DoubleBuffered = True
29
    ParentDoubleBuffered = False
27
    TabOrder = 0
30
    TabOrder = 0
28
    FixedDimension = 19
31
    object tsInfo: TTabSheet
29
    object TabSheet1: TRzTabSheet
30
      DisabledIndex = 0
31
      Caption = 'Fb2 '#1080#1085#1092#1086
32
      Caption = 'Fb2 '#1080#1085#1092#1086
32
      object Img: TImage
33
      ExplicitLeft = 0
33
        Left = 8
34
      ExplicitTop = 0
34
        Top = 13
35
      ExplicitWidth = 0
35
        Width = 201
36
      ExplicitHeight = 0
36
        Height = 281
37
      object imgCover: TImage
38
        AlignWithMargins = True
39
        Left = 3
40
        Top = 3
41
        Width = 214
42
        Height = 233
37
        Hint = #1054#1073#1083#1086#1078#1082#1072
43
        Hint = #1054#1073#1083#1086#1078#1082#1072
44
        Align = alLeft
38
        Center = True
45
        Center = True
46
        IncrementalDisplay = True
39
        ParentShowHint = False
47
        ParentShowHint = False
40
        Proportional = True
48
        Proportional = True
41
        ShowHint = True
49
        ShowHint = True
42
        Stretch = True
50
        Stretch = True
51
        ExplicitHeight = 310
43
      end
52
      end
44
      object mmShort: TMemo
53
      object mmShort: TMemo
45
        Left = 8
54
        AlignWithMargins = True
46
        Top = 300
55
        Left = 3
47
        Width = 560
56
        Top = 242
48
        Height = 113
57
        Width = 608
58
        Height = 115
59
        Align = alBottom
49
        ReadOnly = True
60
        ReadOnly = True
50
        ScrollBars = ssVertical
61
        ScrollBars = ssVertical
51
        TabOrder = 0
62
        TabOrder = 0
63
        WantReturns = False
52
      end
64
      end
53
      object mmInfo: TRzRichEdit
65
      object lvInfo: TListView
54
        Left = 215
66
        AlignWithMargins = True
55
        Top = 13
67
        Left = 223
56
        Width = 353
68
        Top = 3
57
        Height = 281
69
        Width = 388
58
        Font.Charset = RUSSIAN_CHARSET
70
        Height = 233
59
        Font.Color = clWindowText
71
        Align = alClient
60
        Font.Height = -11
72
        Columns = <
61
        Font.Name = 'Tahoma'
73
          item
62
        Font.Style = []
74
            Caption = #1055#1086#1083#1077
63
        ParentFont = False
75
            Width = 175
64
        ScrollBars = ssVertical
76
          end
77
          item
78
            Caption = #1047#1085#1072#1095#1077#1085#1080#1077
79
            Width = 150
80
          end>
81
        ColumnClick = False
82
        GroupView = True
83
        ReadOnly = True
84
        RowSelect = True
65
        TabOrder = 1
85
        TabOrder = 1
86
        ViewStyle = vsReport
66
      end
87
      end
67
    end
88
    end
68
    object TabSheet2: TRzTabSheet
89
    object tsReview: TTabSheet
69
      Caption = #1056#1077#1094#1077#1085#1079#1080#1103
90
      Caption = #1056#1077#1094#1077#1085#1079#1080#1103
70
      object btnLoadReview: TRzBitBtn
91
      ExplicitLeft = 0
71
        Left = 8
92
      ExplicitTop = 0
72
        Top = 384
93
      ExplicitWidth = 0
73
        Width = 129
94
      ExplicitHeight = 0
74
        Caption = #1047#1072#1075#1088#1091#1079#1080#1090#1100
95
      object mmReview: TMemo
75
        TabOrder = 0
76
        Visible = False
77
        OnClick = btnLoadReviewClick
78
        Glyph.Data = {
79
          36040000424D3604000000000000360000002800000010000000100000000100
80
          2000000000000004000000000000000000000000000000000000FF00FF00F1EF
81
          F000A49E9700DDD3CC00F5F0F000444250009E9DA5009E9B9D0028476A002F53
82
          77002B5B8C004E627A00E6E0D800E7E1DC00F0F0F000E7E2DD00E7EAF100D9DC
83
          E90088868600DEDFDF00F5EDE700423D4A00D3CCC700CFCBC900285482004386
84
          C60099B4CD0096AABE00D1CCC500D8D2CC00F0EDE800E2DDD800F7F4F100F7F1
85
          ED00B0ACA900DDDEDC00FBF5F100383F4200BCB3A700C9C3BF0021486B00527C
86
          9B00F0ECE600D2CAC400B9ADA400D3C9C200E7DDD500D5CCC400F5EFEA008E83
87
          7900CCC9C5008C887A00404E42001F3F3E002E454800393F43001A353E003D59
88
          5200BEB49F00E0D8CC003B4864009FA9D200F0F0EE00E5DFD900D8D4D4005465
89
          7D009194980038424100142347002A2D49003F3E530049485E0046466000383F
90
          6400504E7900DFD4C600526CA6005B7AC500A5A5B100E6E2DD005377B600435C
91
          8600746E7F0013155E003F3E6100978C8A00B7AFAD00C1B8B600BBB3B200AEA5
92
          A400837E87007F6E6A00435862002B4F8700788CB500E3DCD6003C6380008497
93
          A2003B385A0027405A007E797700CAC1C200D3C9C900D3C9C800D8CBCA00D3C9
94
          C800A3A0A20061667100465D54006B72790098979700B6AA9E0041665E007A8E
95
          7D00435752004A736B0097919200BBB6BD00C9C1C100CAC5C500A59D99009595
96
          9B00536CB400426CD800657AB100DAD0C700B0AAA400C0BEBB00738475006378
97
          6C0042594F0050777400A29C9E00A1A3AE008E93A60082899C004F5C7700375A
98
          A7004C80F0005C94FF006285DA00DFD6CA0097928D00F6F3F000EFEAE8005B7A
99
          7100486C61003A5E5B00838594006B78A500495C8500355EB4003F71D3005798
100
          FF0064A9FF005794FB00BABDCD00E5DFD90078787600E5E1DD0093A0B9007588
101
          99005A6E6E00475C70006783C800B7BCCE00A0A2A5002E54A4004776CF00628B
102
          C200879DBF00D0D1D500E6E2DF00E7E2DE00B9BAB900979290007A9AC1003D89
103
          E100407CC8004C619E006166B600A0B2DB008595C3003F62B800394B85005852
104
          5E00D2C0AC00D9D2CD00D9D4CF00DFD9D400F0EFE900B4ABA300849AA7004EAB
105
          FF0060CBFF0059A6F900826D9D003562B3002B4699002D50A0002F5AAF003A69
106
          B60087ACD000C3C2C200D8CEC400DBCFC700EFE4DA00D9D0C700E1DBD4006E93
107
          D60059A3EA005874A100645F83006A8FC300477FBE00558ABF005E90BF0086A5
108
          C700DBDEE300D5D0CA00E0D9D300DFD9D300F0F0E900E4DFD900988574006F6F
109
          F30056529D006F798800ACA9BC00C4A58C00999BA000C3A18300C5A88F00C5A2
110
          8400D6AD8A00C59E7C00C49C7A00C19A7700D1A78200C49C7B00626066007F81
111
          B600CBC2DE00AAE9DA00DFC0A300D6A77F00D5A88000D1A78100D2A78100D2A7
112
          8100E5B68D00D5AA8400D2A88200D2A88400E3B58E00D5AE8A00}
113
      end
114
      object mmReview: TRzMemo
115
        AlignWithMargins = True
96
        AlignWithMargins = True
116
        Left = 3
97
        Left = 3
117
        Top = 3
98
        Top = 3
118
        Width = 572
99
        Width = 608
119
        Height = 377
100
        Height = 321
120
        Margins.Bottom = 35
121
        Align = alClient
101
        Align = alClient
122
        ScrollBars = ssVertical
102
        ScrollBars = ssVertical
123
        TabOrder = 1
103
        TabOrder = 0
124
        OnChange = mmReviewChange
104
        OnChange = mmReviewChange
125
        ReadOnlyColor = 15794175
126
        ReadOnlyColorOnFocus = True
127
      end
105
      end
128
      object btnClearReview: TRzBitBtn
106
      object pnReviewButtons: TPanel
129
        Left = 158
107
        Left = 0
130
        Top = 384
108
        Top = 327
131
        Width = 91
109
        Width = 614
132
        Caption = #1054#1095#1080#1089#1090#1080#1090#1100
110
        Height = 33
133
        TabOrder = 2
111
        Align = alBottom
112
        BevelOuter = bvNone
113
        Caption = 'pnReviewButtons'
114
        ShowCaption = False
115
        TabOrder = 1
134
        Visible = False
116
        Visible = False
135
        OnClick = btnClearReviewClick
117
        DesignSize = (
136
        Glyph.Data = {
118
          614
137
          36060000424D3606000000000000360400002800000020000000100000000100
119
          33)
138
          0800000000000002000000000000000000000001000000000000000000003300
120
        object btnLoadReview: TButton
139
          00006600000099000000CC000000FF0000000033000033330000663300009933
121
          Left = 456
140
          0000CC330000FF33000000660000336600006666000099660000CC660000FF66
122
          Top = 3
141
          000000990000339900006699000099990000CC990000FF99000000CC000033CC
123
          Width = 75
142
          000066CC000099CC0000CCCC0000FFCC000000FF000033FF000066FF000099FF
124
          Height = 25
143
          0000CCFF0000FFFF000000003300330033006600330099003300CC003300FF00
125
          Anchors = [akTop, akRight]
144
          330000333300333333006633330099333300CC333300FF333300006633003366
126
          Caption = #1047#1072#1075#1088#1091#1079#1080#1090#1100
145
          33006666330099663300CC663300FF6633000099330033993300669933009999
127
          TabOrder = 0
146
          3300CC993300FF99330000CC330033CC330066CC330099CC3300CCCC3300FFCC
128
          OnClick = btnLoadReviewClick
147
          330000FF330033FF330066FF330099FF3300CCFF3300FFFF3300000066003300
129
        end
148
          66006600660099006600CC006600FF0066000033660033336600663366009933
130
        object btnClearReview: TButton
149
          6600CC336600FF33660000666600336666006666660099666600CC666600FF66
131
          Left = 537
150
          660000996600339966006699660099996600CC996600FF99660000CC660033CC
132
          Top = 3
151
          660066CC660099CC6600CCCC6600FFCC660000FF660033FF660066FF660099FF
133
          Width = 75
152
          6600CCFF6600FFFF660000009900330099006600990099009900CC009900FF00
134
          Height = 25
153
          990000339900333399006633990099339900CC339900FF339900006699003366
135
          Anchors = [akTop, akRight]
154
          99006666990099669900CC669900FF6699000099990033999900669999009999
136
          Caption = #1054#1095#1080#1089#1090#1080#1090#1100
155
          9900CC999900FF99990000CC990033CC990066CC990099CC9900CCCC9900FFCC
137
          TabOrder = 1
156
          990000FF990033FF990066FF990099FF9900CCFF9900FFFF99000000CC003300
138
          OnClick = btnClearReviewClick
157
          CC006600CC009900CC00CC00CC00FF00CC000033CC003333CC006633CC009933
139
        end
158
          CC00CC33CC00FF33CC000066CC003366CC006666CC009966CC00CC66CC00FF66
159
          CC000099CC003399CC006699CC009999CC00CC99CC00FF99CC0000CCCC0033CC
160
          CC0066CCCC0099CCCC00CCCCCC00FFCCCC0000FFCC0033FFCC0066FFCC0099FF
161
          CC00CCFFCC00FFFFCC000000FF003300FF006600FF009900FF00CC00FF00FF00
162
          FF000033FF003333FF006633FF009933FF00CC33FF00FF33FF000066FF003366
163
          FF006666FF009966FF00CC66FF00FF66FF000099FF003399FF006699FF009999
164
          FF00CC99FF00FF99FF0000CCFF0033CCFF0066CCFF0099CCFF00CCCCFF00FFCC
165
          FF0000FFFF0033FFFF0066FFFF0099FFFF00CCFFFF00FFFFFF00000080000080
166
          000000808000800000008000800080800000C0C0C00080808000191919004C4C
167
          4C00B2B2B200E5E5E5005A1E1E00783C3C0096646400C8969600FFC8C800465F
168
          82005591B9006EB9D7008CD2E600B4E6F000D8E9EC0099A8AC00646F7100E2EF
169
          F100C56A31000000000000000000000000000000000000000000000000000000
170
          0000000000000000000000000000000000000000000000000000EEEEEEEEEEEE
171
          EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE7E5E5E5E5
172
          EEEEEEEEEEEEEEEEEEEEEEAC81818181EEEEEEEEEEEEEEEEEEEEE7E5EEEEEEEE
173
          E5E5EEEEEEE5EEEEEEEEAC81EEEEEEEE8181EEEEEE81EEEEEEEEE5EEEEEEEEEE
174
          EEEEE5EEE5E5EEEEEEEE81EEEEEEEEEEEEEE81EE8181EEEEEEEEE5EEEEEEEEEE
175
          EEEEEEE5E5E5EEEEEEEE81EEEEEEEEEEEEEEEE818181EEEEEEEEE5EEEEEEEEEE
176
          EEEEE5E5E5E5EEEEEEEE81EEEEEEEEEEEEEE81818181EEEEEEEEE7E5EEEEEEEE
177
          EEE5E5E5E5E5EEEEEEEEAC81EEEEEEEEEE8181818181EEEEEEEEEEE5E7EEEEEE
178
          EEEEEEEEEEEEEEEEEEEEEE81ACEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
179
          EEEEEEEEEEEEE7E5EEEEEEEEEEEEEEEEEEEEEEEEEEEEAC81EEEEEEEEEEE5E5E5
180
          E5E5EEEEEEEEEEE5E7EEEEEEEE8181818181EEEEEEEEEE81ACEEEEEEEEE5E5E5
181
          E5EEEEEEEEEEEEEEE5EEEEEEEE81818181EEEEEEEEEEEEEE81EEEEEEEEE5E5E5
182
          EEEEEEEEEEEEEEEEE5EEEEEEEE818181EEEEEEEEEEEEEEEE81EEEEEEEEE5E5EE
183
          E5EEEEEEEEEEEEEEE5EEEEEEEE8181EE81EEEEEEEEEEEEEE81EEEEEEEEE5EEEE
184
          EEE5E5EEEEEEEEE5E7EEEEEEEE81EEEEEE8181EEEEEEEE81ACEEEEEEEEEEEEEE
185
          EEEEEEE5E5E5E5E7EEEEEEEEEEEEEEEEEEEEEE81818181ACEEEEEEEEEEEEEEEE
186
          EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE}
187
        NumGlyphs = 2
188
      end
140
      end
189
    end
141
    end
190
  end
142
  end
191
  object RzPanel1: TRzPanel
143
  object pnButtons: TPanel
192
    Left = 0
144
    Left = 0
193
    Top = 438
145
    Top = 444
194
    Width = 582
146
    Width = 628
195
    Height = 37
147
    Height = 37
196
    Align = alBottom
148
    Align = alBottom
197
    BorderOuter = fsFlatBold
149
    BevelOuter = bvNone
198
    TabOrder = 1
150
    TabOrder = 1
199
    DesignSize = (
151
    DesignSize = (
200
      580
152
      628
201
      35)
153
      37)
202
    object RzBitBtn1: TRzBitBtn
154
    object btnClose: TButton
203
      Left = 465
155
      Left = 545
204
      Top = 7
156
      Top = 4
205
      Width = 104
157
      Width = 75
158
      Height = 25
206
      Anchors = [akRight, akBottom]
159
      Anchors = [akRight, akBottom]
160
      Cancel = True
207
      Caption = #1047#1072#1082#1088#1099#1090#1100
161
      Caption = #1047#1072#1082#1088#1099#1090#1100
162
      ModalResult = 2
208
      TabOrder = 0
163
      TabOrder = 0
209
      OnClick = RzBitBtn1Click
210
      Kind = bkClose
211
    end
164
    end
212
  end
165
  end
166
  object pnTitle: TPanel
167
    Left = 0
168
    Top = 0
169
    Width = 628
170
    Height = 50
171
    Align = alTop
172
    AutoSize = True
173
    BevelOuter = bvNone
174
    Caption = 'pnTitle'
175
    Color = clWindow
176
    Padding.Left = 6
177
    Padding.Top = 6
178
    Padding.Right = 6
179
    Padding.Bottom = 6
180
    ParentBackground = False
181
    ShowCaption = False
182
    TabOrder = 2
183
    object lblAuthors: TLabel
184
      AlignWithMargins = True
185
      Left = 9
186
      Top = 28
187
      Width = 47
188
      Height = 13
189
      Align = alTop
190
      Caption = #1040#1074#1090#1086#1088'('#1099')'
191
      ShowAccelChar = False
192
      Transparent = True
193
    end
194
    object lblTitle: TLabel
195
      AlignWithMargins = True
196
      Left = 9
197
      Top = 9
198
      Width = 55
199
      Height = 13
200
      Align = alTop
201
      Caption = #1053#1072#1079#1074#1072#1085#1080#1077
202
      Font.Charset = DEFAULT_CHARSET
203
      Font.Color = clWindowText
204
      Font.Height = -11
205
      Font.Name = 'Tahoma'
206
      Font.Style = [fsBold]
207
      ParentFont = False
208
      ShowAccelChar = False
209
    end
210
  end
213
end
211
end

Updated trunk/Forms/frm_book_info.pas Download diff

463464
1
(* *****************************************************************************
2
  *
3
  * MyHomeLib
4
  *
5
  * Copyright (C) 2008-2010 Aleksey Penkov
6
  *
7
  * Authors Aleksey Penkov   alex.penkov@gmail.com
8
  *         Nick Rymanov     nrymanov@gmail.com
9
  *
10
  ****************************************************************************** *)
1
11
2
{******************************************************************************}
3
{                                                                              }
4
{                                 MyHomeLib                                    }
5
{                                                                              }
6
{                                Version 0.9                                   }
7
{                                20.08.2008                                    }
8
{                    Copyright (c) Aleksey Penkov  alex.penkov@gmail.com       }
9
{                                                                              }
10
{******************************************************************************}
11
12
13
unit frm_book_info;
12
unit frm_book_info;
14
13
15
interface
14
interface
16
15
17
uses
16
uses
18
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
17
  Windows,
19
  Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, ExtCtrls, RzPanel, RzButton,
18
  Messages,
20
  StdCtrls, RzLabel, RzEdit, ComCtrls, RzTabs;
19
  SysUtils,
20
  Variants,
21
  Classes,
22
  Graphics,
23
  Controls,
24
  Forms,
25
  Dialogs,
26
  xmldom,
27
  XMLIntf,
28
  msxmldom,
29
  XMLDoc,
30
  ExtCtrls,
31
  StdCtrls,
32
  ComCtrls,
33
  unit_Globals;
21
34
22
type
35
type
23
  TfrmBookDetails = class(TForm)
36
  TfrmBookDetails = class(TForm)
24
    RzPageControl1: TRzPageControl;
37
    RzPageControl1: TPageControl;
25
    TabSheet1: TRzTabSheet;
38
    tsInfo: TTabSheet;
26
    TabSheet2: TRzTabSheet;
39
    tsReview: TTabSheet;
27
    mmShort: TMemo;
40
    mmShort: TMemo;
28
    Img: TImage;
41
    imgCover: TImage;
29
    RzPanel1: TRzPanel;
42
    pnButtons: TPanel;
30
    RzBitBtn1: TRzBitBtn;
43
    btnClose: TButton;
31
    btnLoadReview: TRzBitBtn;
44
    btnLoadReview: TButton;
32
    mmReview: TRzMemo;
45
    mmReview: TMemo;
33
    btnClearReview: TRzBitBtn;
46
    btnClearReview: TButton;
34
    mmInfo: TRzRichEdit;
47
    pnTitle: TPanel;
35
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
48
    lblAuthors: TLabel;
36
    procedure RzBitBtn1Click(Sender: TObject);
49
    lvInfo: TListView;
50
    lblTitle: TLabel;
51
    pnReviewButtons: TPanel;
52
    procedure FormCreate(Sender: TObject);
53
    procedure FormShow(Sender: TObject);
37
    procedure mmReviewChange(Sender: TObject);
54
    procedure mmReviewChange(Sender: TObject);
38
    procedure btnLoadReviewClick(Sender: TObject);
55
    procedure btnLoadReviewClick(Sender: TObject);
39
    procedure btnClearReviewClick(Sender: TObject);
56
    procedure btnClearReviewClick(Sender: TObject);
57
40
  private
58
  private
41
    { Private declarations }
42
    FUrl: string;
59
    FUrl: string;
43
60
44
    FReviewChanged : boolean;
61
    FReviewChanged: Boolean;
62
    //FBookRecord: TBookRecord;
45
    function GetReview: string;
63
    function GetReview: string;
46
    procedure Setreview(const Value: string);
64
    procedure SetReview(const Value: string);
65
    //procedure SetBookRecord(const Value: TBookRecord);
47
66
48
  public
67
  public
49
    procedure AllowOnlineReview(URL: string);
68
    procedure AllowOnlineReview(URL: string);
50
    procedure Download;
69
    procedure Download;
51
70
52
    procedure ShowBookInfo(FS: TMemoryStream);
71
    procedure FillBookInfo(bookInfo: TBookRecord; bookStream: TMemoryStream);
53
    property Review: string read GetReview write Setreview;
72
54
    property ReviewChanged: boolean read FReviewChanged write FReviewChanged;
73
    property Review: string read GetReview write SetReview;
55
    property URL: string write FURL;
74
    property ReviewChanged: Boolean read FReviewChanged write FReviewChanged;
56
    { Public declarations }
75
    property URL: string read FUrl write FUrl;
76
    //property Book: TBookRecord read FBookRecord write SetBookRecord;
57
  end;
77
  end;
58
78
59
  TReviewDownloadThread = class(TThread)
79
  TReviewDownloadThread = class(TThread)
60
  private
80
  private
61
    { Private declarations }
62
    FForm: TfrmBookDetails;
81
    FForm: TfrmBookDetails;
63
    FReview : TStringList;
82
    FReview: TStringList;
64
    FURL : string;
83
    FUrl: string;
65
84
66
    procedure StartDownload;
85
    procedure StartDownload;
67
    procedure Finish;
86
    procedure Finish;
...
...
69
    procedure Execute; override;
88
    procedure Execute; override;
70
    property Form: TfrmBookDetails read FForm write FForm;
89
    property Form: TfrmBookDetails read FForm write FForm;
71
  public
90
  public
72
    property URL: string write FURL;
91
    property URL: string write FUrl;
73
  end;
92
  end;
74
93
75
  procedure DownloadReview(Form: TfrmBookDetails; URL: string);
94
procedure DownloadReview(Form: TfrmBookDetails; URL: string);
76
95
77
var
96
var
78
  frmBookDetails: TfrmBookDetails;
97
  frmBookDetails: TfrmBookDetails;
...
...
81
100
82
uses
101
uses
83
  FictionBook_21,
102
  FictionBook_21,
84
  unit_globals,
85
  unit_Settings,
103
  unit_Settings,
86
  unit_MHLHelpers,
87
  unit_ReviewParser,
104
  unit_ReviewParser,
88
  dm_user,
105
  dm_user,
89
  jpeg,
106
  CommCtrl,
90
  pngimage,
107
  StrUtils,
91
  strutils;
108
  unit_MHLHelpers,
109
  unit_FB2Utils;
92
110
93
94
{$R *.dfm}
111
{$R *.dfm}
95
112
113
procedure TfrmBookDetails.FormCreate(Sender: TObject);
114
begin
115
  lvInfo.ShowColumnHeaders := False;
116
  FReviewChanged := False;
117
end;
118
96
procedure TfrmBookDetails.AllowOnlineReview(URL: string);
119
procedure TfrmBookDetails.AllowOnlineReview(URL: string);
97
begin
120
begin
98
  FUrl := URL;
121
  FUrl := URL;
99
122
100
  btnLoadReview.Visible := True;
123
  pnReviewButtons.Visible := True;
101
  btnClearReview.Visible := True;
102
end;
124
end;
103
125
104
procedure TfrmBookDetails.FormKeyDown(Sender: TObject; var Key: Word;
105
  Shift: TShiftState);
106
begin
107
  if key=27 then Close;
108
end;
109
110
procedure TfrmBookDetails.Download;
126
procedure TfrmBookDetails.Download;
111
var
127
var
112
  reviewParser : TReviewParser;
128
  reviewParser: TReviewParser;
113
  review : TStringList;
129
  Review: TStringList;
114
begin
130
begin
115
  btnLoadReview.Enabled := False;
131
  btnLoadReview.Enabled := False;
116
  reviewParser := TReviewParser.Create;
117
  review := TStringList.Create;
118
  Screen.Cursor := crHourGlass;
132
  Screen.Cursor := crHourGlass;
119
  try
133
  try
120
    reviewParser.Parse(FURL, review);
134
    reviewParser := TReviewParser.Create;
121
    mmReview.Clear;
135
    try
122
    mmReview.Lines.AddStrings(review);
136
      Review := TStringList.Create;
123
    FReviewChanged := True;
137
      try
138
        reviewParser.Parse(FUrl, Review);
139
        mmReview.Lines.Assign(Review);
140
141
        FReviewChanged := True;
142
      finally
143
        Review.Free;
144
      end;
145
    finally
146
      reviewParser.Free;
147
    end;
124
  finally
148
  finally
125
    review.Free;
126
    reviewParser.Free;
127
    Screen.Cursor := crDefault;
149
    Screen.Cursor := crDefault;
128
    btnLoadReview.Enabled := True;
150
    btnLoadReview.Enabled := True;
129
  end;
151
  end;
130
end;
152
end;
131
153
154
procedure TfrmBookDetails.FormShow(Sender: TObject);
155
begin
156
  // TODO     ?
157
  ListView_SetColumnWidth(lvInfo.Handle, 0, LVSCW_AUTOSIZE);
158
  ListView_SetColumnWidth(lvInfo.Handle, 1, LVSCW_AUTOSIZE);
159
end;
160
132
function TfrmBookDetails.GetReview: string;
161
function TfrmBookDetails.GetReview: string;
133
begin
162
begin
134
  Result := mmReview.Lines.Text;
163
  Result := mmReview.Lines.Text;
...
...
139
  FReviewChanged := True;
168
  FReviewChanged := True;
140
end;
169
end;
141
170
142
procedure TfrmBookDetails.RzBitBtn1Click(Sender: TObject);
143
begin
144
  Close;
145
end;
146
147
procedure TfrmBookDetails.btnClearReviewClick(Sender: TObject);
171
procedure TfrmBookDetails.btnClearReviewClick(Sender: TObject);
148
begin
172
begin
149
  mmReview.Clear;
173
  mmReview.Clear;
...
...
155
  Download;
179
  Download;
156
end;
180
end;
157
181
158
procedure TfrmBookDetails.Setreview(const Value: string);
182
//procedure TfrmBookDetails.SetBookRecord(const Value: TBookRecord);
183
//begin
184
//  FBookRecord := Value;
185
//  lblTitle.Caption := FBookRecord.Title;
186
  { TODO -oNickR -cUsability :     ?        }
187
//  lblAuthors.Caption := FBookRecord.Authors[0].GetFullName;
188
//end;
189
190
procedure TfrmBookDetails.SetReview(const Value: string);
159
begin
191
begin
160
  mmReview.Lines.Text := Value;
192
  mmReview.Lines.Text := Value;
161
end;
193
end;
162
194
163
procedure TfrmBookDetails.ShowBookInfo(FS: TMemoryStream);
195
procedure TfrmBookDetails.FillBookInfo(bookInfo: TBookRecord; bookStream: TMemoryStream);
164
var
196
var
165
  book:IXMLFictionBook;
197
  book: IXMLFictionBook;
166
  i,p:integer;
198
  i: integer;
167
  S, outStr: AnsiString;
199
  imgBookCover: TGraphic;
168
  CoverID:String;
200
  tmpStr: string;
169
  Ext: string;
170
201
171
  ImgVisible : boolean;
202
  procedure AddItem(const Field: string; const Value: string; GroupID: integer = -1);
172
  MS : TMemoryStream;
203
  var
204
    item: TListItem;
205
  begin
206
    item := lvInfo.Items.Add;
207
    item.Caption := Field;
208
    item.SubItems.Add(Value);
209
    item.GroupID := GroupID;
210
  end;
173
211
174
  TmpImg: TGraphic;
212
begin
213
  //
214
  //    TBookRecord
215
  //
216
  lblTitle.Caption := bookInfo.Title;
217
  lblAuthors.Caption := bookInfo.Authors[0].GetFullName;
175
218
176
  StrLen : integer;
219
  with lvInfo.Groups.Add do
177
  ImageType: TCoverImageType;
220
  begin
221
    Header := '  ';
222
    AddItem('', bookInfo.Folder, GroupID);
223
    AddItem('', bookInfo.FileName, GroupID);
224
    AddItem('', GetFormattedSize(bookInfo.Size, True), GroupID);
225
    AddItem('', DateToStr(bookInfo.Date), GroupID);
226
  end;
227
  { TODO -oNickR -cUsability :        }
228
  // libID: Integer;    ???
229
  // LibRate: Integer;  ???
230
  // URI: string;       ???
178
231
179
232
  //
180
  procedure WriteString(Title, Text: string);
233
  //    
  //
234
  if not Assigned(bookStream) or (bookStream.Size = 0) then
181
  begin
235
  begin
182
    mmInfo.SelAttributes.Style := [fsBold];
236
    imgCover.Visible := False;
183
    mmInfo.SetSelText(Title + ': ' + #9);
237
    mmShort.Visible := False;
184
    mmInfo.SelAttributes.Style := [];
238
    Exit;
185
    if Text <> '' then mmInfo.SetSelText(Text);
186
    mmInfo.SetSelText(#13#10)
187
  end;
239
  end;
188
240
189
241
  //FS.SaveToFile('C:\temp\book.xml');
190
begin
191
  FReviewChanged := False;
192
193
  Img.Picture.Bitmap.Canvas.FrameRect(Img.ClientRect);
194
  mmInfo.Lines.Clear;
195
  mmShort.Lines.Clear;
196
  try
242
  try
197
    book := LoadFictionbook(FS);
243
    book := LoadFictionbook(bookStream);
198
    try
199
      MS := TMemoryStream.Create;
200
      CoverID := Book.Description.Titleinfo.Coverpage.XML;
201
      p := pos('"#', CoverID);
202
      if p <> 0 then
203
      begin
204
        Delete(CoverId, 1, p + 1);
205
        p := pos('"', CoverID);
206
        CoverID := Copy(CoverID, 1, p - 1);
207
        for i := 0 to Book.Binary.Count - 1 do
208
        begin
209
          if Book.Binary.Items[i].Id = CoverID then
210
          begin
211
            S := Book.Binary.Items[i].Text;
212
            outStr := DecodeBase64(S);
213
244
214
            StrLen := Length(outStr);
245
    //
215
            MS.Write(PAnsiChar(outStr)^, StrLen);
246
    //   ( )
216
            ImgVisible := True;
247
    //
217
          end;
248
    imgBookCover := GetBookCover(book);
218
        end;
249
    if Assigned(imgBookCover) then
219
        //MS.SaveToFile('E:\temp\' + CoverID);
250
    begin
251
      try
252
        imgCover.Picture.Assign(imgBookCover);
253
        imgCover.Visible := True;
254
      finally
255
        imgBookCover.Free;
220
      end;
256
      end;
257
    end
258
    else
259
      imgCover.Visible := False;
221
260
222
      if ImgVisible then
261
    with book.Description.Titleinfo do
262
    begin
263
      // ---------------------------------------------
264
      with lvInfo.Groups.Add do
223
      begin
265
      begin
224
        CreateImage(ExtractFileExt(CoverID), TmpImg, ImageType);
266
        Header := ' ';
225
        if Assigned(TmpImg) then
226
        begin
227
          MS.Seek(0,soFromBeginning);
228
          TmpImg.LoadFromStream(MS);
229
          IMG.Picture.Assign(TmpImg);
230
          IMG.Invalidate;
231
          TmpImg.Free;
232
        end;
233
      end
234
      else
235
        IMG.Picture := nil;
236
    finally
237
      MS.Free;
238
    end;
239
267
240
    with Book.Description.Titleinfo do
268
        { TODO -oNickR -cUsability :     ?        }
241
    begin
269
        //if Author.Count > 0 then
270
        //  lblAuthors.Caption := Author[0].Lastname.Text + ' ' + Author[0].Firstname.Text + ' ' + Author[0].MiddleName.Text;
242
271
243
      mmInfo.SelAttributes.Size := 10;
272
        { TODO -oNickR -cUsability :    +    }
244
      mmInfo.SelAttributes.Style := [fsBold];
273
        if Sequence.Count > 0 then
274
          AddItem('', Sequence[0].Name, GroupID);
245
275
246
      if Author.Count>0 then
276
        { TODO -oNickR -cUsability :    +     }
247
        mmInfo.SetSelText(Author[0].Lastname.Text+' '+Author[0].Firstname.Text+' '+Author[0].MiddleName.Text+#13#10);
277
        if Genre.Count > 0 then
278
          AddItem('', Genre[0], GroupID);
279
      end;
248
280
249
      mmInfo.SelAttributes.Size := 12;
281
      // ---------------------------------------------
250
      mmInfo.SelAttributes.Color := clNavy;
282
      with lvInfo.Groups.Add, book.Description.Publishinfo do
251
      mmInfo.SetSelText(Booktitle.Text+#13#10);
283
      begin
284
        Header := ' ';
285
        AddItem('', Publisher.Text, GroupID);
286
        AddItem('', City.Text, GroupID);
287
        AddItem('', Year, GroupID);
288
        AddItem('ISBN', Isbn.Text, GroupID);
289
      end;
252
290
253
      if Sequence.Count > 0 then
291
      // ---------------------------------------------
254
        WriteString('',Sequence[0].Name);
292
      with lvInfo.Groups.Add, book.Description.Documentinfo do
293
      begin
294
        Header := '   (OCR)';
295
        for i := 0 to Author.Count - 1 do
296
        begin
297
          { TODO -oNickR -cUsability :         }
298
          tmpStr := Author[i].Firstname.Text + ' ' + Author[i].Lastname.Text + '(' + Author[i].NickName.Text + ')';
299
          AddItem(IfThen(i = 0, ''), tmpStr, GroupID);
300
        end;
255
301
256
      mmInfo.SetSelText(#13#10);
302
        AddItem('', Programused.Text, GroupID);
257
      WriteString('',IfThen(Genre.Count > 0, Genre[0], ''));
303
        AddItem('', Date.Text, GroupID);
258
      mmInfo.SetSelText(#13#10);
304
        AddItem('ID', Id, GroupID);
305
        AddItem('', Version, GroupID);
259
306
260
      WriteString('PublishInfo','');
307
        for i := 0 to History.p.Count - 1 do
261
      mmInfo.SetSelText('-: '+ #9 + Book.Description.Publishinfo.Publisher.Text+#13#10);
308
          AddItem(IfThen(i = 0, ''), History.p[i].OnlyText, GroupID);
262
      mmInfo.SetSelText(': '+ #9 + Book.Description.Publishinfo.City.Text+#13#10);
309
      end;
263
      mmInfo.SetSelText(': '+ #9 + Book.Description.Publishinfo.Year+#13#10);
264
      mmInfo.SetSelText('ISBN: '+ #9 + Book.Description.Publishinfo.Isbn.Text+#13#10);
265
      mmInfo.SetSelText(#13#10);
266
310
267
311
      // ---------------------------------------------
268
      WriteString('DocumentInfo (OCR)','');
312
      { TODO -oNickR -cUsability :      ? }
      for i := 0 to Annotation.p.Count - 1 do
269
      mmInfo.SetSelText(': '+#13#10);
313
        mmShort.Lines.Add(Annotation.p[i].OnlyText);
270
      for I := 0 to Book.Description.Documentinfo.Author.Count - 1 do
271
        with Book.Description.Documentinfo.Author.Items[i] do
272
            mmInfo.SetSelText(Firstname.Text + ' ' +Lastname.Text + '(' + NickName.Text + ')' + #13#10);
273
      mmInfo.SetSelText('');
274
      mmInfo.SetSelText(': '+ Book.Description.Documentinfo.Programused.Text + #13#10);
275
      mmInfo.SetSelText(': '+ #9 + Book.Description.Documentinfo.Date.Text + #13#10);
276
      mmInfo.SetSelText('ID: '+ #9 + Book.Description.Documentinfo.ID + #13#10);
277
      mmInfo.SetSelText('Version: '+ #9 + Book.Description.Documentinfo.Version + #13#10);
278
      mmInfo.SetSelText('History: '+ #9 + Book.Description.Documentinfo.History.P.Text + #13#10);
279
280
      for I := 0 to Annotation.P.Count - 1 do
281
              mmShort.SetSelText(Annotation.P.Items[i].OnlyText);
282
283
    end;
314
    end;
284
  except
315
  except
316
    //
317
    Assert(False);
285
  end;
318
  end;
286
end;
319
end;
287
320
288
{-------------------- TReviewDownloadThread -----------------------------------}
321
{-------------------- TReviewDownloadThread ----------------------------------- }
289
322
290
procedure TReviewDownloadThread.Execute;
323
procedure TReviewDownloadThread.Execute;
291
var
324
var
292
  reviewParser : TReviewParser;
325
  reviewParser: TReviewParser;
293
begin
326
begin
294
  Synchronize(StartDownload);
327
  Synchronize(StartDownload);
295
  Freview := TStringList.Create;
328
  FReview := TStringList.Create;
296
  try
329
  try
297
    reviewParser := TReviewParser.Create;
330
    reviewParser := TReviewParser.Create;
298
    try
331
    try
299
      reviewParser.Parse(FURL, Freview);
332
      reviewParser.Parse(FUrl, FReview);
300
    finally
333
    finally
301
      reviewParser.Free;
334
      reviewParser.Free;
302
    end;
335
    end;
...
...
306
  end;
341
  end;
307
end;
342
end;
308
343
344
procedure TReviewDownloadThread.StartDownload;
345
begin
346
  FForm.btnLoadReview.Enabled := False;
347
end;
348
309
procedure TReviewDownloadThread.Finish;
349
procedure TReviewDownloadThread.Finish;
310
begin
350
begin
311
  if FForm.mmReview = Nil then Exit; // FForm -   nil  .
351
  if FForm.mmReview = nil then
312
                                     //   ,    
352
    Exit; // FForm -   nil  .
353
  //   ,    
313
354
314
  FForm.mmReview.Clear;
355
  FForm.mmReview.Lines := FReview;
315
  FForm.mmReview.Lines.AddStrings(Freview);
316
  FForm.btnLoadReview.Enabled := True;
356
  FForm.btnLoadReview.Enabled := True;
317
  FForm.ReviewChanged := True;
357
  FForm.ReviewChanged := True;
318
  FForm.RzPageControl1.ActivePageIndex := 1;
358
  //FForm.RzPageControl1.ActivePageIndex := 1;
319
end;
359
end;
320
360
321
procedure TReviewDownloadThread.StartDownload;
361
// ------------------------------------------------------------------------------
322
begin
323
  FForm.btnLoadReview.Enabled := False;
324
end;
325
362
326
//------------------------------------------------------------------------------
363
procedure DownloadReview(Form: TfrmBookDetails; URL: string);
327
328
procedure DownloadReview (Form: TfrmBookDetails; URL: string) ;
329
var
364
var
330
  Worker : TReviewDownloadThread;
365
  Worker: TReviewDownloadThread;
331
begin
366
begin
332
  Worker := TReviewDownloadThread.Create(True);
367
  Worker := TReviewDownloadThread.Create(True);
333
  Worker.Form := Form;
368
  Worker.Form := Form;

Updated trunk/Forms/frm_main.pas Download diff

File was changed - ok, show the diff

Updated trunk/MyhomeLib.dpr Download diff

File was changed - ok, show the diff

Updated trunk/MyhomeLib.dproj Download diff

File was changed - ok, show the diff

Updated trunk/Units/unit_Globals.pas Download diff

File was changed - ok, show the diff