-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathformexportpatch.pas
More file actions
135 lines (110 loc) · 3 KB
/
formexportpatch.pas
File metadata and controls
135 lines (110 loc) · 3 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
unit formexportpatch;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, Projeto, LazLogger, BibleTreeView, PatchFile, LCLIntf;
type
{ TFormExportPatch }
TFormExportPatch = class(TForm)
Button1: TButton;
Button2: TButton;
BtnSelectAll: TButton;
BtnDeselectAll: TButton;
GroupBox1: TGroupBox;
procedure BtnDeselectAllClick(Sender: TObject);
procedure BtnSelectAllClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
private
FBibleTreeView: TBibleTreeView;
function CreatePatch: TPatchFile;
function GetVerseList: TStringList;
procedure SetScope(AValue: TEscopoTexto);
public
procedure SavePatch(filename: string);
property VerseList: TStringList read GetVerseList;
property Scope: TEscopoTexto write SetScope;
end;
{$INCLUDE include/bookdefs.inc}
var
FrmExportPatch: TFormExportPatch;
implementation
uses formPrincipal;
{ TFormExportPatch }
procedure TFormExportPatch.SetScope(AValue: TEscopoTexto);
begin
FBibleTreeView.Scope := AValue;
end;
procedure TFormExportPatch.SavePatch(filename: string);
var
patch: TPatchFile;
begin
patch := CreatePatch;
if patch.Reference.Count = 0 then
exit;
try
patch.Save(filename);
finally
patch.Free;
end;
OpenDocument(ExtractFilePath(filename));
end;
function TFormExportPatch.GetVerseList: TStringList;
begin
result := FBibleTreeView.VerseList;
end;
function TFormExportPatch.CreatePatch: TPatchFile;
var
refs: TStringList;
ref: string;
begin
result := TPatchFile.Create;
refs := FBibleTreeView.VerseList;
try
ProjetoAtual.StartScrollingSession;
for ref in refs do
begin
ProjetoAtual.GoToReference(ref);
DebugLn('exporting %s (%s)', [ref, ProjetoAtual.FormattedReference]);
result.Add(ref,
ProjetoAtual.ObterTextoVersiculo(tbOrigem),
ProjetoAtual.ObterTextoVersiculo(tbDestino),
ProjetoAtual.Pairs,
ProjetoAtual.Comentarios,
ProjetoAtual.Situacao
);
end;
finally
ProjetoAtual.FinishScrollingSession;
refs.Free;
end;
end;
procedure TFormExportPatch.FormCreate(Sender: TObject);
begin
FBibleTreeView := TBibleTreeView.Create(GroupBox1);
FBibleTreeView.Align := alClient;
end;
procedure TFormExportPatch.FormDestroy(Sender: TObject);
begin
FBibleTreeView.Free;
end;
procedure TFormExportPatch.FormShow(Sender: TObject);
begin
Scope := ProjetoAtual.Escopo;
Position := poScreenCenter; // necessary to force alignment after setting height
Height := Trunc(FrmPrincipal.Height * 0.9);
Position := poMainFormCenter;
end;
procedure TFormExportPatch.BtnSelectAllClick(Sender: TObject);
begin
FBibleTreeView.SelectAll;
end;
procedure TFormExportPatch.BtnDeselectAllClick(Sender: TObject);
begin
FBibleTreeView.SelectNone;
end;
initialization
{$I formexportpatch.lrs}
end.