| 8 |
|
|
| 9 |
type |
type |
| 10 |
TRoundDialog = class(TForm) |
TRoundDialog = class(TForm) |
| 11 |
RoundPopupMenu: TPopupMenu; |
RoundPopupMenu: TPopupMenu; |
| 12 |
C1: TMenuItem; |
C1: TMenuItem; |
| 13 |
P1: TMenuItem; |
P1: TMenuItem; |
| 14 |
N1: TMenuItem; |
N1: TMenuItem; |
| 15 |
D1: TMenuItem; |
D1: TMenuItem; |
| 16 |
ItemIcon16: TImageList; |
ItemIcon16: TImageList; |
| 17 |
Panel1: TPanel; |
Panel1: TPanel; |
| 18 |
Label1: TLabel; |
Label1: TLabel; |
| 19 |
Label2: TLabel; |
Label2: TLabel; |
| 20 |
RoundNameComboBox: TComboBox; |
RoundNameComboBox: TComboBox; |
| 21 |
Panel2: TPanel; |
Panel2: TPanel; |
| 22 |
Panel3: TPanel; |
Panel3: TPanel; |
| 23 |
AllSelectButton: TButton; |
AllSelectButton: TButton; |
| 24 |
AllCancelButton: TButton; |
AllCancelButton: TButton; |
| 25 |
RoundDeleteButton: TButton; |
RoundDeleteButton: TButton; |
| 26 |
Panel4: TPanel; |
Panel4: TPanel; |
| 27 |
Button1: TButton; |
Button1: TButton; |
| 28 |
RoundButton: TButton; |
RoundButton: TButton; |
| 29 |
StatusBar1: TStatusBar; |
StatusBar1: TStatusBar; |
| 30 |
RoundListView: TListView; |
RoundListView: TListView; |
| 31 |
procedure RoundButtonClick(Sender: TObject); |
procedure RoundButtonClick(Sender: TObject); |
| 32 |
procedure FormCreate(Sender: TObject); |
procedure FormCreate(Sender: TObject); |
| 33 |
procedure RoundListViewChange(Sender: TObject; Item: TListItem; |
procedure RoundListViewChange(Sender: TObject; Item: TListItem; |
| 36 |
procedure AllCancelButtonClick(Sender: TObject); |
procedure AllCancelButtonClick(Sender: TObject); |
| 37 |
procedure RoundNameComboBoxChange(Sender: TObject); |
procedure RoundNameComboBoxChange(Sender: TObject); |
| 38 |
procedure RoundDeleteButtonClick(Sender: TObject); |
procedure RoundDeleteButtonClick(Sender: TObject); |
| 39 |
|
procedure RoundListViewColumnClick(Sender: TObject; |
| 40 |
|
Column: TListColumn); |
| 41 |
|
procedure RoundListViewCompare(Sender: TObject; Item1, |
| 42 |
|
Item2: TListItem; Data: Integer; var Compare: Integer); |
| 43 |
|
procedure RoundListViewColumnRightClick(Sender: TObject; |
| 44 |
|
Column: TListColumn; Point: TPoint); |
| 45 |
private |
private |
| 46 |
{ Private 宣言 } |
{ Private 宣言 } |
| 47 |
|
FColumnToSort: Integer; |
| 48 |
|
FSortOrder: Boolean; |
| 49 |
function GetRoundCount: Integer; |
function GetRoundCount: Integer; |
| 50 |
procedure SetRoundItem(RoundName: string); |
procedure SetRoundItem(RoundName: string); |
| 51 |
function CompareTime(Time1: TDateTime; Time2: TDateTime; MarginMin: Integer): Boolean; |
function CompareTime(Time1: TDateTime; Time2: TDateTime; MarginMin: Integer): Boolean; |
| 53 |
{ Public 宣言 } |
{ Public 宣言 } |
| 54 |
end; |
end; |
| 55 |
|
|
|
//var |
|
|
// RoundDialog: TRoundDialog; |
|
| 56 |
|
|
| 57 |
implementation |
implementation |
| 58 |
|
|
| 59 |
uses |
uses |
| 60 |
Giko, BoardGroup, RoundData; |
Giko, BoardGroup, RoundData, Math, GikoDataModule; |
| 61 |
|
|
| 62 |
{$R *.DFM} |
{$R *.DFM} |
| 63 |
|
|
| 70 |
ThreadItem: TThreadItem; |
ThreadItem: TThreadItem; |
| 71 |
RoundItem: TRoundItem; |
RoundItem: TRoundItem; |
| 72 |
begin |
begin |
| 73 |
// if CompareTime(GikoForm.LastRoundTime, Now, 5) then begin |
{$IF Defined(FRCRND) } |
| 74 |
// msg := '一度巡回すると5分間巡回は出来ません'; |
GikoDM.LoginAction.Checked := true; // 動作試験用途 |
| 75 |
// GikoSys.MsgBox(msg, 'エラー', MB_OK or MB_ICONSTOP); |
{$IFEND} |
| 76 |
// Exit; |
|
| 77 |
// end; |
{$IFNDEF LOOSENUP} //巡回制限を緩めることにしてたら{$ELSE}の方を使う |
| 78 |
|
if not GikoDM.LoginAction.Checked then begin |
| 79 |
if not Giko.GikoForm.LoginAction.Checked then begin |
if GikoSys.Setting.UserID <> '' then begin |
| 80 |
msg := 'ログインしないと巡回は出来ません' + #13#10 |
msg := 'ログインしないと巡回は出来ません' + #13#10 |
| 81 |
+ '「ログインってなによ?」という人はギコナビスレかメールで聞いてください'; |
+ '今ログインしますか'; |
| 82 |
MsgBox(Handle, msg, 'エラー', MB_OK or MB_ICONSTOP); |
if MsgBox(Handle, msg, '確認', MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then begin |
| 83 |
Exit; |
Exit; |
| 84 |
|
end; |
| 85 |
|
GikoDM.LoginAction.Execute; |
| 86 |
|
end; |
| 87 |
|
if not GikoDM.LoginAction.Checked then begin |
| 88 |
|
msg := 'ログインしないと巡回は出来ません'; |
| 89 |
|
MsgBox(Handle, msg, 'エラー', MB_OK or MB_ICONSTOP); |
| 90 |
|
Exit; |
| 91 |
|
end; |
| 92 |
|
end; |
| 93 |
|
{$ELSE} |
| 94 |
|
//規制を緩めたほうは、スレ一覧のみ巡回可能 |
| 95 |
|
if not GikoDM.LoginAction.Checked then begin |
| 96 |
|
if GikoSys.Setting.UserID <> '' then begin |
| 97 |
|
msg := 'ログインしないとスレッドの巡回は出来ません' + #13#10 |
| 98 |
|
+ '今ログインしますか'; |
| 99 |
|
if MsgBox(Handle, msg, '確認', MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then begin |
| 100 |
|
Exit; |
| 101 |
|
end; |
| 102 |
|
GikoDM.LoginAction.Execute; |
| 103 |
|
end; |
| 104 |
|
end; |
| 105 |
|
//●なし巡回は15分以上の間隔を必要とする |
| 106 |
|
if not GikoDM.LoginAction.Checked then begin |
| 107 |
|
if CompareTime(GikoForm.LastRoundTime, Now, 30) then begin |
| 108 |
|
msg := '一度巡回すると30分間巡回は出来ません'; |
| 109 |
|
MsgBox(Handle, msg, 'エラー', MB_OK or MB_ICONSTOP); |
| 110 |
|
Exit; |
| 111 |
|
end; |
| 112 |
end; |
end; |
| 113 |
|
{$ENDIF} |
| 114 |
|
|
| 115 |
|
//一つも巡回に設定していなかったらエラーにする |
| 116 |
cnt := GetRoundCount; |
cnt := GetRoundCount; |
| 117 |
if cnt = 0 then begin |
if cnt = 0 then begin |
| 118 |
msg := '巡回したい項目に1つ以上チェックを入れてください'; |
msg := '巡回したい項目に1つ以上チェックを入れてください'; |
| 120 |
Exit; |
Exit; |
| 121 |
end; |
end; |
| 122 |
|
|
| 123 |
|
{$IFNDEF LOOSENUP} |
| 124 |
|
//●なし巡回は1度に100個までにする |
| 125 |
|
if not GikoDM.LoginAction.Checked then begin |
| 126 |
|
if cnt > 100 then begin |
| 127 |
|
msg := '100個以上は一度に巡回できません'; |
| 128 |
|
MsgBox(Handle, msg, 'エラー', MB_OK or MB_ICONSTOP); |
| 129 |
|
Exit; |
| 130 |
|
end; |
| 131 |
|
end; |
| 132 |
|
{$ENDIF} |
| 133 |
|
|
| 134 |
|
//巡回に登録されている板の数だけまわす |
| 135 |
for i := 0 to RoundList.Count[grtBoard] - 1 do begin |
for i := 0 to RoundList.Count[grtBoard] - 1 do begin |
| 136 |
RoundItem := RoundList.Items[i, grtBoard]; |
RoundItem := RoundList.Items[i, grtBoard]; |
| 137 |
|
//巡回のチェックがついていなければスルー |
| 138 |
if not RoundItem.BoolData then Continue; |
if not RoundItem.BoolData then Continue; |
| 139 |
if not Giko.GikoForm.LoginAction.Checked then Exit; |
//確実に板のはずだけどチェック |
| 140 |
if RoundItem.RoundType = grtBoard then begin |
if RoundItem.RoundType = grtBoard then begin |
| 141 |
Board := BBS2ch.FindBBSID(RoundItem.BBSID); |
Board := TBoard( RoundItem.Item ); |
| 142 |
|
//Boardのオブジェクトが存在すれば、DLする |
| 143 |
if Board <> nil then begin |
if Board <> nil then begin |
| 144 |
if not Board.IsThreadDatRead then |
if not Board.IsThreadDatRead then |
| 145 |
GikoSys.ReadSubjectFile(Board); |
GikoSys.ReadSubjectFile(Board); |
| 149 |
end; |
end; |
| 150 |
for i := 0 to RoundList.Count[grtItem] - 1 do begin |
for i := 0 to RoundList.Count[grtItem] - 1 do begin |
| 151 |
RoundItem := RoundList.Items[i, grtItem]; |
RoundItem := RoundList.Items[i, grtItem]; |
| 152 |
|
//巡回のチェックがついていなければスルー |
| 153 |
if not RoundItem.BoolData then Continue; |
if not RoundItem.BoolData then Continue; |
| 154 |
if not Giko.GikoForm.LoginAction.Checked then Exit; |
{$IFDEF LOOSENUP} |
| 155 |
Board := BBS2ch.FindBBSID(RoundItem.BBSID); |
//●なし巡回はスレッドはできないことにする |
| 156 |
if Board <> nil then begin |
if not GikoDM.LoginAction.Checked then begin |
| 157 |
if not Board.IsThreadDatRead then |
msg := 'ログインしないとスレッドの巡回はできません。'; |
| 158 |
GikoSys.ReadSubjectFile(Board); |
MsgBox(Handle, msg, 'エラー', MB_OK or MB_ICONSTOP); |
| 159 |
ThreadItem := BBS2ch.FindThreadItem(RoundItem.BBSID, RoundItem.FileName); |
break; |
| 160 |
|
end; |
| 161 |
|
{$ENDIF} |
| 162 |
|
if RoundItem.RoundType = grtItem then begin |
| 163 |
|
ThreadItem := TThreadItem( RoundItem.Item ); |
| 164 |
if ThreadItem <> nil then begin |
if ThreadItem <> nil then begin |
|
// GikoForm.AddMessageList('debug2:' + IntToStr(i), nil); |
|
| 165 |
GikoForm.DownloadContent(ThreadItem); |
GikoForm.DownloadContent(ThreadItem); |
| 166 |
end; |
end; |
| 167 |
end; |
end; |
| 168 |
end; |
end; |
| 169 |
// GikoForm.LastRoundTime := Now; |
GikoForm.LastRoundTime := Now; |
| 170 |
Close; |
Close; |
| 171 |
end; |
end; |
| 172 |
|
|
| 202 |
var |
var |
| 203 |
i: Integer; |
i: Integer; |
| 204 |
begin |
begin |
| 205 |
|
//現在の巡回データをファイルアウトする |
| 206 |
|
RoundList.SaveRoundFile; |
| 207 |
RoundNameComboBox.Items.Add('(すべて)'); |
RoundNameComboBox.Items.Add('(すべて)'); |
| 208 |
for i := 0 to RoundList.RoundNameList.Count - 1 do |
for i := 0 to RoundList.RoundNameList.Count - 1 do |
| 209 |
RoundNameComboBox.Items.Add(RoundList.RoundNameList[i]); |
RoundNameComboBox.Items.Add(RoundList.RoundNameList[i]); |
| 270 |
|
|
| 271 |
procedure TRoundDialog.RoundNameComboBoxChange(Sender: TObject); |
procedure TRoundDialog.RoundNameComboBoxChange(Sender: TObject); |
| 272 |
begin |
begin |
| 273 |
|
//カラムのソート記号イメージを解除する |
| 274 |
|
if FColumnToSort > -1 then |
| 275 |
|
RoundListView.Column[FColumnToSort].ImageIndex := -1; |
| 276 |
|
FColumnToSort := -1; |
| 277 |
if RoundNameComboBox.ItemIndex = 0 then |
if RoundNameComboBox.ItemIndex = 0 then |
| 278 |
SetRoundItem('') |
SetRoundItem('') |
| 279 |
else |
else |
| 280 |
SetRoundItem(RoundNameComboBox.Items[RoundNameComboBox.itemIndex]); |
SetRoundItem(RoundNameComboBox.Items[RoundNameComboBox.itemIndex]); |
| 281 |
|
|
| 282 |
end; |
end; |
| 283 |
|
|
| 284 |
procedure TRoundDialog.SetRoundItem(RoundName: string); |
procedure TRoundDialog.SetRoundItem(RoundName: string); |
| 320 |
|
|
| 321 |
procedure TRoundDialog.RoundDeleteButtonClick(Sender: TObject); |
procedure TRoundDialog.RoundDeleteButtonClick(Sender: TObject); |
| 322 |
var |
var |
| 323 |
Board: TBoard; |
// Board: TBoard; |
| 324 |
ThreadItem: TThreadItem; |
// ThreadItem: TThreadItem; |
| 325 |
RoundItem: TRoundItem; |
RoundItem: TRoundItem; |
| 326 |
ListChangeEvent: TLVChangeEvent; |
ListChangeEvent: TLVChangeEvent; |
| 327 |
begin |
begin |
| 332 |
Exit; |
Exit; |
| 333 |
if TObject(RoundListView.Selected.Data) is TRoundItem then begin |
if TObject(RoundListView.Selected.Data) is TRoundItem then begin |
| 334 |
RoundItem := TRoundItem(RoundListView.Selected.Data); |
RoundItem := TRoundItem(RoundListView.Selected.Data); |
| 335 |
Board := BBS2ch.FindBBSID(RoundItem.BBSID); |
if( RoundItem.Item is TBoard ) then begin |
| 336 |
|
TBoard(RoundItem.Item).Round := false; |
| 337 |
|
end else if( RoundItem.Item is TThreadItem ) then begin |
| 338 |
|
TThreadItem(RoundItem.Item).Round := false; |
| 339 |
|
end; |
| 340 |
|
//RoundList.Delete(RoundItem.URL,RoundItem.RoundType); |
| 341 |
|
{ |
| 342 |
if RoundItem.RoundType = grtBoard then begin |
if RoundItem.RoundType = grtBoard then begin |
| 343 |
RoundList.Delete(Board); |
//Board := TBoard( RoundItem.Item ); |
| 344 |
|
RoundList.Delete(RoundItem.URL,RoundItem.RoundType); |
| 345 |
Board.Round := False; |
Board.Round := False; |
| 346 |
Board.RoundName := ''; |
Board.RoundName := ''; |
| 347 |
end else begin |
end else begin |
| 348 |
if not Board.IsThreadDatRead then |
//ThreadItem := TThreadItem( RoundItem.Item ); |
|
GikoSys.ReadSubjectFile(Board); |
|
|
ThreadItem := BBS2ch.FindThreadItem(RoundItem.BBSID, RoundItem.FileName); |
|
| 349 |
RoundList.Delete(ThreadItem); |
RoundList.Delete(ThreadItem); |
| 350 |
ThreadItem.Round := False; |
ThreadItem.Round := False; |
| 351 |
ThreadItem.RoundName := ''; |
ThreadItem.RoundName := ''; |
| 352 |
end; |
end; |
| 353 |
|
} |
| 354 |
GikoForm.ListView.Refresh; |
GikoForm.ListView.Refresh; |
| 355 |
end; |
end; |
| 356 |
RoundListView.Selected.Delete; |
RoundListView.Selected.Delete; |
| 359 |
end; |
end; |
| 360 |
end; |
end; |
| 361 |
|
|
| 362 |
|
procedure TRoundDialog.RoundListViewColumnClick(Sender: TObject; |
| 363 |
|
Column: TListColumn); |
| 364 |
|
begin |
| 365 |
|
if (Sender is TCustomListView) then begin |
| 366 |
|
|
| 367 |
|
if FColumnToSort > -1 then |
| 368 |
|
(Sender as TCustomListView).Column[FColumnToSort].ImageIndex := -1; |
| 369 |
|
|
| 370 |
|
if FColumnToSort = Column.Index then |
| 371 |
|
FSortOrder := not FSortOrder |
| 372 |
|
else |
| 373 |
|
FSortOrder := false; |
| 374 |
|
|
| 375 |
|
if FSortOrder then |
| 376 |
|
Column.ImageIndex := 3 |
| 377 |
|
else |
| 378 |
|
Column.ImageIndex := 2; |
| 379 |
|
|
| 380 |
|
FColumnToSort := Column.Index; |
| 381 |
|
(Sender as TCustomListView).AlphaSort; |
| 382 |
|
end; |
| 383 |
|
end; |
| 384 |
|
|
| 385 |
|
procedure TRoundDialog.RoundListViewCompare(Sender: TObject; Item1, |
| 386 |
|
Item2: TListItem; Data: Integer; var Compare: Integer); |
| 387 |
|
var |
| 388 |
|
ix: Integer; |
| 389 |
|
begin |
| 390 |
|
if FColumnToSort = 0 then begin |
| 391 |
|
if not FSortOrder then begin |
| 392 |
|
Compare := CompareText(Item1.Caption,Item2.Caption); |
| 393 |
|
if Compare = 0 then |
| 394 |
|
Compare := CompareValue(Item1.ImageIndex, item2.ImageIndex); |
| 395 |
|
end else begin |
| 396 |
|
Compare := -CompareText(Item1.Caption,Item2.Caption); |
| 397 |
|
if Compare = 0 then |
| 398 |
|
Compare := -CompareValue(Item1.ImageIndex,item2.ImageIndex); |
| 399 |
|
end; |
| 400 |
|
end else begin |
| 401 |
|
ix := FColumnToSort - 1; |
| 402 |
|
if not FSortOrder then begin |
| 403 |
|
Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix]); |
| 404 |
|
if Compare = 0 then |
| 405 |
|
Compare := CompareValue(Item1.ImageIndex, item2.ImageIndex); |
| 406 |
|
end else begin |
| 407 |
|
Compare := -CompareText(Item1.SubItems[ix],Item2.SubItems[ix]); |
| 408 |
|
if Compare = 0 then |
| 409 |
|
Compare := -CompareValue(Item1.ImageIndex, item2.ImageIndex); |
| 410 |
|
end; |
| 411 |
|
end; |
| 412 |
|
end; |
| 413 |
|
(* |
| 414 |
|
* カラム上で右クリックしたらソートを解除して初期状態に戻す |
| 415 |
|
*) |
| 416 |
|
procedure TRoundDialog.RoundListViewColumnRightClick(Sender: TObject; |
| 417 |
|
Column: TListColumn; Point: TPoint); |
| 418 |
|
begin |
| 419 |
|
RoundNameComboBox.OnChange(Sender); |
| 420 |
|
end; |
| 421 |
|
|
| 422 |
end. |
end. |