Ignore:
Timestamp:
Nov 29, 2017, 2:03:17 PM (7 years ago)
Author:
chronos
Message:
  • Added: New rule item type "Terminal range" to hold interval of characters.
  • Fixed: Removel of selected items in a list was not working correctly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/generator/Forms/UFormRuleItems.pas

    r119 r122  
    2222    ComboBox1: TComboBox;
    2323    Label1: TLabel;
    24     ListView: TListView;
     24    ListView1: TListView;
    2525    MenuItem1: TMenuItem;
    2626    MenuItem2: TMenuItem;
     
    4242    procedure FormCreate(Sender: TObject);
    4343    procedure FormShow(Sender: TObject);
    44     procedure ListViewData(Sender: TObject; Item: TListItem);
    45     procedure ListViewDblClick(Sender: TObject);
    46     procedure ListViewKeyPress(Sender: TObject; var Key: char);
    47     procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
     44    procedure ListView1Data(Sender: TObject; Item: TListItem);
     45    procedure ListView1DblClick(Sender: TObject);
     46    procedure ListView1KeyPress(Sender: TObject; var Key: char);
     47    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
    4848      Selected: Boolean);
    4949  private
     
    6868{ TFormRuleItems }
    6969
    70 procedure TFormRuleItems.ListViewData(Sender: TObject; Item: TListItem);
     70procedure TFormRuleItems.ListView1Data(Sender: TObject; Item: TListItem);
    7171begin
    7272  if (Item.Index >= 0) and (Item.Index < RuleItems.Count) then begin
     
    9797  RuleItem: TRuleItem;
    9898begin
    99   if Assigned(ListView.Selected) then begin
    100     RuleItem := TRuleItem(ListView.Selected.Data);
     99  if Assigned(ListView1.Selected) then begin
     100    RuleItem := TRuleItem(ListView1.Selected.Data);
    101101    FormRuleItem := TFormRuleItem.Create(nil);
    102102    FormRuleItem.LoadData(RuleItem);
     
    111111procedure TFormRuleItems.AMoveDownExecute(Sender: TObject);
    112112begin
    113   RuleItems.ParentRule.Items.Move(ListView.Selected.Index, ListView.Selected.Index + 1);
    114   ListView.ItemIndex := ListView.Selected.Index + 1;
     113  RuleItems.ParentRule.Items.Move(ListView1.Selected.Index, ListView1.Selected.Index + 1);
     114  ListView1.ItemIndex := ListView1.Selected.Index + 1;
    115115  ReloadList;
    116116end;
     
    118118procedure TFormRuleItems.AMoveUpExecute(Sender: TObject);
    119119begin
    120   RuleItems.ParentRule.Items.Move(ListView.Selected.Index, ListView.Selected.Index - 1);
    121   ListView.ItemIndex := ListView.Selected.Index - 1;
     120  RuleItems.ParentRule.Items.Move(ListView1.Selected.Index, ListView1.Selected.Index - 1);
     121  ListView1.ItemIndex := ListView1.Selected.Index - 1;
    122122  ReloadList;
    123123end;
     
    125125procedure TFormRuleItems.ARemoveExecute(Sender: TObject);
    126126var
    127   Item: TListItem;
     127  I: Integer;
    128128begin
    129   for Item in ListView.Items do
    130   if Item.Selected then
    131     RuleItems.ParentRule.Items.Remove(TRuleItem(Item.Data));
     129  if MessageDlg('Remove item(s)', 'Do you want to remove selected item(s)?',
     130    mtConfirmation, mbYesNo, 0) = mrYes then
     131  for I := ListView1.Items.Count - 1 downto 0 do
     132  if ListView1.Items[I].Selected then
     133    RuleItems.ParentRule.Items.Remove(TRuleItem(ListView1.Items[I].Data));
    132134  ReloadList;
    133135end;
     
    144146end;
    145147
    146 procedure TFormRuleItems.ListViewDblClick(Sender: TObject);
     148procedure TFormRuleItems.ListView1DblClick(Sender: TObject);
    147149begin
    148150  AModify.Execute;
    149151end;
    150152
    151 procedure TFormRuleItems.ListViewKeyPress(Sender: TObject; var Key: char);
     153procedure TFormRuleItems.ListView1KeyPress(Sender: TObject; var Key: char);
    152154begin
    153155  if Key = #13 then AModify.Execute;
    154156end;
    155157
    156 procedure TFormRuleItems.ListViewSelectItem(Sender: TObject; Item: TListItem;
     158procedure TFormRuleItems.ListView1SelectItem(Sender: TObject; Item: TListItem;
    157159  Selected: Boolean);
    158160begin
     
    162164procedure TFormRuleItems.UpdateInterface;
    163165begin
    164   AModify.Enabled := Assigned(ListView.Selected);
    165   ARemove.Enabled := Assigned(ListView.Selected);
    166   AMoveUp.Enabled := Assigned(ListView.Selected) and (ListView.Selected.Index > 0);
    167   AMoveDown.Enabled := Assigned(ListView.Selected) and (ListView.Selected.Index < (ListView.Items.Count - 1));
     166  AModify.Enabled := Assigned(ListView1.Selected);
     167  ARemove.Enabled := Assigned(ListView1.Selected);
     168  AMoveUp.Enabled := Assigned(ListView1.Selected) and (ListView1.Selected.Index > 0);
     169  AMoveDown.Enabled := Assigned(ListView1.Selected) and (ListView1.Selected.Index < (ListView1.Items.Count - 1));
    168170end;
    169171
    170172procedure TFormRuleItems.ReloadList;
    171173begin
    172   if Assigned(RuleItems) then ListView.Items.Count := RuleItems.Count
    173     else ListView.Items.Count := 0;
    174   ListView.Refresh;
     174  if Assigned(RuleItems) then ListView1.Items.Count := RuleItems.Count
     175    else ListView1.Items.Count := 0;
     176  ListView1.Refresh;
    175177end;
    176178
Note: See TracChangeset for help on using the changeset viewer.