| 110 |
destructor TFavoriteBoardItem.Destory; |
destructor TFavoriteBoardItem.Destory; |
| 111 |
begin |
begin |
| 112 |
if FItem <> nil then |
if FItem <> nil then |
| 113 |
FItem.Free; |
FItem.Free; |
| 114 |
inherited; |
inherited; |
| 115 |
end; |
end; |
| 116 |
function TFavoriteBoardItem.GetItem : TBoard; |
function TFavoriteBoardItem.GetItem : TBoard; |
| 117 |
var |
var |
| 131 |
FItem := BBSs[ 0 ].FindBBSID( BBSID ); |
FItem := BBSs[ 0 ].FindBBSID( BBSID ); |
| 132 |
if FItem <> nil then |
if FItem <> nil then |
| 133 |
URL := FItem.URL; |
URL := FItem.URL; |
| 134 |
|
end else if AnsiPos('jbbs.shitaraba.com', host) <> 0 then begin |
| 135 |
|
// したらばJBBSのhttp://jbbs.shitaraba.com/ → http://jbbs.livedoor.com/ 置換 |
| 136 |
|
URL := CustomStringReplace(URL, 'http://jbbs.shitaraba.com/', 'http://jbbs.livedoor.com/', false); |
| 137 |
|
FItem := BBSsFindBoardFromURL( URL ); |
| 138 |
|
if FItem <> nil then |
| 139 |
|
URL := FItem.URL; |
| 140 |
end; |
end; |
| 141 |
{ |
{ |
| 142 |
// ※作っても、追加するカテゴリが無いので激しく保留 |
// ※作っても、追加するカテゴリが無いので激しく保留 |
| 146 |
end; |
end; |
| 147 |
end; |
end; |
| 148 |
|
|
| 149 |
Result := FItem; |
Result := FItem; |
| 150 |
|
|
| 151 |
end; |
end; |
| 152 |
|
|
| 158 |
begin |
begin |
| 159 |
|
|
| 160 |
inherited Create; |
inherited Create; |
|
|
|
| 161 |
URL := inURL; |
URL := inURL; |
| 162 |
|
|
| 163 |
Title := inTitle; |
Title := inTitle; |
| 164 |
Item := inItem; |
Item := inItem; |
| 165 |
|
|
| 251 |
end; |
end; |
| 252 |
procedure TFavoriteDM.Clear; |
procedure TFavoriteDM.Clear; |
| 253 |
var |
var |
| 254 |
i: Integer; |
Node : TTreeNode; |
| 255 |
begin |
begin |
| 256 |
TreeView.Items.BeginUpdate; |
TreeView.Items.BeginUpdate; |
| 257 |
for i := TreeView.Items.Count - 1 downto 0 do begin |
Node := TreeView.Items.GetFirstNode; |
| 258 |
if TObject(TreeView.Items[i].Data) <> nil then |
while Node <> nil do begin |
| 259 |
TObject(TreeView.Items[i].Data).Free; |
if TObject(Node.Data) <> nil then |
| 260 |
|
TObject(Node.Data).Free; |
| 261 |
|
Node := Node.GetNext; |
| 262 |
end; |
end; |
| 263 |
TreeView.Items.Clear; |
TreeView.Items.Clear; |
| 264 |
TreeView.Items.EndUpdate; |
TreeView.Items.EndUpdate; |
| 265 |
//TreeView.Free; |
//TreeView.Free; |
| 266 |
end; |
end; |
| 267 |
|
|
| 446 |
XMLDoc.SaveToFile(FileName); |
XMLDoc.SaveToFile(FileName); |
| 447 |
} |
} |
| 448 |
var |
var |
| 449 |
FileName: string; |
FileName, tmpFileName: string; |
| 450 |
SaveList: TStringList; |
SaveList: TStringList; |
| 451 |
|
|
| 452 |
begin |
begin |
| 453 |
FileName := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
FileName := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
| 454 |
|
if FileExists(FileName) then begin |
| 455 |
|
tmpFileName := GikoSys.GetConfigDir + '~' + FAVORITE_FILE_NAME; |
| 456 |
|
if FileExists(tmpFileName) then |
| 457 |
|
SysUtils.DeleteFile(tmpFileName); //SysUtils.をつけないとWinAPIと区別できないので |
| 458 |
|
RenameFile(FileName, tmpFileName); |
| 459 |
|
end; |
| 460 |
SaveList := TStringList.Create; |
SaveList := TStringList.Create; |
| 461 |
try |
try |
| 462 |
SaveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>'); |
SaveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>'); |
| 463 |
SaveList.Add('<favorite>'); |
SaveList.Add('<favorite>'); |
| 464 |
AddSaveString(TreeView.Items.GetFirstNode, SaveList); |
AddSaveString(TreeView.Items.GetFirstNode.getFirstChild, SaveList); |
| 465 |
SaveList.Add('</favorite>'); |
SaveList.Add('</favorite>'); |
| 466 |
SaveList.SaveToFile(FileName); |
SaveList.SaveToFile(FileName); |
| 467 |
finally |
finally |
| 507 |
|
|
| 508 |
procedure TFavoriteDM.AddSaveString(Node: TTreeNode; SaveList: TStringList); |
procedure TFavoriteDM.AddSaveString(Node: TTreeNode; SaveList: TStringList); |
| 509 |
var |
var |
|
i: Integer; |
|
| 510 |
s: string; |
s: string; |
| 511 |
FavBoard: TFavoriteBoardItem; |
FavBoard: TFavoriteBoardItem; |
| 512 |
FavThread: TFavoriteThreadItem; |
FavThread: TFavoriteThreadItem; |
| 513 |
|
data : Pointer; |
| 514 |
begin |
begin |
| 515 |
for i := 0 to Node.Count - 1 do begin |
while Node <> nil do begin |
| 516 |
if TObject(Node.Item[i].Data) is TFavoriteFolder then begin |
data := Node.Data; |
| 517 |
if Node.Item[ i ].Expanded then |
if TObject(data) is TFavoriteFolder then begin |
| 518 |
s := Format('<folder title="%s" expanded="true">', [HtmlEncode(Node.Item[i].Text)]) |
if Node.Expanded then |
| 519 |
|
s := Format('<folder title="%s" expanded="true">', [HtmlEncode(Node.Text)]) |
| 520 |
else |
else |
| 521 |
s := Format('<folder title="%s" expanded="false">', [HtmlEncode(Node.Item[i].Text)]); |
s := Format('<folder title="%s" expanded="false">', [HtmlEncode(Node.Text)]); |
| 522 |
SaveList.Add(s); |
SaveList.Add(s); |
| 523 |
AddSaveString(Node.Item[i], SaveList); |
AddSaveString(Node.getFirstChild, SaveList); |
| 524 |
SaveList.Add('</folder>'); |
SaveList.Add('</folder>'); |
| 525 |
end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin |
end else if TObject(data) is TFavoriteBoardItem then begin |
| 526 |
FavBoard := TFavoriteBoardItem(Node.Item[i].Data); |
FavBoard := TFavoriteBoardItem(data); |
| 527 |
s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>', |
s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>', |
| 528 |
[HtmlEncode( FavBoard.URL ), HtmlEncode(Node.Item[ i ].Text)]); |
[HtmlEncode( FavBoard.URL ), HtmlEncode(Node.Text)]); |
| 529 |
SaveList.Add(s); |
SaveList.Add(s); |
| 530 |
end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin |
end else if TObject(data) is TFavoriteThreadItem then begin |
| 531 |
FavThread := TFavoriteThreadItem(Node.Item[i].Data); |
FavThread := TFavoriteThreadItem(data); |
| 532 |
s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>', |
s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>', |
| 533 |
[HtmlEncode( FavThread.URL ), HtmlEncode(Node.Item[ i ].Text)]); |
[HtmlEncode( FavThread.URL ), HtmlEncode(Node.Text)]); |
| 534 |
SaveList.Add(s); |
SaveList.Add(s); |
| 535 |
end; |
end; |
| 536 |
|
Node := Node.getNextSibling; |
| 537 |
end; |
end; |
| 538 |
end; |
end; |
| 539 |
|
|
| 610 |
FavoriteFilePath: string; |
FavoriteFilePath: string; |
| 611 |
tempStringList: TStringList; |
tempStringList: TStringList; |
| 612 |
begin |
begin |
| 613 |
|
WriteFavorite; |
| 614 |
FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
| 615 |
|
|
| 616 |
if FileExists( FavoriteFilePath ) then begin |
if FileExists( FavoriteFilePath ) then begin |
| 629 |
|
|
| 630 |
procedure TFavoriteDM.URLReplace(oldURLs: TStringList; newURLs: TStringList); |
procedure TFavoriteDM.URLReplace(oldURLs: TStringList; newURLs: TStringList); |
| 631 |
var |
var |
| 632 |
i, j : Integer; |
i : Integer; |
| 633 |
tmpURL: string; |
tmpURL: string; |
| 634 |
oldHost: string; |
oldHost: string; |
| 635 |
oldBoardName: string; |
oldBoardName: string; |
| 639 |
favBoard : TFavoriteBoardItem; |
favBoard : TFavoriteBoardItem; |
| 640 |
favThread : TFavoriteThreadItem; |
favThread : TFavoriteThreadItem; |
| 641 |
favorites : TTreeNodes; |
favorites : TTreeNodes; |
| 642 |
|
Node : TTreeNode; |
| 643 |
begin |
begin |
| 644 |
|
|
| 645 |
// 面倒だけどthreadはそれぞれURLをチェックしながらやってかなきゃいけない。 |
// 面倒だけどthreadはそれぞれURLをチェックしながらやってかなきゃいけない。 |
| 653 |
newHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) ); |
newHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) ); |
| 654 |
newBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/'; |
newBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/'; |
| 655 |
|
|
| 656 |
for j := favorites.Count - 1 downto 0 do begin |
Node := favorites.GetFirstNode.getFirstChild; |
| 657 |
|
while Node <> nil do begin |
| 658 |
try |
try |
| 659 |
if TObject( favorites.Item[ j ].Data ) is TFavoriteBoardItem then begin |
if TObject( Node.Data ) is TFavoriteBoardItem then begin |
| 660 |
favBoard := TFavoriteBoardItem( favorites.Item[ j ].Data ); |
favBoard := TFavoriteBoardItem( Node.Data ); |
| 661 |
if favBoard = nil then continue; |
if favBoard = nil then continue; |
| 662 |
tempString := favBoard.URL; |
tempString := favBoard.URL; |
| 663 |
if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin |
if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin |
| 664 |
tempString := StringReplace(tempString, oldHost, newHost,[]); |
tempString := StringReplace(tempString, oldHost, newHost,[]); |
| 665 |
favBoard.URL := tempString; |
favBoard.URL := tempString; |
| 666 |
end; |
end; |
| 667 |
end else if TObject( favorites.Item[ j ].Data ) is TFavoriteThreadItem then begin |
end else if TObject( Node.Data ) is TFavoriteThreadItem then begin |
| 668 |
favThread := TFavoriteThreadItem( favorites.Item[ j ].Data ); |
favThread := TFavoriteThreadItem( Node.Data ); |
| 669 |
if favThread = nil then continue; |
if favThread = nil then continue; |
| 670 |
tempString := favThread.URL; |
tempString := favThread.URL; |
| 671 |
if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin |
if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin |
| 675 |
end; |
end; |
| 676 |
except |
except |
| 677 |
end; |
end; |
| 678 |
|
Node := Node.GetNext; |
| 679 |
end; |
end; |
| 680 |
except |
except |
| 681 |
end; |
end; |