Changeset 122 for branches/generator/Forms/UFormRuleItems.pas
- Timestamp:
- Nov 29, 2017, 2:03:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormRuleItems.pas
r119 r122 22 22 ComboBox1: TComboBox; 23 23 Label1: TLabel; 24 ListView : TListView;24 ListView1: TListView; 25 25 MenuItem1: TMenuItem; 26 26 MenuItem2: TMenuItem; … … 42 42 procedure FormCreate(Sender: TObject); 43 43 procedure FormShow(Sender: TObject); 44 procedure ListView Data(Sender: TObject; Item: TListItem);45 procedure ListView DblClick(Sender: TObject);46 procedure ListView KeyPress(Sender: TObject; var Key: char);47 procedure ListView SelectItem(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; 48 48 Selected: Boolean); 49 49 private … … 68 68 { TFormRuleItems } 69 69 70 procedure TFormRuleItems.ListView Data(Sender: TObject; Item: TListItem);70 procedure TFormRuleItems.ListView1Data(Sender: TObject; Item: TListItem); 71 71 begin 72 72 if (Item.Index >= 0) and (Item.Index < RuleItems.Count) then begin … … 97 97 RuleItem: TRuleItem; 98 98 begin 99 if Assigned(ListView .Selected) then begin100 RuleItem := TRuleItem(ListView .Selected.Data);99 if Assigned(ListView1.Selected) then begin 100 RuleItem := TRuleItem(ListView1.Selected.Data); 101 101 FormRuleItem := TFormRuleItem.Create(nil); 102 102 FormRuleItem.LoadData(RuleItem); … … 111 111 procedure TFormRuleItems.AMoveDownExecute(Sender: TObject); 112 112 begin 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; 115 115 ReloadList; 116 116 end; … … 118 118 procedure TFormRuleItems.AMoveUpExecute(Sender: TObject); 119 119 begin 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; 122 122 ReloadList; 123 123 end; … … 125 125 procedure TFormRuleItems.ARemoveExecute(Sender: TObject); 126 126 var 127 I tem: TListItem;127 I: Integer; 128 128 begin 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)); 132 134 ReloadList; 133 135 end; … … 144 146 end; 145 147 146 procedure TFormRuleItems.ListView DblClick(Sender: TObject);148 procedure TFormRuleItems.ListView1DblClick(Sender: TObject); 147 149 begin 148 150 AModify.Execute; 149 151 end; 150 152 151 procedure TFormRuleItems.ListView KeyPress(Sender: TObject; var Key: char);153 procedure TFormRuleItems.ListView1KeyPress(Sender: TObject; var Key: char); 152 154 begin 153 155 if Key = #13 then AModify.Execute; 154 156 end; 155 157 156 procedure TFormRuleItems.ListView SelectItem(Sender: TObject; Item: TListItem;158 procedure TFormRuleItems.ListView1SelectItem(Sender: TObject; Item: TListItem; 157 159 Selected: Boolean); 158 160 begin … … 162 164 procedure TFormRuleItems.UpdateInterface; 163 165 begin 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)); 168 170 end; 169 171 170 172 procedure TFormRuleItems.ReloadList; 171 173 begin 172 if Assigned(RuleItems) then ListView .Items.Count := RuleItems.Count173 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; 175 177 end; 176 178
Note:
See TracChangeset
for help on using the changeset viewer.