source: trunk/Forms/UFormLog.pas

Last change on this file was 12, checked in by chronos, 9 years ago
  • Modified: Show messages in one line in revision list.
File size: 2.8 KB
Line 
1unit UFormLog;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
9 StdCtrls, ExtCtrls, UVCS;
10
11type
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
38var
39 FormLog: TFormLog;
40
41implementation
42
43uses
44 UCore;
45
46{$R *.lfm}
47
48{ TFormLog }
49
50procedure TFormLog.FormCreate(Sender: TObject);
51begin
52 LogList := TLogList.Create;
53end;
54
55procedure TFormLog.FormDestroy(Sender: TObject);
56begin
57 FreeAndNil(LogList);
58end;
59
60procedure TFormLog.FormShow(Sender: TObject);
61begin
62 Core.Project.WorkingCopy.GetLog(FileName, LogList);
63 ReloadList;
64end;
65
66procedure TFormLog.ListViewFilesData(Sender: TObject; Item: TListItem);
67begin
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;
72end;
73
74procedure TFormLog.ListViewItemsData(Sender: TObject; Item: TListItem);
75begin
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;
85end;
86
87procedure TFormLog.ListViewItemsSelectItem(Sender: TObject; Item: TListItem;
88 Selected: Boolean);
89begin
90 ReloadList;
91end;
92
93procedure TFormLog.ReloadList;
94begin
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;
108end;
109
110procedure TFormLog.UpdateInterface;
111begin
112 MemoMessages.Enabled := Assigned(ListViewItems.Selected);
113 ListViewFiles.Enabled := Assigned(ListViewItems.Selected)
114end;
115
116end.
117
Note: See TracBrowser for help on using the repository browser.