OSDN Git Service

リリース日修正
[gikonavigoeson/gikonavi.git] / Round.pas
index c977226..db3f95d 100644 (file)
--- a/Round.pas
+++ b/Round.pas
@@ -8,26 +8,26 @@ uses
 
 type
        TRoundDialog = class(TForm)
-    RoundPopupMenu: TPopupMenu;
-    C1: TMenuItem;
-    P1: TMenuItem;
+       RoundPopupMenu: TPopupMenu;
+       C1: TMenuItem;
+       P1: TMenuItem;
                N1: TMenuItem;
-    D1: TMenuItem;
+       D1: TMenuItem;
                ItemIcon16: TImageList;
-    Panel1: TPanel;
-    Label1: TLabel;
-    Label2: TLabel;
-    RoundNameComboBox: TComboBox;
-    Panel2: TPanel;
-    Panel3: TPanel;
-    AllSelectButton: TButton;
-    AllCancelButton: TButton;
-    RoundDeleteButton: TButton;
-    Panel4: TPanel;
-    Button1: TButton;
-    RoundButton: TButton;
-    StatusBar1: TStatusBar;
-    RoundListView: TListView;
+       Panel1: TPanel;
+       Label1: TLabel;
+       Label2: TLabel;
+       RoundNameComboBox: TComboBox;
+       Panel2: TPanel;
+       Panel3: TPanel;
+       AllSelectButton: TButton;
+       AllCancelButton: TButton;
+       RoundDeleteButton: TButton;
+       Panel4: TPanel;
+       Button1: TButton;
+       RoundButton: TButton;
+       StatusBar1: TStatusBar;
+       RoundListView: TListView;
                procedure RoundButtonClick(Sender: TObject);
                procedure FormCreate(Sender: TObject);
                procedure RoundListViewChange(Sender: TObject; Item: TListItem;
@@ -36,8 +36,16 @@ type
                procedure AllCancelButtonClick(Sender: TObject);
                procedure RoundNameComboBoxChange(Sender: TObject);
                procedure RoundDeleteButtonClick(Sender: TObject);
+    procedure RoundListViewColumnClick(Sender: TObject;
+      Column: TListColumn);
+    procedure RoundListViewCompare(Sender: TObject; Item1,
+      Item2: TListItem; Data: Integer; var Compare: Integer);
+    procedure RoundListViewColumnRightClick(Sender: TObject;
+      Column: TListColumn; Point: TPoint);
        private
                { Private \90é\8c¾ }
+               FColumnToSort: Integer;
+               FSortOrder:     Boolean;
                function GetRoundCount: Integer;
                procedure SetRoundItem(RoundName: string);
                function CompareTime(Time1: TDateTime; Time2: TDateTime; MarginMin: Integer): Boolean;
@@ -45,13 +53,11 @@ type
                { Public \90é\8c¾ }
        end;
 
-//var
-//     RoundDialog: TRoundDialog;
 
 implementation
 
 uses
-       Giko, BoardGroup, RoundData;
+       Giko, BoardGroup, RoundData, Math, GikoDataModule;
 
 {$R *.DFM}
 
@@ -65,30 +71,75 @@ var
        RoundItem: TRoundItem;
 begin
 {$IF Defined(FRCRND) }
-    Giko.GikoForm.LoginAction.Checked := true; // \93®\8dì\8e\8e\8c±\97p\93r
+       GikoDM.LoginAction.Checked := true; // \93®\8dì\8e\8e\8c±\97p\93r
 {$IFEND}
 
+{$IFNDEF LOOSENUP}     //\8f\84\89ñ\90§\8cÀ\82ð\8aÉ\82ß\82é\82±\82Æ\82É\82µ\82Ä\82½\82ç{$ELSE}\82Ì\95û\82ð\8eg\82¤
+       if not GikoDM.LoginAction.Checked then begin
+               if GikoSys.Setting.UserID <> '' then begin
+                       msg := '\83\8d\83O\83C\83\93\82µ\82È\82¢\82Æ\8f\84\89ñ\82Í\8fo\97\88\82Ü\82¹\82ñ' + #13#10
+                               + '\8d¡\83\8d\83O\83C\83\93\82µ\82Ü\82·\82©';
+                       if MsgBox(Handle, msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then begin
+                               Exit;
+                       end;
+                       GikoDM.LoginAction.Execute;
+               end;
+               if not GikoDM.LoginAction.Checked then begin
+                       msg := '\83\8d\83O\83C\83\93\82µ\82È\82¢\82Æ\8f\84\89ñ\82Í\8fo\97\88\82Ü\82¹\82ñ';
+                       MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+                       Exit;
+               end;
+       end;
+{$ELSE}
+       //\8bK\90§\82ð\8aÉ\82ß\82½\82Ù\82¤\82Í\81A\83X\83\8c\88ê\97\97\82Ì\82Ý\8f\84\89ñ\89Â\94\
+       if not GikoDM.LoginAction.Checked then begin
+               if GikoSys.Setting.UserID <> '' then begin
+                       msg := '\83\8d\83O\83C\83\93\82µ\82È\82¢\82Æ\83X\83\8c\83b\83h\82Ì\8f\84\89ñ\82Í\8fo\97\88\82Ü\82¹\82ñ' + #13#10
+                               + '\8d¡\83\8d\83O\83C\83\93\82µ\82Ü\82·\82©';
+                       if MsgBox(Handle, msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then begin
+                               Exit;
+                       end;
+                       GikoDM.LoginAction.Execute;
+               end;
+       end;
+       //\81\9c\82È\82µ\8f\84\89ñ\82Í15\95ª\88È\8fã\82Ì\8aÔ\8au\82ð\95K\97v\82Æ\82·\82é
+       if not GikoDM.LoginAction.Checked then begin
+               if CompareTime(GikoForm.LastRoundTime, Now, 30) then begin
+                       msg := '\88ê\93x\8f\84\89ñ\82·\82é\82Æ\82R\82O\95ª\8aÔ\8f\84\89ñ\82Í\8fo\97\88\82Ü\82¹\82ñ';
+                       MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+                       Exit;
+               end;
+       end;
+{$ENDIF}
+
+       //\88ê\82Â\82à\8f\84\89ñ\82É\90Ý\92è\82µ\82Ä\82¢\82È\82©\82Á\82½\82ç\83G\83\89\81[\82É\82·\82é
        cnt := GetRoundCount;
-       if not Giko.GikoForm.LoginAction.Checked then begin
-                if CompareTime(GikoForm.LastRoundTime, Now, 30) then begin
-                       msg := '\88ê\93x\8f\84\89ñ\82·\82é\82Æ\82P\82T\95ª\8aÔ\8f\84\89ñ\82Í\8fo\97\88\82Ü\82¹\82ñ';
-                       MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
-                       Exit;
-               end;
-               if cnt > 100 then begin
-                       msg := '\82P\82O\82O\8cÂ\88È\8fã\82Í\88ê\93x\82É\8f\84\89ñ\82Å\82«\82Ü\82¹\82ñ';
-                       MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
-                       Exit;
-               end;
+       if cnt = 0 then begin
+               msg := '\8f\84\89ñ\82µ\82½\82¢\8d\80\96Ú\82É\82P\82Â\88È\8fã\83`\83F\83b\83N\82ð\93ü\82ê\82Ä\82­\82¾\82³\82¢';
+               MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+               Exit;
        end;
 
+{$IFNDEF LOOSENUP}
+       //\81\9c\82È\82µ\8f\84\89ñ\82Í\82P\93x\82É100\8cÂ\82Ü\82Å\82É\82·\82é
+       if not GikoDM.LoginAction.Checked then begin
+               if cnt > 100 then begin
+                       msg := '\82P\82O\82O\8cÂ\88È\8fã\82Í\88ê\93x\82É\8f\84\89ñ\82Å\82«\82Ü\82¹\82ñ';
+                       MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+                       Exit;
+               end;
+       end;
+{$ENDIF}
+
+       //\8f\84\89ñ\82É\93o\98^\82³\82ê\82Ä\82¢\82é\94Â\82Ì\90\94\82¾\82¯\82Ü\82í\82·
        for i := 0 to RoundList.Count[grtBoard] - 1 do begin
                RoundItem := RoundList.Items[i, grtBoard];
+               //\8f\84\89ñ\82Ì\83`\83F\83b\83N\82ª\82Â\82¢\82Ä\82¢\82È\82¯\82ê\82Î\83X\83\8b\81[
                if not RoundItem.BoolData then Continue;
-               if not Giko.GikoForm.LoginAction.Checked then Exit;
+               //\8am\8eÀ\82É\94Â\82Ì\82Í\82¸\82¾\82¯\82Ç\83`\83F\83b\83N
                if RoundItem.RoundType = grtBoard then begin
                        Board := TBoard( RoundItem.Item );
-                       //Board := BBSsFindBoardFromURL(RoundItem.URL);
+                       //Board\82Ì\83I\83u\83W\83F\83N\83g\82ª\91\8dÝ\82·\82ê\82Î\81ADL\82·\82é
                        if Board <> nil then begin
                                if not Board.IsThreadDatRead then
                                        GikoSys.ReadSubjectFile(Board);
@@ -98,13 +149,19 @@ begin
        end;
        for i := 0 to RoundList.Count[grtItem] - 1 do begin
                RoundItem := RoundList.Items[i, grtItem];
+               //\8f\84\89ñ\82Ì\83`\83F\83b\83N\82ª\82Â\82¢\82Ä\82¢\82È\82¯\82ê\82Î\83X\83\8b\81[
                if not RoundItem.BoolData then Continue;
-               if not Giko.GikoForm.LoginAction.Checked then Exit;
-       if RoundItem.RoundType = grtItem then begin
-               ThreadItem := TThreadItem( RoundItem.Item );
-               //ThreadItem := BBSsFindThreadFromURL(RoundItem.URL);
+{$IFDEF LOOSENUP}
+               //\81\9c\82È\82µ\8f\84\89ñ\82Í\83X\83\8c\83b\83h\82Í\82Å\82«\82È\82¢\82±\82Æ\82É\82·\82é
+               if not GikoDM.LoginAction.Checked then begin
+                       msg := '\83\8d\83O\83C\83\93\82µ\82È\82¢\82Æ\83X\83\8c\83b\83h\82Ì\8f\84\89ñ\82Í\82Å\82«\82Ü\82¹\82ñ\81B';
+                       MsgBox(Handle, msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+                       break;
+               end;
+{$ENDIF}
+               if RoundItem.RoundType = grtItem then begin
+                       ThreadItem := TThreadItem( RoundItem.Item );
                        if ThreadItem <> nil then begin
-//                             GikoForm.AddMessageList('debug2:' + IntToStr(i), nil);
                                GikoForm.DownloadContent(ThreadItem);
                        end;
                end;
@@ -145,6 +202,8 @@ procedure TRoundDialog.FormCreate(Sender: TObject);
 var
        i: Integer;
 begin
+       //\8c»\8dÝ\82Ì\8f\84\89ñ\83f\81[\83^\82ð\83t\83@\83C\83\8b\83A\83E\83g\82·\82é
+       RoundList.SaveRoundFile;
        RoundNameComboBox.Items.Add('\81i\82·\82×\82Ä\81j');
        for i := 0 to RoundList.RoundNameList.Count - 1 do
                RoundNameComboBox.Items.Add(RoundList.RoundNameList[i]);
@@ -211,10 +270,15 @@ end;
 
 procedure TRoundDialog.RoundNameComboBoxChange(Sender: TObject);
 begin
+       //\83J\83\89\83\80\82Ì\83\\81[\83g\8bL\8d\86\83C\83\81\81[\83W\82ð\89ð\8f\9c\82·\82é
+       if FColumnToSort > -1 then
+               RoundListView.Column[FColumnToSort].ImageIndex := -1;
+       FColumnToSort := -1;
        if RoundNameComboBox.ItemIndex = 0 then
                SetRoundItem('')
        else
                SetRoundItem(RoundNameComboBox.Items[RoundNameComboBox.itemIndex]);
+
 end;
 
 procedure TRoundDialog.SetRoundItem(RoundName: string);
@@ -274,7 +338,7 @@ begin
                                TThreadItem(RoundItem.Item).Round := false;
                        end;
                        //RoundList.Delete(RoundItem.URL,RoundItem.RoundType);
-            {
+                       {
                        if RoundItem.RoundType = grtBoard then begin
                                //Board := TBoard( RoundItem.Item );
                                RoundList.Delete(RoundItem.URL,RoundItem.RoundType);
@@ -286,7 +350,7 @@ begin
                                ThreadItem.Round := False;
                                ThreadItem.RoundName := '';
                        end;
-            }
+                       }
                        GikoForm.ListView.Refresh;
                end;
                RoundListView.Selected.Delete;
@@ -295,4 +359,64 @@ begin
        end;
 end;
 
+procedure TRoundDialog.RoundListViewColumnClick(Sender: TObject;
+  Column: TListColumn);
+begin
+       if (Sender is TCustomListView) then begin
+
+               if FColumnToSort > -1 then
+                       (Sender as TCustomListView).Column[FColumnToSort].ImageIndex := -1;
+
+               if FColumnToSort = Column.Index then
+                       FSortOrder := not FSortOrder
+               else
+                       FSortOrder := false;
+
+               if FSortOrder then
+                       Column.ImageIndex := 3
+               else
+                       Column.ImageIndex := 2;
+
+               FColumnToSort := Column.Index;
+               (Sender as TCustomListView).AlphaSort;
+       end;
+end;
+
+procedure TRoundDialog.RoundListViewCompare(Sender: TObject; Item1,
+  Item2: TListItem; Data: Integer; var Compare: Integer);
+var
+  ix: Integer;
+begin
+       if FColumnToSort = 0 then begin
+               if not FSortOrder then begin
+                       Compare := CompareText(Item1.Caption,Item2.Caption);
+                       if Compare = 0 then
+                               Compare := CompareValue(Item1.ImageIndex, item2.ImageIndex);
+               end else begin
+                       Compare := -CompareText(Item1.Caption,Item2.Caption);
+                       if Compare = 0 then
+                               Compare := -CompareValue(Item1.ImageIndex,item2.ImageIndex);
+               end;
+       end else begin
+               ix := FColumnToSort - 1;
+               if not FSortOrder then begin
+                       Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix]);
+                       if Compare = 0 then
+                               Compare := CompareValue(Item1.ImageIndex, item2.ImageIndex);
+               end else begin
+                       Compare := -CompareText(Item1.SubItems[ix],Item2.SubItems[ix]);
+                       if Compare = 0 then
+                               Compare := -CompareValue(Item1.ImageIndex, item2.ImageIndex);
+               end;
+       end;
+end;
+(*
+* \83J\83\89\83\80\8fã\82Å\89E\83N\83\8a\83b\83N\82µ\82½\82ç\83\\81[\83g\82ð\89ð\8f\9c\82µ\82Ä\8f\89\8aú\8fó\91Ô\82É\96ß\82·
+*)
+procedure TRoundDialog.RoundListViewColumnRightClick(Sender: TObject;
+  Column: TListColumn; Point: TPoint);
+begin
+       RoundNameComboBox.OnChange(Sender);
+end;
+
 end.