📄 umfcompare.pas
字号:
{ JADD - Just Another DelphiDoc: Documentation from Delphi Source Code
Copyright (C) 2002-2008 Gerold Veith
This file is part of JADD - Just Another DelphiDoc.
DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit UMFCompare;
{Contains a page to compare the current parsed data with kept parsed data. }
interface
uses Classes, Forms, Controls, StdCtrls, ExtCtrls,
UMainFormFrame,
UJADDState;
type
{A page to compare the current parsed data with kept parsed data. }
TMFCompare = class(TMainFormFrame)
ListBox: TListBox;
ButtonCompareParsedDatas: TButton;
procedure ListBoxClick(Sender: TObject);
procedure ButtonCompareParsedDatasClick(Sender: TObject);
private
protected
//Called when the list of parsed file changes.
procedure StateFileListChanged(State: TJADDState); override;
public
end;
implementation
{$R *.dfm}
uses SysUtils,
UBaseIdents,
UComparison;
{Called when the list of parsed file changes.
~param State the state that has been changed }
procedure TMFCompare.StateFileListChanged(State: TJADDState);
var i :Integer; //counter through kept parsed data
Files :TFileList; //each kept parsed dat
Caption :String; //caption for each kept parsed data
begin
ListBox.Clear; //clear the list
for i := 0 to State.KeptDataCount - 1 do //show all kept parsed data
begin
Files := State.KeptDatas[i]; //get each kept parsed data
if i <> State.CurrentDataKeptIndex then //not the current parsed data?
begin
if Files.Count <> 1 then //generate a caption for it
Caption := Format('%d Files', [Files.Count])
else
Caption := 'One File';
ListBox.Items.Append(Caption); //and add it
end;
end;
//by default nothing selected to compare with
ButtonCompareParsedDatas.Enabled := False;
if ListBox.Items.Count <> 0 then //some parsed data kept?
ListBox.ItemIndex := 0; //select the first data
ListBoxClick(ListBox); //and update the button
end;
{Called when one of the parsed data sets in the list of kept data is selected.
~param Sender the sender of the event, ~[link ListBox] }
procedure TMFCompare.ListBoxClick(Sender: TObject);
begin
//enable button only if current data is valid and kept data selected
ButtonCompareParsedDatas.Enabled := (ListBox.ItemIndex <> -1) and
assigned(State.FileList) and
State.CompletelyParsed and
(State.FileList.Count <> 0);
end;
{Called when the button to compare kept parsed data with the current data is
clicked.
~param Sender the sender of the event, ~[link ButtonCompareParsedDatas] }
procedure TMFCompare.ButtonCompareParsedDatasClick(Sender: TObject);
var Index :Integer; //index of the other data
Other :TFileList; //the other selected list of parsed files
begin
//currently some valid parsed data and other parsed data selected?
if assigned(State.FileList) and State.CompletelyParsed and
(State.FileList.Count <> 0) and (ListBox.ItemIndex <> -1) then
begin
Index := ListBox.ItemIndex; //get index of selected data
if (State.CurrentDataKeptIndex <> -1) and //after current data?
(Index >= State.CurrentDataKeptIndex) then
inc(Index); //skip current data
//get the selected other data
Other := State.GetKeptData(Index);
if Other.Count <> 0 then //other data not empty?
MakeComparision(State.FileList, Other); //compare both sets of parsed data
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -