OSDN Git Service

Move and Delete methods are rewritten
authornaru <bottle@mikage.to>
Sat, 30 Aug 2003 02:37:11 +0000 (02:37 +0000)
committernaru <bottle@mikage.to>
Sat, 30 Aug 2003 02:37:11 +0000 (02:37 +0000)
bottleclient/BottleChainListFrame.pas

index 9146b78..83c191c 100755 (executable)
@@ -32,6 +32,7 @@ type
     procedure ExecuteEditRule(Rule: TBottleChainRule);
   public
     { Public \90é\8c¾ }
+    procedure UpdateCheckBox;
     procedure UpdateDisplay;
   end;
 
@@ -139,12 +140,16 @@ begin
 end;
 
 procedure TfrmBottleChainList.btnDeleteClick(Sender: TObject);
-var Del: TBottleChainRule;
+var
+  Del: TBottleChainRule;
+  Index: integer;
 begin
-  if lstRules.ItemIndex < 0 then Exit;
-  Del := BottleChainRuleList[lstRules.ItemIndex];
+  Index := lstRules.ItemIndex;
+  if Index < 0 then
+    Exit;
+  Del := BottleChainRuleList[Index];
   Del.Free;
-  UpdateDisplay; 
+  lstRules.Items.Delete(Index);
 end;
 
 procedure TfrmBottleChainList.btnUpClick(Sender: TObject);
@@ -153,8 +158,8 @@ begin
   i := lstRules.ItemIndex;
   if i > 0 then begin
     BottleChainRuleList.List.Move(i, i - 1);
+    lstRules.Items.Move(i, i-1);
     lstRules.ItemIndex := i - 1;
-    UpdateDisplay;
   end;
 end;
 
@@ -164,8 +169,8 @@ begin
   i := lstRules.ItemIndex;
   if (i >= 0) and (i < lstRules.Items.Count-1) then begin
     BottleChainRuleList.List.Move(i, i + 1);
+    lstRules.Items.Move(i, i+1);
     lstRules.ItemIndex := i + 1;
-    UpdateDisplay;
   end;
 end;
 
@@ -191,8 +196,17 @@ begin
     New := TBottleChainRule.Create(BottleChainRuleList);
     New.Assign(BottleChainRuleList.Rules[lstRules.ItemIndex]);
     New.RuleList := BottleChainRuleList;
-    UpdateDisplay;
+    lstRules.Items.Insert(lstRules.ItemIndex + 1, New.StringExpression);
+    UpdateCheckBox;
   end;
 end;
 
+procedure TfrmBottleChainList.UpdateCheckBox;
+var
+  i: integer;
+begin
+  for i := 0 to BottleChainRuleList.Count-1 do
+    lstRules.Checked[i] := BottleChainRuleList[i].Enabled;
+end;
+
 end.