-
Notifications
You must be signed in to change notification settings - Fork 0
/
conflictstree.pas
84 lines (68 loc) · 1.95 KB
/
conflictstree.pas
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
unit ConflictsTree;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, sqldb, FileUtil, Forms, Controls, Graphics, Dialogs,
ComCtrls, MetaUnit, ConflictsMeta, Filters, Referen;
type
{ TConflictsTreeForm }
TConflictsTreeForm = class(TForm)
TreeView: TTreeView;
procedure FormShow(Sender: TObject);
procedure TreeViewDblClick(Sender: TObject);
public
ScheduleTable: TTableInfo;
procedure BuildTree;
procedure InsertConflicts(ANode: TTreeNode; AID: Integer);
end;
var
ConflictsTreeForm: TConflictsTreeForm;
implementation
{ TConflictsTreeForm }
procedure TConflictsTreeForm.InsertConflicts(ANode: TTreeNode; AID: Integer);
var
i: Integer;
Pairs: TConflictPairs;
tmpNode: TTreeNode;
begin
Pairs := ConflictsModule.ConflictPairs[AID];
for i := 0 to High(Pairs) do begin
tmpNode := TreeView.Items.AddChild(ANode, Format('Конфликт между %d и %d',
[Pairs[i].x, Pairs[i].y]));
tmpNode.Data := @ConflictsModule.ConflictPairs[AID][i];
end;
end;
procedure TConflictsTreeForm.BuildTree;
var
i: Integer;
rootNode, currLvlNode: TTreeNode;
begin
rootNode := TreeView.Items.Add(nil, 'Конфликты');
for i := 0 to High(Conflicts) do begin
currLvlNode := TreeView.Items.AddChild(rootNode,
Format('%d. %s', [i + 1, Conflicts[i].FName]));
InsertConflicts(currLvlNode, i);
end;
rootNode.Expanded := True;
end;
procedure TConflictsTreeForm.FormShow(Sender: TObject);
begin
BuildTree;
end;
procedure TConflictsTreeForm.TreeViewDblClick(Sender: TObject);
var
a, b: String;
DefFilters: array of TFilterInfo;
begin
if TreeView.Selected.Data = nil then Exit;
with TPoint(TreeView.Selected.Data^) do begin
a := IntToStr(x);
b := IntToStr(y);
end;
SetLength(DefFilters, 2);
DefFilters[0] := TFilterInfo.Create(0, 2, a, True);
DefFilters[1] := TFilterInfo.Create(0, 2, b, True);
ReferenForm.PopupForm(ConflictsModule.ScheduleTable, 1, DefFilters);
end;
{$R *.lfm}
end.