OSDN Git Service

ログの多彩な条件での検索機能を、ひととおり実装。
[winbottle/winbottle.git] / bottleclient / SearchLog.pas
index 55d61c1..73c6e96 100644 (file)
@@ -35,13 +35,14 @@ type
     procedure SetSearchLogRange(const Value: TSearchLogRange);
   public
     procedure Assign(Source: TPersistent); override;
+    function IsInvalidCondition: boolean;
   published
     property ScriptPattern: String read FScriptPattern write SetScriptPattern;
     property ScriptRegExp: boolean read FScriptRegExp write SetScriptRegExp;
     property Channel: String read FChannel write SetChannel;
     property Ghost: String read FGhost write SetGhost;
-    property MinLength: integer read FMinLength write SetMinLength;
-    property MaxLength: integer read FMaxLength write SetMaxLength;
+    property MinLength: integer read FMinLength write SetMinLength; //\96¢\8eÀ\91\95
+    property MaxLength: integer read FMaxLength write SetMaxLength; //\96¢\8eÀ\91\95
     property MinVote: integer read FMinVote write SetMinVote;
     property MinAgree: integer read FMinAgree write SetMinAgree;
     property SearchLogRange: TSearchLogRange read FSearchLogRange write SetSearchLogRange;
@@ -59,11 +60,13 @@ type
     cbxScriptRegExp: TCheckBox;
     cbxGhost: TComboBox;
     cbxChannel: TComboBox;
-    rgpTarget: TRadioGroup;
+    rgpSearchLogRange: TRadioGroup;
     lblMinVote: TLabel;
     lblMinAgree: TLabel;
     spnMinVote: TSpinEdit;
     spnMinAgree: TSpinEdit;
+    lblMinVote2: TLabel;
+    lblMinAgree2: TLabel;
     procedure btnOkClick(Sender: TObject);
     procedure btnCancelClick(Sender: TObject);
   private
@@ -112,6 +115,20 @@ begin
   end;
 end;
 
+function TSearchCond.IsInvalidCondition: boolean;
+begin
+  // \8bó\82Á\82Û\82Ì\8fð\8c\8f\82Å\82Í\82È\82¢\82±\82Æ\82ð\83`\83F\83b\83N
+  Result := true;
+  if ScriptPattern <> '' then
+    Result := false;
+  if (Channel <> '') or (Ghost <> '') then
+    Result := false;
+  if (MinVote > 0) or (MinAgree > 0) then
+    Result := false;
+  { if (MinLength > 0) or (MaxLength > 0) then
+    Result := false; }
+end;
+
 procedure TSearchCond.SetChannel(const Value: String);
 begin
   FChannel := Value;
@@ -155,25 +172,29 @@ end;
 { TTfrmSearchLog }
 
 function TfrmSearchLog.Execute: boolean;
+var
+  Backup: TSearchCond;
 begin
-  with Condition do
-  begin
-    edtScriptPattern.Text := ScriptPattern;
-    cbxChannel.Text   := Channel;
-    cbxGhost.Text     := Ghost;
-    spnMinVote.Value  := MinVote;
-    spnMinAgree.Value := MinAgree;
-  end;
-  Result := ShowModal = mrOk;
-  if not Result then
-    Exit;
-  with Condition do
-  begin
-    ScriptPattern := edtScriptPattern.Text;
-    Channel  := cbxChannel.Text;
-    Ghost    := cbxGhost.Text;
-    MinVote  := spnMinVote.Value;
-    MinAgree := spnMinAgree.Value;
+  // \83L\83\83\83\93\83Z\83\8b\8e\9e\82É\90Ý\92è\82ª\95Ï\82í\82ç\82È\82¢\82æ\82¤\82É\83o\83b\83N\83A\83b\83v
+  Backup := TSearchCond.Create(nil);
+  try
+    Backup.Assign(Condition);
+    with Condition do
+    begin
+      edtScriptPattern.Text   := ScriptPattern;
+      cbxScriptRegExp.Checked := ScriptRegExp;
+      cbxChannel.Text   := Channel;
+      cbxGhost.Text     := Ghost;
+      spnMinVote.Value  := MinVote;
+      spnMinAgree.Value := MinAgree;
+      rgpSearchLogRange.ItemIndex := Ord(SearchLogRange);
+    end;
+    Result := ShowModal = mrOk;
+    // \83L\83\83\83\93\83Z\83\8b\8e\9e\82É\82Í\90Ý\92è\82ð\8c³\82É\96ß\82·
+    if not Result then
+      Condition.Assign(Backup);
+  finally
+    Backup.Free;
   end;
 end;
 
@@ -185,7 +206,20 @@ end;
 procedure TfrmSearchLog.btnOkClick(Sender: TObject);
 begin
   // \8c\8b\89ÊOK\82Å\83E\83B\83\93\83h\83E\82ð\95Â\82\82é
-  ModalResult := mrOk;
+  with Condition do
+  begin
+    ScriptPattern := edtScriptPattern.Text;
+    ScriptRegExp  := cbxScriptRegExp.Checked;
+    Channel  := cbxChannel.Text;
+    Ghost    := cbxGhost.Text;
+    MinVote  := spnMinVote.Value;
+    MinAgree := spnMinAgree.Value;
+    SearchLogRange := TSearchLogRange(rgpSearchLogRange.ItemIndex);
+  end;
+  if Condition.IsInvalidCondition then
+    ShowMessage('\8fð\8c\8f\82ð\8ew\92è\82µ\82Ä\82­\82¾\82³\82¢')
+  else
+    ModalResult := mrOk;
 end;
 
 procedure TfrmSearchLog.btnCancelClick(Sender: TObject);