📄 umfkeepselectdata.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 UMFKeepSelectData;
{Contains a page to manage the kept parsed data. }
interface
uses Classes, Forms, Controls, StdCtrls, ExtCtrls,
UMainFormFrame,
UJADDState;
type
{A page to manage the kept parsed data. }
TMFKeepSelectData = class(TMainFormFrame)
ListBox: TListBox;
ButtonKeepCurrentParsedData: TButton;
ButtonMakeCurrentParsedData: TButton;
ButtonUnKeepParsedData: TButton;
procedure ButtonKeepCurrentParsedDataClick(Sender: TObject);
procedure ButtonMakeCurrentParsedDataClick(Sender: TObject);
procedure ButtonUnKeepParsedDataClick(Sender: TObject);
procedure ListBoxClick(Sender: TObject);
private
//Updates the list of kept parsed data and the state of the buttons.
procedure UpdateAll;
protected
//Called when the list of parsed file changes.
procedure StateFileListChanged(State: TJADDState); override;
public
end;
implementation
{$R *.dfm}
uses SysUtils,
Dialogs,
UBaseIdents;
{Called when the list of parsed file changes.
~param State the state that has been changed }
procedure TMFKeepSelectData.StateFileListChanged(State: TJADDState);
begin
UpdateAll; //show kept files, update buttons
end;
{Updates the list of kept parsed data and the state of the buttons. }
procedure TMFKeepSelectData.UpdateAll;
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 Files.Count <> 1 then //generate a caption for it
Caption := Format('%d Files', [Files.Count])
else
Caption := 'One File';
if i = State.CurrentDataKeptIndex then
Caption := Caption + ' (current)';
ListBox.Items.Append(Caption); //and add it
end;
ListBox.ItemIndex := State.CurrentDataKeptIndex; //mark the current data
//update the states of the buttons
ButtonKeepCurrentParsedData.Enabled := assigned(State.FileList) and
State.CompletelyParsed and
(State.CurrentDataKeptIndex = -1);
ListBoxClick(ListBox);
end;
{Called when the button to keep the current parsed data is clicked.
~param Sender the sender of the event, ~[link ButtonKeepCurrentParsedData] }
procedure TMFKeepSelectData.ButtonKeepCurrentParsedDataClick(Sender: TObject);
begin
State.KeepCurrentData; //keep the current parsed data
UpdateAll; //and update the list
end;
{Called when the button to select kept parsed data is clicked or the list of
parsed data is double clicked.
~param Sender the sender of the event, ~[link ButtonMakeCurrentParsedData] or
~[link ListBox] }
procedure TMFKeepSelectData.ButtonMakeCurrentParsedDataClick(Sender: TObject);
var Cancel :Boolean; //if the selecting should be aborted
begin
//valid and other then the current parsed data selected?
if (ListBox.ItemIndex <> -1) and
(ListBox.ItemIndex <> State.CurrentDataKeptIndex) then
begin
Cancel := False; //assume don't abort
//current parsed data not kept so far and complete?
if assigned(State.FileList) and State.CompletelyParsed and
(State.CurrentDataKeptIndex = -1) then
//get confirmation from the user
case MessageDlg('Do you want to keep the current parsed data?',
mtConfirmation, [mbYes, mbNo, mbCancel],
ButtonMakeCurrentParsedData.HelpContext) of
mrYes: State.KeepCurrentData; //keep the current parsed data
mrNo: ;
else
Cancel := True; //abort the selecting
end;
if not Cancel then //selecting hasn't been aborted?
begin
State.SelectParsedData(ListBox.ItemIndex); //select the data
UpdateAll; //and update the list
end;
end;
end;
{Called when the button to free kept parsed data is clicked.
~param Sender the sender of the event, ~[link ButtonUnKeepParsedData] }
procedure TMFKeepSelectData.ButtonUnKeepParsedDataClick(Sender: TObject);
begin
if ListBox.ItemIndex <> -1 then //some parsed data selected?
begin
State.DoNotKeepParsedData(ListBox.ItemIndex); //un-keep it
UpdateAll; //update the list
end;
end;
{Called when another kept parsed data is selected in the list.
~param Sender the sender of the event, ~[link ListBox] }
procedure TMFKeepSelectData.ListBoxClick(Sender: TObject);
begin //update the state of the buttons
ButtonMakeCurrentParsedData.Enabled := (ListBox.ItemIndex <> -1) and
(State.CurrentDataKeptIndex <>
ListBox.ItemIndex);
ButtonUnKeepParsedData.Enabled := ListBox.ItemIndex <> -1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -