OSDN Git Service

・お気に入りの読み込みを高速化。
authoryoffy <yoffy>
Sun, 23 Nov 2003 09:25:26 +0000 (09:25 +0000)
committeryoffy <yoffy>
Sun, 23 Nov 2003 09:25:26 +0000 (09:25 +0000)
BoardGroup.pas
Favorite.pas
GikoSystem.pas
gikoNavi.res

index a18230a..c74a185 100644 (file)
@@ -380,14 +380,13 @@ const
 //     COLUMN_THREADITEM: array[0..3] of string = ('\83X\83\8c\83b\83h\96¼', '\83J\83E\83\93\83g', '\8f\84\89ñ\97\\96ñ', '\91O\89ñ\8f\84\89ñ\93ú\8e\9e');
 
 function       BBSsFindBoardFromBBSID(
-       inBBSID         : string
+       inBBSID : string
 ) : TBoard;
 var
-       i, bound        : Integer;
+       i                               : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindBBSID( inBBSID );
                if Result <> nil then
                        Exit;
@@ -398,14 +397,13 @@ begin
 end;
 
 function       BBSsFindBoardFromURL(
-       inURL                   : string
+       inURL   : string
 ) : TBoard;
 var
-       i, bound        : Integer;
+       i                       : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindBoardFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -416,14 +414,13 @@ begin
 end;
 
 function       BBSsFindBoardFromTitle(
-       inTitle         : string
+       inTitle : string
 ) : TBoard;
 var
-       i, bound        : Integer;
+       i                               : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindBoardFromTitle( inTitle );
                if Result <> nil then
                        Exit;
@@ -434,14 +431,13 @@ begin
 end;
 
 function       BBSsFindThreadFromURL(
-       inURL                   : string
+       inURL   : string
 ) : TThreadItem;
 var
-       i, bound        : Integer;
+       i                       : Integer;
 begin
 
-       bound := Length( BBSs ) - 1;
-       for i := 0 to bound do begin
+       for i := Length( BBSs ) - 1 downto 0 do begin
                Result := BBSs[ i ].FindThreadFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -514,19 +510,14 @@ end;
 
 function TBBS.FindBBSID(BBSID: string): TBoard;
 var
-       i: Integer;
-       Category: TCategory;
-       Board: TBoard;
+       i       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBBSID(BBSID);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBBSID(BBSID);
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -535,18 +526,13 @@ end;
 function TBBS.FindBoardFromTitle(Title: string): TBoard;
 var
        i: Integer;
-       Category: TCategory;
-       Board: TBoard;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBoardFromTitle(Title);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromTitle(Title);
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -554,19 +540,14 @@ end;
 //*************************************************************************)
 function TBBS.FindBoardFromURL(inURL: string): TBoard;
 var
-       i: Integer;
-       Category: TCategory;
-       Board: TBoard;
+       i                                       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBoardFromURL(inURL);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromURL( inURL );
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -574,9 +555,9 @@ end;
 //*************************************************************************)
 function TBBS.FindThreadFromURL(inURL: string): TThreadItem;
 var
-       i: Integer;
+       i       : Integer;
 begin
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                Result := Items[ i ].FindThreadFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -673,15 +654,15 @@ end;
 
 function TCategory.FindBBSID(BBSID: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Items[i].FBBSID = BBSID then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -689,15 +670,15 @@ end;
 //*************************************************************************)
 function TCategory.FindBoardFromTitle(Title: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Items[i].FTitle = Title then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -705,15 +686,15 @@ end;
 //*************************************************************************)
 function TCategory.FindBoardFromURL(inURL: string): TBoard;
 var
-       i: integer;
+       i       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Pos( Items[i].URL, inURL ) = 1 then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
 //*************************************************************************
@@ -724,7 +705,7 @@ var
        i                                               : Integer;
 begin
 
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                Result := Items[ i ].FindThreadFromURL( inURL );
                if Result <> nil then
                        Exit;
@@ -955,7 +936,7 @@ begin
        if not IsThreadDatRead then
                GikoSys.ReadSubjectFile( Self );
                
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Pos( Items[ i ].URL, inURL ) = 1 then begin
                        Result := Items[ i ];
                        Exit;
index 0f31479..6f8d4fb 100644 (file)
@@ -16,9 +16,10 @@ type
                FItem                           : TBoard;
                FURL                            : string;
                FTitle                  : string;
+               function        GetItem : TBoard;
        public
                constructor Create( inURL : string; inTitle : string = ''; inItem : TBoard = nil );
-               property Item                           : TBoard        read FItem write FItem;
+               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;
        end;
@@ -28,9 +29,10 @@ type
                FItem                           : TThreadItem;
                FURL                            : string;
                FTitle                  : string;
+               function        GetItem : TThreadItem;
        public
                constructor Create( inURL : string; inTitle : string = ''; inItem : TThreadItem = nil );
-               property Item                           : TThreadItem   read FItem write FItem;
+               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;
        end;
@@ -91,6 +93,21 @@ begin
 
 end;
 
+function       TFavoriteBoardItem.GetItem : TBoard;
+begin
+
+       if FItem = nil then begin
+               FItem := BBSsFindBoardFromURL( URL );
+               // \8b\8c\8e®\82Ì\82¨\8bC\82É\93ü\82è\82Æ\82Ì\8cÝ\8a·\90«\82Ì\82½\82ß
+               if FItem = 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¯
+                       FItem := TBoard.Create( nil, URL );
+       end;
+
+       Result := FItem;
+
+end;
+
 constructor TFavoriteThreadItem.Create(
        inURL           : string;
        inTitle : string = '';
@@ -106,6 +123,57 @@ begin
 
 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 );
+
+               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, boardURL )
+               else
+                       FItem := board.FindThreadFromURL( URL );
+
+               if FItem = nil then
+                       FItem := TThreadItem.Create( boardPlugIn, URL );
+
+               FItem.Title := Title;
+               board.Add( FItem );
+       end;
+
+       Result := FItem;
+
+end;
+
 procedure TFavoriteDM.DataModuleCreate(Sender: TObject);
 begin
        //FTreeView := TreeView;
@@ -230,73 +298,41 @@ begin
                ParentNode := FStack.Peek;
                if TObject(ParentNode.Data) is TFavoriteFolder then begin
                        if Node.Attributes['favtype'] = 'board' then begin
-                               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;
+                               if Length( Node.Attributes[ 'bbs' ] ) > 0 then begin
+                                       board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] );
+                                       FavBoard := TFavoriteBoardItem.Create(
+                                               board.URL, Node.Attributes[ 'title' ], board );
+                               end else begin
+                                       FavBoard := TFavoriteBoardItem.Create(
+                                               Node.Attributes[ 'url' ], Node.Attributes[ 'title' ], board );
                                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' ];
-                               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' ], '' ) ) );
-                                                       threadItem.Title := Node.Attributes[ 'title' ];
-                                                       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 );
-
+                               if Length( Node.Attributes[ 'bbs' ] ) > 0 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' ], '' ) ) );
                                                threadItem.Title := Node.Attributes[ 'title' ];
                                                board.Add( threadItem );
                                        end;
+                                       FavThread := TFavoriteThreadItem.Create(
+                                               threadItem.URL, Node.Attributes[ 'title' ], threadItem );
+                               end else begin
+                                       FavThread := TFavoriteThreadItem.Create(
+                                               Node.Attributes[ 'url' ], Node.Attributes[ 'title' ], threadItem );
                                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;
index 201ad1e..ca24c5c 100644 (file)
@@ -520,17 +520,27 @@ begin
                        sl.LoadFromFile(FileName);
 
                //\82Q\8ds\96Ú\82©\82ç\81i\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93\81j
-               for i := 1 to sl.Count - 1 do begin
+               for i := sl.Count - 1 downto 0 do begin
                        Rec := ParseIndexLine(sl[i]);
 
                        if usePlugIn then
                                ThreadItem := TThreadItem.Create(
                                        Board.BoardPlugIn,
                                        Board.BoardPlugIn.FileName2ThreadURL( DWORD( Board ), Rec.FFileName ) )
-                       else
+                       else begin
                                ThreadItem := TThreadItem.Create(
                                        nil,
                                        Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
+                               
+                               //IsLogFile\83`\83F\83b\83N
+                               ThreadItem.IsLogFile := False;
+                               if FileList.Count <> 0 then begin
+                                       if FileList.Find( ThreadItem.FileName, Index ) then begin
+                                               ThreadItem.IsLogFile := True;
+                                               FileList.Delete( Index );
+                                       end;
+                               end;
+                       end;
                        ThreadItem.BeginUpdate;
                        ThreadItem.No := Rec.FNo;
                        ThreadItem.FileName := Rec.FFileName;
@@ -550,15 +560,6 @@ begin
                        ThreadItem.AgeSage := Rec.FAgeSage;
                        ThreadItem.ParentBoard := Board;
 
-                       //IsLogFile\83`\83F\83b\83N
-                       ThreadItem.IsLogFile := False;
-                       if FileList.Count <> 0 then begin
-                               if FileList.Find(ThreadItem.FileName, Index) then begin
-                                       ThreadItem.IsLogFile := True;
-                                       FileList.Delete(Index);
-                               end;
-                       end;
-
                        //\8f\84\89ñ\83\8a\83X\83g\82É\91\8dÝ\82µ\82½\82ç\8f\84\89ñ\83t\83\89\83O\83Z\83b\83g
                        if ThreadItem.IsLogFile then begin
                                idx := RoundList.Find(ThreadItem);
index 09f2287..592fb82 100644 (file)
Binary files a/gikoNavi.res and b/gikoNavi.res differ