| 14 |
TFavoriteBoardItem = class |
TFavoriteBoardItem = class |
| 15 |
private |
private |
| 16 |
FItem : TBoard; |
FItem : TBoard; |
| 17 |
|
FURL : string; |
| 18 |
FTitle : string; |
FTitle : string; |
| 19 |
public |
public |
| 20 |
|
constructor Create( inURL : string; inTitle : string = ''; inItem : TBoard = nil ); |
| 21 |
property Item : TBoard read FItem write FItem; |
property Item : TBoard read FItem write FItem; |
| 22 |
|
property URL : string read FURL write FURL; // Item が取得できなくても URL は常に保持される |
| 23 |
property Title : string read FTitle write FTitle; |
property Title : string read FTitle write FTitle; |
| 24 |
end; |
end; |
| 25 |
|
|
| 26 |
TFavoriteThreadItem = class |
TFavoriteThreadItem = class |
| 27 |
private |
private |
| 28 |
FItem : TThreadItem; |
FItem : TThreadItem; |
| 29 |
|
FURL : string; |
| 30 |
FTitle : string; |
FTitle : string; |
| 31 |
public |
public |
| 32 |
|
constructor Create( inURL : string; inTitle : string = ''; inItem : TThreadItem = nil ); |
| 33 |
property Item : TThreadItem read FItem write FItem; |
property Item : TThreadItem read FItem write FItem; |
| 34 |
|
property URL : string read FURL write FURL; // Item が取得できなくても URL は常に保持される |
| 35 |
property Title : string read FTitle write FTitle; |
property Title : string read FTitle write FTitle; |
| 36 |
end; |
end; |
| 37 |
|
|
| 53 |
// procedure SAXCharacters(Sender: TObject; const PCh: SAXString); |
// procedure SAXCharacters(Sender: TObject; const PCh: SAXString); |
| 54 |
public |
public |
| 55 |
{ Public 宣言 } |
{ Public 宣言 } |
| 56 |
function GetFavoriteFilePath() : String; |
function GetFavoriteFilePath() : String; |
| 57 |
function SaveFavoriteFile(FileName: String) : Boolean; |
function SaveFavoriteFile(FileName: String) : Boolean; |
| 58 |
procedure SetFavTreeView(TreeView: TTreeView); |
procedure SetFavTreeView(TreeView: TTreeView); |
| 59 |
procedure ReadFavorite; |
procedure ReadFavorite; |
| 60 |
procedure WriteFavorite; |
procedure WriteFavorite; |
| 76 |
|
|
| 77 |
{$R *.dfm} |
{$R *.dfm} |
| 78 |
|
|
| 79 |
|
constructor TFavoriteBoardItem.Create( |
| 80 |
|
inURL : string; |
| 81 |
|
inTitle : string = ''; |
| 82 |
|
inItem : TBoard = nil |
| 83 |
|
); |
| 84 |
|
begin |
| 85 |
|
|
| 86 |
|
inherited Create; |
| 87 |
|
|
| 88 |
|
URL := inURL; |
| 89 |
|
Title := inTitle; |
| 90 |
|
Item := inItem; |
| 91 |
|
|
| 92 |
|
end; |
| 93 |
|
|
| 94 |
|
constructor TFavoriteThreadItem.Create( |
| 95 |
|
inURL : string; |
| 96 |
|
inTitle : string = ''; |
| 97 |
|
inItem : TThreadItem = nil |
| 98 |
|
); |
| 99 |
|
begin |
| 100 |
|
|
| 101 |
|
inherited Create; |
| 102 |
|
|
| 103 |
|
URL := inURL; |
| 104 |
|
Title := inTitle; |
| 105 |
|
Item := inItem; |
| 106 |
|
|
| 107 |
|
end; |
| 108 |
|
|
| 109 |
procedure TFavoriteDM.DataModuleCreate(Sender: TObject); |
procedure TFavoriteDM.DataModuleCreate(Sender: TObject); |
| 110 |
begin |
begin |
| 111 |
//FTreeView := TreeView; |
//FTreeView := TreeView; |
| 200 |
procedure TFavoriteDM.ReadNode(Node: IXMLNode); |
procedure TFavoriteDM.ReadNode(Node: IXMLNode); |
| 201 |
var |
var |
| 202 |
i: Integer; |
i: Integer; |
| 203 |
j, jBound : Integer; |
j, jBound : Integer; |
| 204 |
|
|
| 205 |
ParentNode: TTreeNode; |
ParentNode: TTreeNode; |
| 206 |
CurrentNode: TTreeNode; |
CurrentNode: TTreeNode; |
| 207 |
FavFolder: TFavoriteFolder; |
FavFolder: TFavoriteFolder; |
| 208 |
FavBoard: TFavoriteBoardItem; |
FavBoard: TFavoriteBoardItem; |
| 209 |
FavThread: TFavoriteThreadItem; |
FavThread: TFavoriteThreadItem; |
| 210 |
board : TBoard; |
board : TBoard; |
| 211 |
url : string; |
threadItem : TThreadItem; |
| 212 |
|
url : string; |
| 213 |
begin |
begin |
| 214 |
if Node.NodeName = 'folder' then begin |
if Node.NodeName = 'folder' then begin |
| 215 |
ParentNode := FStack.Peek; |
ParentNode := FStack.Peek; |
| 218 |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder); |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder); |
| 219 |
CurrentNode.ImageIndex := 14; |
CurrentNode.ImageIndex := 14; |
| 220 |
CurrentNode.SelectedIndex := 14; |
CurrentNode.SelectedIndex := 14; |
| 221 |
CurrentNode.Expanded := Node.Attributes[ 'expanded' ] = 'true'; |
CurrentNode.Expanded := Node.Attributes[ 'expanded' ] = 'true'; |
| 222 |
FStack.Push(CurrentNode); |
FStack.Push(CurrentNode); |
| 223 |
end; |
end; |
| 224 |
for i := 0 to Node.ChildNodes.Count - 1 do begin |
for i := 0 to Node.ChildNodes.Count - 1 do begin |
| 230 |
ParentNode := FStack.Peek; |
ParentNode := FStack.Peek; |
| 231 |
if TObject(ParentNode.Data) is TFavoriteFolder then begin |
if TObject(ParentNode.Data) is TFavoriteFolder then begin |
| 232 |
if Node.Attributes['favtype'] = 'board' then begin |
if Node.Attributes['favtype'] = 'board' then begin |
| 233 |
FavBoard := TFavoriteBoardItem.Create; |
board := BBSsFindBoardFromURL( Node.Attributes[ 'url' ] ); |
| 234 |
FavBoard.Item := BBSsFindBoardFromURL( Node.Attributes[ 'url' ] ); |
// 旧式のお気に入りとの互換性のため |
| 235 |
// 旧式のお気に入りとの互換性のため |
if board = nil then begin |
| 236 |
if FavBoard.Item = nil then begin |
if Node.Attributes[ 'url' ] = '' then begin |
| 237 |
if Node.Attributes[ 'url' ] = '' then begin |
board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] ); |
| 238 |
FavBoard.Item := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] ); |
if board = nil then |
| 239 |
if FavBoard.Item = nil then begin |
Exit; |
| 240 |
FavBoard.Free; |
end else begin |
| 241 |
Exit; |
// ※作っても、追加するカテゴリが無いので激しく保留 |
| 242 |
end; |
board := TBoard.Create( nil, Node.Attributes[ 'url' ] ); |
| 243 |
end else begin |
end; |
| 244 |
// ※作っても、追加するカテゴリが無いので激しく保留 |
end; |
| 245 |
//FavBoard.Item := TBoard.Create( nil, Node.Attributes[ 'url' ] ); |
FavBoard := TFavoriteBoardItem.Create( board.URL, Node.Attributes['title'], board ); |
|
end; |
|
|
end; |
|
|
FavBoard.Title := Node.Attributes['title']; |
|
| 246 |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard); |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard); |
| 247 |
CurrentNode.ImageIndex := 15; |
CurrentNode.ImageIndex := 15; |
| 248 |
CurrentNode.SelectedIndex := 15; |
CurrentNode.SelectedIndex := 15; |
| 249 |
end else if Node.Attributes['favtype'] = 'thread' then begin |
end else if Node.Attributes['favtype'] = 'thread' then begin |
| 250 |
url := Node.Attributes[ 'url' ]; |
url := Node.Attributes[ 'url' ]; |
| 251 |
FavThread := TFavoriteThreadItem.Create; |
threadItem := BBSsFindThreadFromURL( url ); |
| 252 |
FavThread.Item := BBSsFindThreadFromURL( url ); |
// 旧式のお気に入りとの互換性のため |
| 253 |
// 旧式のお気に入りとの互換性のため |
if threadItem = nil then begin |
| 254 |
if FavThread.Item = nil then begin |
if Node.Attributes[ 'url' ] = '' then begin |
| 255 |
if Node.Attributes[ 'url' ] = '' then begin |
board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] ); |
| 256 |
board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] ); |
if board = nil then |
| 257 |
if board = nil then begin |
Exit; |
| 258 |
FavThread.Free; |
if not board.IsThreadDatRead then |
| 259 |
Exit; |
GikoSys.ReadSubjectFile( board ); |
| 260 |
end; |
threadItem := board.Find( Node.Attributes[ 'thread' ] ); |
| 261 |
if not board.IsThreadDatRead then |
if threadItem = nil then begin |
| 262 |
GikoSys.ReadSubjectFile( board ); |
threadItem := TThreadItem.Create( |
| 263 |
FavThread.Item := board.Find( Node.Attributes[ 'thread' ] ); |
board.BoardPlugIn, |
| 264 |
if FavThread.Item = nil then begin |
GikoSys.Get2chBoard2ThreadURL( board, ChangeFileExt( Node.Attributes[ 'thread' ], '' ) ) ); |
| 265 |
FavThread.Item := TThreadItem.Create( |
board.Add( threadItem ); |
| 266 |
board.BoardPlugIn, |
end; |
| 267 |
GikoSys.Get2chBoard2ThreadURL( board, ChangeFileExt( Node.Attributes[ 'thread' ], '' ) ) ); |
end else begin |
| 268 |
board.Add( FavThread.Item ) |
board := BBSsFindBoardFromURL( GikoSys.Get2chThreadURL2BoardURL( url ) ); |
| 269 |
end; |
|
| 270 |
end else begin |
//===== プラグイン |
| 271 |
board := BBSsFindBoardFromURL( GikoSys.Get2chThreadURL2BoardURL( url ) ); |
try |
| 272 |
if board <> nil then begin |
jBound := Length( BoardPlugIns ) - 1; |
| 273 |
//===== プラグイン |
for j := 0 to jBound do begin |
| 274 |
try |
if Assigned( Pointer( BoardPlugIns[ j ].Module ) ) then begin |
| 275 |
jBound := Length( BoardPlugIns ) - 1; |
if BoardPlugIns[ j ].AcceptURL( url ) = atThread then begin |
| 276 |
for j := 0 to jBound do begin |
threadItem := TThreadItem.Create( BoardPlugIns[ j ], url ); |
| 277 |
if Assigned( Pointer( BoardPlugIns[ j ].Module ) ) then begin |
|
| 278 |
if BoardPlugIns[ j ].AcceptURL( url ) = atThread then begin |
Break; |
| 279 |
FavThread.Item := TThreadItem.Create( BoardPlugIns[ j ], url ); |
end; |
| 280 |
|
end; |
| 281 |
Break; |
end; |
| 282 |
end; |
except |
| 283 |
end; |
// exception が発生した場合は内部処理に任せたいのでここでは何もしない |
| 284 |
end; |
end; |
| 285 |
except |
|
| 286 |
// exception が発生した場合は内部処理に任せたいのでここでは何もしない |
//===== 内部 |
| 287 |
end; |
if board = nil then |
| 288 |
|
// ※作っても、追加するカテゴリが無いので激しく保留 |
| 289 |
//===== 内部 |
board := TBoard.Create( nil, Node.Attributes[ 'url' ] ); |
| 290 |
if FavThread.Item = nil then |
|
| 291 |
FavThread.Item := TThreadItem.Create( nil, url ); |
if threadItem = nil then |
| 292 |
|
threadItem := TThreadItem.Create( nil, url ); |
| 293 |
board.Add( FavThread.Item ); |
board.Add( threadItem ); |
| 294 |
end; |
end; |
| 295 |
end; |
end; |
| 296 |
end; |
FavThread := TFavoriteThreadItem.Create( threadItem.URL, Node.Attributes['title'], threadItem ); |
|
FavThread.Title := Node.Attributes['title']; |
|
| 297 |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread); |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread); |
| 298 |
CurrentNode.ImageIndex := 16; |
CurrentNode.ImageIndex := 16; |
| 299 |
CurrentNode.SelectedIndex := 16; |
CurrentNode.SelectedIndex := 16; |
| 314 |
XMLNode: IXMLNode; |
XMLNode: IXMLNode; |
| 315 |
// FavoNode: IXMLNode; |
// FavoNode: IXMLNode; |
| 316 |
begin |
begin |
| 317 |
XMLDoc := NewXMLDocument; |
XMLDoc := NewXMLDocument; |
| 318 |
XMLDoc.Encoding := 'Shift_JIS'; |
XMLDoc.Encoding := 'Shift_JIS'; |
| 319 |
XMLDoc.StandAlone := 'yes'; |
XMLDoc.StandAlone := 'yes'; |
| 320 |
XMLNode := XMLDoc.AddChild('favorite'); |
XMLNode := XMLDoc.AddChild('favorite'); |
| 384 |
begin |
begin |
| 385 |
for i := 0 to Node.Count - 1 do begin |
for i := 0 to Node.Count - 1 do begin |
| 386 |
if TObject(Node.Item[i].Data) is TFavoriteFolder then begin |
if TObject(Node.Item[i].Data) is TFavoriteFolder then begin |
| 387 |
if Node.Item[ i ].Expanded then |
if Node.Item[ i ].Expanded then |
| 388 |
s := Format('<folder title="%s" expanded="true">', [HttpEncode(Node.Item[i].Text)]) |
s := Format('<folder title="%s" expanded="true">', [HttpEncode(Node.Item[i].Text)]) |
| 389 |
else |
else |
| 390 |
s := Format('<folder title="%s" expanded="false">', [HttpEncode(Node.Item[i].Text)]); |
s := Format('<folder title="%s" expanded="false">', [HttpEncode(Node.Item[i].Text)]); |
| 391 |
SaveList.Add(s); |
SaveList.Add(s); |
| 392 |
AddSaveString(Node.Item[i], SaveList); |
AddSaveString(Node.Item[i], SaveList); |
| 394 |
end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin |
end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin |
| 395 |
FavBoard := TFavoriteBoardItem(Node.Item[i].Data); |
FavBoard := TFavoriteBoardItem(Node.Item[i].Data); |
| 396 |
s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>', |
s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>', |
| 397 |
[HttpEncode( FavBoard.Item.URL ), HttpEncode(FavBoard.Title)]); |
[HttpEncode( FavBoard.URL ), HttpEncode(FavBoard.Title)]); |
| 398 |
SaveList.Add(s); |
SaveList.Add(s); |
| 399 |
end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin |
end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin |
| 400 |
FavThread := TFavoriteThreadItem(Node.Item[i].Data); |
FavThread := TFavoriteThreadItem(Node.Item[i].Data); |
| 401 |
s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>', |
s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>', |
| 402 |
[HttpEncode( FavThread.Item.URL ), HttpEncode(FavThread.Title)]); |
[HttpEncode( FavThread.URL ), HttpEncode(FavThread.Title)]); |
| 403 |
SaveList.Add(s); |
SaveList.Add(s); |
| 404 |
end; |
end; |
| 405 |
end; |
end; |
| 476 |
function TFavoriteDM.SaveFavoriteFile(FileName: String) : Boolean; |
function TFavoriteDM.SaveFavoriteFile(FileName: String) : Boolean; |
| 477 |
var |
var |
| 478 |
FavoriteFilePath: string; |
FavoriteFilePath: string; |
| 479 |
tempStringList: TStringList; |
tempStringList: TStringList; |
| 480 |
begin |
begin |
| 481 |
|
|
| 482 |
FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME; |
| 483 |
|
|
| 484 |
if FileExists( FavoriteFilePath ) then begin |
if FileExists( FavoriteFilePath ) then begin |
| 485 |
tempStringList := TStringList.Create; |
tempStringList := TStringList.Create; |
| 486 |
try |
try |
| 487 |
tempStringList.LoadFromFile( FavoriteFilePath ); |
tempStringList.LoadFromFile( FavoriteFilePath ); |
| 488 |
tempStringList.SaveToFile( FileName ); |
tempStringList.SaveToFile( FileName ); |
| 489 |
finally |
finally |
| 490 |
tempStringList.Free; |
tempStringList.Free; |
| 491 |
end; |
end; |
| 492 |
Result := true; |
Result := true; |
| 493 |
end else begin |
end else begin |
| 494 |
Result := false; |
Result := false; |
| 495 |
end; |
end; |
| 496 |
end; |
end; |
| 497 |
|
|
| 498 |
function TFavoriteDM.GetFavoriteFilePath() : String; |
function TFavoriteDM.GetFavoriteFilePath() : String; |