TFavoriteBoardItem = class
private
FItem : TBoard;
+ FURL : string;
FTitle : string;
public
+ constructor Create( inURL : string; inTitle : string = ''; inItem : TBoard = nil );
property Item : TBoard read FItem write FItem;
+ property URL : string read FURL write FURL; // Item \82ª\8eæ\93¾\82Å\82«\82È\82\82Ä\82à URL \82Í\8fí\82É\95Û\8e\9d\82³\82ê\82é
property Title : string read FTitle write FTitle;
end;
TFavoriteThreadItem = class
private
FItem : TThreadItem;
+ FURL : string;
FTitle : string;
public
+ constructor Create( inURL : string; inTitle : string = ''; inItem : TThreadItem = nil );
property Item : TThreadItem read FItem write FItem;
+ property URL : string read FURL write FURL; // Item \82ª\8eæ\93¾\82Å\82«\82È\82\82Ä\82à URL \82Í\8fí\82É\95Û\8e\9d\82³\82ê\82é
property Title : string read FTitle write FTitle;
end;
// procedure SAXCharacters(Sender: TObject; const PCh: SAXString);
public
{ Public \90é\8c¾ }
- function GetFavoriteFilePath() : String;
- function SaveFavoriteFile(FileName: String) : Boolean;
+ function GetFavoriteFilePath() : String;
+ function SaveFavoriteFile(FileName: String) : Boolean;
procedure SetFavTreeView(TreeView: TTreeView);
procedure ReadFavorite;
procedure WriteFavorite;
{$R *.dfm}
+constructor TFavoriteBoardItem.Create(
+ inURL : string;
+ inTitle : string = '';
+ inItem : TBoard = nil
+);
+begin
+
+ inherited Create;
+
+ URL := inURL;
+ Title := inTitle;
+ Item := inItem;
+
+end;
+
+constructor TFavoriteThreadItem.Create(
+ inURL : string;
+ inTitle : string = '';
+ inItem : TThreadItem = nil
+);
+begin
+
+ inherited Create;
+
+ URL := inURL;
+ Title := inTitle;
+ Item := inItem;
+
+end;
+
procedure TFavoriteDM.DataModuleCreate(Sender: TObject);
begin
//FTreeView := TreeView;
procedure TFavoriteDM.ReadNode(Node: IXMLNode);
var
i: Integer;
- j, jBound : Integer;
+ j, jBound : Integer;
ParentNode: TTreeNode;
CurrentNode: TTreeNode;
FavFolder: TFavoriteFolder;
FavBoard: TFavoriteBoardItem;
FavThread: TFavoriteThreadItem;
- board : TBoard;
- url : string;
+ board : TBoard;
+ threadItem : TThreadItem;
+ url : string;
begin
if Node.NodeName = 'folder' then begin
ParentNode := FStack.Peek;
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder);
CurrentNode.ImageIndex := 14;
CurrentNode.SelectedIndex := 14;
- CurrentNode.Expanded := Node.Attributes[ 'expanded' ] = 'true';
+ CurrentNode.Expanded := Node.Attributes[ 'expanded' ] = 'true';
FStack.Push(CurrentNode);
end;
for i := 0 to Node.ChildNodes.Count - 1 do begin
ParentNode := FStack.Peek;
if TObject(ParentNode.Data) is TFavoriteFolder then begin
if Node.Attributes['favtype'] = 'board' then begin
- FavBoard := TFavoriteBoardItem.Create;
- FavBoard.Item := BBSsFindBoardFromURL( Node.Attributes[ 'url' ] );
- // \8b\8c\8e®\82Ì\82¨\8bC\82É\93ü\82è\82Æ\82Ì\8cÝ\8a·\90«\82Ì\82½\82ß
- if FavBoard.Item = nil then begin
- if Node.Attributes[ 'url' ] = '' then begin
- FavBoard.Item := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
- if FavBoard.Item = nil then begin
- FavBoard.Free;
- Exit;
- end;
- end else begin
- // \81¦\8dì\82Á\82Ä\82à\81A\92Ç\89Á\82·\82é\83J\83e\83S\83\8a\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82\95Û\97¯
- //FavBoard.Item := TBoard.Create( nil, Node.Attributes[ 'url' ] );
- end;
- end;
- FavBoard.Title := Node.Attributes['title'];
+ board := BBSsFindBoardFromURL( Node.Attributes[ 'url' ] );
+ // \8b\8c\8e®\82Ì\82¨\8bC\82É\93ü\82è\82Æ\82Ì\8cÝ\8a·\90«\82Ì\82½\82ß
+ if board = nil then begin
+ if Node.Attributes[ 'url' ] = '' then begin
+ board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
+ if board = nil then
+ Exit;
+ end else begin
+ // \81¦\8dì\82Á\82Ä\82à\81A\92Ç\89Á\82·\82é\83J\83e\83S\83\8a\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82\95Û\97¯
+ board := TBoard.Create( nil, Node.Attributes[ 'url' ] );
+ end;
+ end;
+ FavBoard := TFavoriteBoardItem.Create( board.URL, Node.Attributes['title'], board );
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard);
CurrentNode.ImageIndex := 15;
CurrentNode.SelectedIndex := 15;
end else if Node.Attributes['favtype'] = 'thread' then begin
- url := Node.Attributes[ 'url' ];
- FavThread := TFavoriteThreadItem.Create;
- FavThread.Item := BBSsFindThreadFromURL( url );
- // \8b\8c\8e®\82Ì\82¨\8bC\82É\93ü\82è\82Æ\82Ì\8cÝ\8a·\90«\82Ì\82½\82ß
- if FavThread.Item = nil then begin
- if Node.Attributes[ 'url' ] = '' then begin
- board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
- if board = nil then begin
- FavThread.Free;
- Exit;
- end;
- if not board.IsThreadDatRead then
- GikoSys.ReadSubjectFile( board );
- FavThread.Item := board.Find( Node.Attributes[ 'thread' ] );
- if FavThread.Item = nil then begin
- FavThread.Item := TThreadItem.Create(
- board.BoardPlugIn,
- GikoSys.Get2chBoard2ThreadURL( board, ChangeFileExt( Node.Attributes[ 'thread' ], '' ) ) );
- board.Add( FavThread.Item )
- end;
- end else begin
- board := BBSsFindBoardFromURL( GikoSys.Get2chThreadURL2BoardURL( url ) );
- if board <> nil then begin
- //===== \83v\83\89\83O\83C\83\93
- try
- jBound := Length( BoardPlugIns ) - 1;
- for j := 0 to jBound do begin
- if Assigned( Pointer( BoardPlugIns[ j ].Module ) ) then begin
- if BoardPlugIns[ j ].AcceptURL( url ) = atThread then begin
- FavThread.Item := TThreadItem.Create( BoardPlugIns[ j ], url );
-
- Break;
- end;
- end;
- end;
- except
- // exception \82ª\94\90¶\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
- end;
-
- //===== \93à\95\94
- if FavThread.Item = nil then
- FavThread.Item := TThreadItem.Create( nil, url );
-
- board.Add( FavThread.Item );
- end;
- end;
- end;
- FavThread.Title := Node.Attributes['title'];
+ url := Node.Attributes[ 'url' ];
+ threadItem := BBSsFindThreadFromURL( url );
+ // \8b\8c\8e®\82Ì\82¨\8bC\82É\93ü\82è\82Æ\82Ì\8cÝ\8a·\90«\82Ì\82½\82ß
+ if threadItem = nil then begin
+ if Node.Attributes[ 'url' ] = '' then begin
+ board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
+ if board = nil then
+ Exit;
+ if not board.IsThreadDatRead then
+ GikoSys.ReadSubjectFile( board );
+ threadItem := board.Find( Node.Attributes[ 'thread' ] );
+ if threadItem = nil then begin
+ threadItem := TThreadItem.Create(
+ board.BoardPlugIn,
+ GikoSys.Get2chBoard2ThreadURL( board, ChangeFileExt( Node.Attributes[ 'thread' ], '' ) ) );
+ board.Add( threadItem );
+ end;
+ end else begin
+ board := BBSsFindBoardFromURL( GikoSys.Get2chThreadURL2BoardURL( url ) );
+
+ //===== \83v\83\89\83O\83C\83\93
+ try
+ jBound := Length( BoardPlugIns ) - 1;
+ for j := 0 to jBound do begin
+ if Assigned( Pointer( BoardPlugIns[ j ].Module ) ) then begin
+ if BoardPlugIns[ j ].AcceptURL( url ) = atThread then begin
+ threadItem := TThreadItem.Create( BoardPlugIns[ j ], url );
+
+ Break;
+ end;
+ end;
+ end;
+ except
+ // exception \82ª\94\90¶\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
+ end;
+
+ //===== \93à\95\94
+ if board = nil then
+ // \81¦\8dì\82Á\82Ä\82à\81A\92Ç\89Á\82·\82é\83J\83e\83S\83\8a\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82\95Û\97¯
+ board := TBoard.Create( nil, Node.Attributes[ 'url' ] );
+
+ if threadItem = nil then
+ threadItem := TThreadItem.Create( nil, url );
+ board.Add( threadItem );
+ end;
+ end;
+ FavThread := TFavoriteThreadItem.Create( threadItem.URL, Node.Attributes['title'], threadItem );
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread);
CurrentNode.ImageIndex := 16;
CurrentNode.SelectedIndex := 16;
XMLNode: IXMLNode;
// FavoNode: IXMLNode;
begin
- XMLDoc := NewXMLDocument;
+ XMLDoc := NewXMLDocument;
XMLDoc.Encoding := 'Shift_JIS';
XMLDoc.StandAlone := 'yes';
XMLNode := XMLDoc.AddChild('favorite');
begin
for i := 0 to Node.Count - 1 do begin
if TObject(Node.Item[i].Data) is TFavoriteFolder then begin
- if Node.Item[ i ].Expanded then
+ if Node.Item[ i ].Expanded then
s := Format('<folder title="%s" expanded="true">', [HttpEncode(Node.Item[i].Text)])
- else
+ else
s := Format('<folder title="%s" expanded="false">', [HttpEncode(Node.Item[i].Text)]);
SaveList.Add(s);
AddSaveString(Node.Item[i], SaveList);
end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin
FavBoard := TFavoriteBoardItem(Node.Item[i].Data);
s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>',
- [HttpEncode( FavBoard.Item.URL ), HttpEncode(FavBoard.Title)]);
+ [HttpEncode( FavBoard.URL ), HttpEncode(FavBoard.Title)]);
SaveList.Add(s);
end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin
FavThread := TFavoriteThreadItem(Node.Item[i].Data);
s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>',
- [HttpEncode( FavThread.Item.URL ), HttpEncode(FavThread.Title)]);
+ [HttpEncode( FavThread.URL ), HttpEncode(FavThread.Title)]);
SaveList.Add(s);
end;
end;
function TFavoriteDM.SaveFavoriteFile(FileName: String) : Boolean;
var
FavoriteFilePath: string;
- tempStringList: TStringList;
+ tempStringList: TStringList;
begin
FavoriteFilePath := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;
if FileExists( FavoriteFilePath ) then begin
- tempStringList := TStringList.Create;
+ tempStringList := TStringList.Create;
try
- tempStringList.LoadFromFile( FavoriteFilePath );
- tempStringList.SaveToFile( FileName );
+ tempStringList.LoadFromFile( FavoriteFilePath );
+ tempStringList.SaveToFile( FileName );
finally
- tempStringList.Free;
+ tempStringList.Free;
end;
- Result := true;
+ Result := true;
end else begin
- Result := false;
- end;
+ Result := false;
+ end;
end;
function TFavoriteDM.GetFavoriteFilePath() : String;