OSDN Git Service

・お気に入りの名前を変更したときに変更が適用されるように修正。
[gikonavigoeson/gikonavi.git] / Favorite.pas
index 7bbe895..cdd6670 100644 (file)
@@ -19,6 +19,7 @@ type
                function        GetItem : TBoard;
        public
                constructor Create( inURL : string; inTitle : string = ''; inItem : TBoard = nil );
+               constructor CreateWithItem( inItem : TBoard );
                property Item                           : TBoard        read GetItem 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;
@@ -32,6 +33,7 @@ type
                function        GetItem : TThreadItem;
        public
                constructor Create( inURL : string; inTitle : string = ''; inItem : TThreadItem = nil );
+               constructor CreateWithItem( inItem : TThreadItem );
                property Item                           : TThreadItem   read GetItem 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;
@@ -93,6 +95,15 @@ begin
 
 end;
 
+constructor TFavoriteBoardItem.CreateWithItem(
+       inItem  : TBoard
+);
+begin
+
+       Create( inItem.URL, inItem.Title, inItem );
+
+end;
+
 function       TFavoriteBoardItem.GetItem : TBoard;
 begin
 
@@ -123,39 +134,26 @@ begin
 
 end;
 
+constructor TFavoriteThreadItem.CreateWithItem(
+       inItem  : TThreadItem
+);
+begin
+
+       Create( inItem.URL, inItem.Title, inItem );
+
+end;
+
 function       TFavoriteThreadItem.GetItem : TThreadItem;
 var
        threadItem      : TThreadItem;
-       boardPlugIn     : TBoardPlugIn;
        board                           : TBoard;
        boardURL                : string;
        i                                               : Integer;
 begin
 
        if FItem = nil then begin
-               //===== \83v\83\89\83O\83C\83\93
-               boardPlugIn     := nil;
-               try
-                       for i := Length( BoardPlugIns ) - 1 downto 0 do begin
-                               if Assigned( Pointer( BoardPlugIns[ i ].Module ) ) then begin
-                                       if BoardPlugIns[ i ].AcceptURL( url ) = atThread then begin
-                                               boardPlugIn := BoardPlugIns[ i ];
-                                               threadItem      := TThreadItem.Create(boardPlugIn, URL );
-                                               boardURL                := BoardPlugIns[ i ].GetBoardURL( Longword( threadItem ) );
-                                               threadItem.Free;
-
-                                               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;
-
-               if Length( boardURL ) = 0 then
-                       boardURL := GikoSys.Get2chThreadURL2BoardURL( URL );
-
-               board   := BBSsFindBoardFromURL( boardURL );
+               boardURL        := GikoSys.GetThreadURL2BoardURL( URL );
+               board                   := BBSsFindBoardFromURL( boardURL );
 
                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¯
@@ -164,7 +162,7 @@ begin
                        FItem := board.FindThreadFromURL( URL );
 
                if FItem = nil then begin
-                       FItem := TThreadItem.Create( boardPlugIn, URL );
+                       FItem := TThreadItem.Create( board.BoardPlugIn, URL );
 
                        FItem.Title := Title;
                        board.Add( FItem );
@@ -425,21 +423,21 @@ 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
-                               s := Format('<folder title="%s" expanded="true">', [HttpEncode(Node.Item[i].Text)])
+                               s := Format('<folder title="%s" expanded="true">', [HtmlEncode(Node.Item[i].Text)])
                        else
-                               s := Format('<folder title="%s" expanded="false">', [HttpEncode(Node.Item[i].Text)]);
+                               s := Format('<folder title="%s" expanded="false">', [HtmlEncode(Node.Item[i].Text)]);
                        SaveList.Add(s);
                        AddSaveString(Node.Item[i], SaveList);
                        SaveList.Add('</folder>');
                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.URL ), HttpEncode(FavBoard.Title)]);
+                                                                       [HtmlEncode( FavBoard.URL ), HtmlEncode(Node.Item[ i ].Text)]);
                        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.URL ), HttpEncode(FavThread.Title)]);
+                                                                       [HtmlEncode( FavThread.URL ), HtmlEncode(Node.Item[ i ].Text)]);
                        SaveList.Add(s);
                end;
        end;