📄 ucomparison.pas
字号:
CheckBoxFilterFiles.Checked := Settings.FilterFiles;
CheckBoxAutoIdentifiers.Checked := Settings.AutoSelectIdentifier;
CheckBoxFilterIdentifiers.Checked := Settings.FilterIdentifiers;
CheckBoxAutoMembers.Checked := Settings.AutoSelectMember;
CheckBoxFilterMembers.Checked := Settings.FilterMembers;
ListBoxMessages.Height := Settings.MessageHeight;
PanelIdentifiersAndMembers.Height := Settings.IdentifierMemberHeight;
PanelMembers.Height := Settings.MemberHeight;
end;
{Shows the list of parsed files.
~param Data the list of parsed files to show
~param List the list box to list the files in
~param Other the other list of parsed files, if filtered all with this list
common files are not shown }
procedure TFormComparison.ShowFiles(Data: TFileList; List: TListBox;
Other: TFileList);
var i :Integer; //counter through all files
AFile :TPascalFile; //each file
j :Integer; //counter through other files
begin
List.Items.BeginUpdate; //begin updating the list
try
List.Clear; //clear the list
if not CheckBoxFilterFiles.Checked then //same files should not be filtered?
for i := 0 to Data.Count - 1 do //add all files
List.Items.AddObject(Data[i].InternalFileName, Data[i])
else
for i := 0 to Data.Count - 1 do //for each file
begin
AFile := Data[i]; //get it
j := Other.Count - 1; //for each file in other data
while (j >= 0) and //check if there is an
((CompareText(AFile.InternalFileName, //equal file
Other[j].InternalFileName) <> 0) or
not AFile.CompareWith(Other[j], '', IgnoreStringList)) do
dec(j);
if j < 0 then //no equal file exists there?
List.Items.AddObject(AFile.InternalFileName, AFile); //add this file
end;
finally
List.Items.EndUpdate; //end updating the list
end;
end;
{Shows the list of identifiers.
~param Idents the list of identifiers to show
~param List the list box to list the identifiers in
~param Filter if the identifiers should be filtered before listing them
~param FilterIdents the other list of identifiers, if filtered all with this
list common identifiers are not shown }
procedure TFormComparison.ShowIdents(Idents: TIdentifierList; List: TListBox;
Filter: Boolean;
FilterIdents: TIdentifierList);
var i :Integer; //counter through all identifiers
Ident :TIdentifier; //each identifier
OtherIdent :TIdentifier; //identifiers in the other list
Index :Integer; //index of identifier
begin
List.Items.BeginUpdate; //begin updating the list
try
List.Clear; //clear the list
assert(not Filter or assigned(FilterIdents));
if assigned(Idents) then //list is not empty?
begin //don't filter same identifiers or
if not Filter or FilterIdents.IsEmpty then //no other available?
for i := 0 to Idents.Count - 1 do //add all identifiers
List.Items.AddObject(Idents[i].Name, Idents[i])
else
for i := 0 to Idents.Count - 1 do //for each identifier
begin
Ident := Idents[i]; //get it
Index := 0;
repeat
//search other list for the same identifier
OtherIdent := FilterIdents.GetIdentByNameList(Ident.Name, Index);
until not assigned(OtherIdent) or
Ident.CompareWith(OtherIdent, '', IgnoreStringList);
if not assigned(OtherIdent) then //no equal identifier found?
List.Items.AddObject(Ident.Name, Ident); //add identifier to the list
end;
end;
finally
List.Items.EndUpdate; //end updating the list
end;
end;
{Called when the form is about to be closed.
~param Sender the sender of the event, the form
~param Action out: if and how the form should be closed }
procedure TFormComparison.FormClose(Sender: TObject; var Action: TCloseAction);
var Settings :TComparisonFormSettings; //to save settings of form
begin
//get object to save the settings in
Settings := TComparisonFormSettings(TComparisonFormSettings.
GetSettings(ClassName));
if assigned(Settings) then
Settings.ReadValues(Self); //save current settings
end;
{Called when the user starts to drag a splitter to resize some components.
~param Sender the sender of the event, one of the panels used as a splitter
~param Button the pressed mouse button
~param Shift state of special modifying keys
~param X, Y position of the mouse }
procedure TFormComparison.PanelSplitterMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
TComponent(Sender).Tag := Y; //save position of click
end;
{Called when the form is resized.
~param Sender the sender of the event, the form }
procedure TFormComparison.FormResize(Sender: TObject);
begin //adjust heights of some components
ListBoxMessages.Height := Max(0, Min(ClientHeight -
PanelSplitterMessages.Height - 125,
ListBoxMessages.Height));
end;
{Called when the user drags the splitter to resize the list of messages of the
comparison.
~param Sender the sender of the event, ~[link PanelSplitterMessages]
~param Shift state of special modifying keys
~param X, Y position of the mouse }
procedure TFormComparison.PanelSplitterMessagesMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if Mouse.Capture = PanelSplitterMessages //is currently dragged?
{$IFNDEF LINUX}
.Handle
{$ENDIF}
then
begin //adjust heights
ListBoxMessages.Height := Max(0, Min(ClientHeight -
PanelSplitterMessages.Height - 125,
ListBoxMessages.Height -
(Y - PanelSplitterMessages.Tag)));
if PanelSplitterMessages.Top > ListBoxMessages.Top then
PanelSplitterMessages.Top := ListBoxMessages.Top - 1;
end;
end;
{Called when the panel of all lists is resized.
~param Sender the sender of the event, ~[link PanelAllData] }
procedure TFormComparison.PanelAllDataResize(Sender: TObject);
begin
PanelIdentifiersAndMembers.Height :=
Max(82, Min(PanelAllData.Height -
PanelSplitterFiles.Height - 39,
PanelIdentifiersAndMembers.Height));
end;
{Called when the user drags the splitter to resize the lists of the files.
~param Sender the sender of the event, ~[link PanelSplitterFiles]
~param Shift state of special modifying keys
~param X, Y position of the mouse }
procedure TFormComparison.PanelSplitterFilesMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if Mouse.Capture = PanelSplitterFiles //is currently dragged?
{$IFNDEF LINUX}
.Handle
{$ENDIF}
then
begin //adjust heights
PanelIdentifiersAndMembers.Height :=
Max(82, Min(PanelAllData.Height -
PanelSplitterFiles.Height - 39,
PanelIdentifiersAndMembers.Height -
(Y - PanelSplitterFiles.Tag)));
if PanelSplitterFiles.Top > PanelIdentifiersAndMembers.Top then
PanelSplitterFiles.Top := PanelIdentifiersAndMembers.Top - 1;
end;
end;
{Called when the panel of all lists of identifiers is resized.
~param Sender the sender of the event, ~[link PanelIdentifiersAndMembers] }
procedure TFormComparison.PanelIdentifiersAndMembersResize(Sender: TObject);
begin
PanelMembers.Height := Max(39, Min(PanelIdentifiersAndMembers.Height -
PanelSplitterIdentifiers.Height - 39,
PanelMembers.Height));
end;
{Called when the user drags the splitter to resize the lists of identifiers.
~param Sender the sender of the event, ~[link PanelSplitterIdentifiers]
~param Shift state of special modifying keys
~param X, Y position of the mouse }
procedure TFormComparison.PanelSplitterIdentifiersMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if Mouse.Capture = PanelSplitterIdentifiers //is currently dragged?
{$IFNDEF LINUX}
.Handle
{$ENDIF}
then
begin //adjust heights
PanelMembers.Height := Max(39, Min(PanelIdentifiersAndMembers.Height -
PanelSplitterIdentifiers.Height - 39,
PanelMembers.Height -
(Y - PanelSplitterIdentifiers.Tag)));
if PanelSplitterIdentifiers.Top > PanelMembers.Top then
PanelSplitterIdentifiers.Top := PanelMembers.Top - 1;
end;
end;
{Called when the panel of the lists of files is resized.
~param Sender the sender of the event, ~[link PanelFiles] }
procedure TFormComparison.PanelFilesResize(Sender: TObject);
begin //adjust sizes and positions of contained components
ListBoxFiles1.Width := (PanelFiles.Width -
CheckBoxAutoFiles.Width - 20) div 2;
ListBoxFiles2.Width := ListBoxFiles1.Width;
CheckBoxAutoFiles.Left := ListBoxFiles1.Width + 10;
CheckBoxFilterFiles.Left := CheckBoxAutoFiles.Left;
ListBoxFiles2.Left := CheckBoxAutoFiles.Left + CheckBoxAutoFiles.Width + 5;
ListBoxFiles1.Height := PanelFiles.Height;
ListBoxFiles2.Height := PanelFiles.Height;
end;
{Called when the panel of the lists of identifiers in files is resized.
~param Sender the sender of the event, ~[link PanelIdentifiers] }
procedure TFormComparison.PanelIdentifiersResize(Sender: TObject);
begin //adjust sizes and positions of contained components
ListBoxIdentifiers1.Width := (PanelIdentifiers.Width -
CheckBoxAutoIdentifiers.Width - 20) div 2;
ListBoxIdentifiers2.Width := ListBoxIdentifiers1.Width;
CheckBoxAutoIdentifiers.Left := ListBoxIdentifiers1.Width + 10;
CheckBoxFilterIdentifiers.Left := CheckBoxAutoIdentifiers.Left;
ListBoxIdentifiers2.Left := CheckBoxAutoIdentifiers.Left +
CheckBoxAutoIdentifiers.Width + 5;
ListBoxIdentifiers1.Height := PanelIdentifiers.Height;
ListBoxIdentifiers2.Height := PanelIdentifiers.Height;
end;
{Called when the panel of the lists of members is resized.
~param Sender the sender of the event, ~[link PanelMembers] }
procedure TFormComparison.PanelMembersResize(Sender: TObject);
begin //adjust sizes and positions of contained components
ListBoxMembers1.Width := (PanelMembers.Width -
CheckBoxAutoMembers.Width - 20) div 2;
ListBoxMembers2.Width := ListBoxMembers1.Width;
CheckBoxAutoMembers.Left := ListBoxMembers1.Width + 10;
CheckBoxFilterMembers.Left := CheckBoxAutoMembers.Left;
ListBoxMembers2.Left := CheckBoxAutoMembers.Left +
CheckBoxAutoMembers.Width + 5;
ListBoxMembers1.Height := PanelMembers.Height;
ListBoxMembers2.Height := PanelMembers.Height;
end;
{Called when the user selects a file in one of the two lists.
~param Sender the sender of the event,
~[link ListBoxFiles1] or ~[link ListBoxFiles2] }
procedure TFormComparison.ListBoxFilesClick(Sender: TObject);
var List, Other :TListBox; //clicked list box and the other one
SubList :TListBox; //list box for its identifiers
OtherSubList :TListBox; //list for identifiers of other file
TheFile :TPascalFile; //the clicked file
OtherFile :TIdentifierList; //identifiers of the equal file
OtherIndex :Integer; //index of the equal file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -