1 | unit UFormLog;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
|
---|
9 | StdCtrls, ExtCtrls, UVCS;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormLog }
|
---|
14 |
|
---|
15 | TFormLog = class(TForm)
|
---|
16 | Button1: TButton;
|
---|
17 | ListViewItems: TListView;
|
---|
18 | ListViewFiles: TListView;
|
---|
19 | MemoMessages: TMemo;
|
---|
20 | Splitter1: TSplitter;
|
---|
21 | Splitter2: TSplitter;
|
---|
22 | procedure FormCreate(Sender: TObject);
|
---|
23 | procedure FormDestroy(Sender: TObject);
|
---|
24 | procedure FormShow(Sender: TObject);
|
---|
25 | procedure ListViewFilesData(Sender: TObject; Item: TListItem);
|
---|
26 | procedure ListViewItemsData(Sender: TObject; Item: TListItem);
|
---|
27 | procedure ListViewItemsSelectItem(Sender: TObject; Item: TListItem;
|
---|
28 | Selected: Boolean);
|
---|
29 | private
|
---|
30 | { private declarations }
|
---|
31 | public
|
---|
32 | FileName: string;
|
---|
33 | LogList: TLogList;
|
---|
34 | procedure ReloadList;
|
---|
35 | procedure UpdateInterface;
|
---|
36 | end;
|
---|
37 |
|
---|
38 | var
|
---|
39 | FormLog: TFormLog;
|
---|
40 |
|
---|
41 | implementation
|
---|
42 |
|
---|
43 | uses
|
---|
44 | UCore;
|
---|
45 |
|
---|
46 | {$R *.lfm}
|
---|
47 |
|
---|
48 | { TFormLog }
|
---|
49 |
|
---|
50 | procedure TFormLog.FormCreate(Sender: TObject);
|
---|
51 | begin
|
---|
52 | LogList := TLogList.Create;
|
---|
53 | end;
|
---|
54 |
|
---|
55 | procedure TFormLog.FormDestroy(Sender: TObject);
|
---|
56 | begin
|
---|
57 | FreeAndNil(LogList);
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TFormLog.FormShow(Sender: TObject);
|
---|
61 | begin
|
---|
62 | Core.Project.WorkingCopy.GetLog(FileName, LogList);
|
---|
63 | ReloadList;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TFormLog.ListViewFilesData(Sender: TObject; Item: TListItem);
|
---|
67 | begin
|
---|
68 | if Assigned(ListViewItems.Selected) and (Item.Index >= 0) and (Item.Index < TLogItem(ListViewItems.Selected.Data).ChangedFiles.Count) then
|
---|
69 | with TLogItem(ListViewItems.Selected.Data) do begin
|
---|
70 | Item.Caption := ChangedFiles[Item.Index];
|
---|
71 | end;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormLog.ListViewItemsData(Sender: TObject; Item: TListItem);
|
---|
75 | begin
|
---|
76 | if (Item.Index >= 0) and (Item.Index < LogList.Count) then
|
---|
77 | with TLogItem(LogList[Item.Index]) do begin
|
---|
78 | Item.Caption := Revision;
|
---|
79 | Item.SubItems.Add(Actions);
|
---|
80 | Item.SubItems.Add(Author);
|
---|
81 | Item.SubItems.Add(DateTimeToStr(Time));
|
---|
82 | Item.SubItems.Add(StringReplace(Messages.Text, LineEnding, ' ', [rfReplaceAll]));
|
---|
83 | Item.Data := LogList[Item.Index];
|
---|
84 | end;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TFormLog.ListViewItemsSelectItem(Sender: TObject; Item: TListItem;
|
---|
88 | Selected: Boolean);
|
---|
89 | begin
|
---|
90 | ReloadList;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TFormLog.ReloadList;
|
---|
94 | begin
|
---|
95 | ListViewItems.Items.Count := LogList.Count;
|
---|
96 | ListViewItems.Refresh;
|
---|
97 | if Assigned(ListViewItems.Selected) then
|
---|
98 | with TLogItem(ListViewItems.Selected.Data) do begin
|
---|
99 | ListViewFiles.Items.Count := ChangedFiles.Count;
|
---|
100 | ListViewFiles.Refresh;
|
---|
101 | MemoMessages.Lines.Assign(Messages);
|
---|
102 | end else begin
|
---|
103 | ListViewFiles.Items.Count := 0;
|
---|
104 | ListViewFiles.Refresh;
|
---|
105 | MemoMessages.Lines.Clear;
|
---|
106 | end;
|
---|
107 | UpdateInterface;
|
---|
108 | end;
|
---|
109 |
|
---|
110 | procedure TFormLog.UpdateInterface;
|
---|
111 | begin
|
---|
112 | MemoMessages.Enabled := Assigned(ListViewItems.Selected);
|
---|
113 | ListViewFiles.Enabled := Assigned(ListViewItems.Selected)
|
---|
114 | end;
|
---|
115 |
|
---|
116 | end.
|
---|
117 |
|
---|