OSDN Git Service

・TBoard および TCategory の親クラスを TList から THashedStringList に変更。
authoryoffy <yoffy>
Sat, 10 Apr 2004 13:53:00 +0000 (13:53 +0000)
committeryoffy <yoffy>
Sat, 10 Apr 2004 13:53:00 +0000 (13:53 +0000)
BoardGroup.pas
Favorite.pas
Giko.pas
ItemDownload.pas
Sort.pas

index 084cdd9..6cb8092 100644 (file)
@@ -111,8 +111,8 @@ type
                property        IsBoardFileRead : Boolean read FIsBoardFileRead write FIsBoardFileRead;
        end;
 
-       //\83J\83e\83S\83\8a
-       TCategory = class(TList)
+       // \83J\83e\83S\83\8a(\94 URL \82Ì\83\8a\83X\83g)
+       TCategory = class(THashedStringList)
        private
                FNo: Integer;
                FTitle: string;
@@ -143,10 +143,10 @@ type
                property NodeExpand: Boolean read FExpand write FExpand;
        end;
 
-       //\94Â
-       TBoard = class(TList)
+       // \94Â(\83X\83\8c\83b\83h URL \82Ì\83\8a\83X\83g)
+       TBoard = class(THashedStringList)
        private
-               FContext: DWORD;                                        // \83v\83\89\83O\83C\83\93\82ª\8e©\97R\82É\90Ý\92è\82µ\82Ä\82¢\82¢\92l(\8eå\82É\83C\83\93\83X\83^\83\93\83X\82ª\93ü\82é)
+               FContext: DWORD;                                                        // \83v\83\89\83O\83C\83\93\82ª\8e©\97R\82É\90Ý\92è\82µ\82Ä\82¢\82¢\92l(\8eå\82É\83C\83\93\83X\83^\83\93\83X\82ª\93ü\82é)
 
                FNo: Integer;                                                                   //\94Ô\8d\86
                FTitle: string;                                                         //\83{\81[\83h\83^\83C\83g\83\8b
@@ -159,7 +159,7 @@ type
                FLastGetTime: TDateTime;                        //\83X\83\8c\83b\83h\82Ü\82½\82Í\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\8cã\82É\8dX\90V\82µ\82½\93ú\8e\9e\81i\83T\81[\83o\91¤\93ú\8e\9e\81E\8f\91\82«\8d\9e\82Ý\8e\9e\82É\8eg\97p\82·\82é\81j
                FIsThreadDatRead: Boolean;              //\83X\83\8c\83b\83h\83\8a\83X\83g\82Í\93Ç\82Ý\8d\9e\82Ü\82ê\82Ä\82¢\82é\82©\81H
                FUnRead: Integer;                                                       //\83X\83\8c\83b\83h\96¢\93Ç\90\94
-               FParentCategory: TCategory;      //\90e\83J\83e\83S\83\8a
+               FParentCategory: TCategory;             //\90e\83J\83e\83S\83\8a
                FModified: Boolean;                                             //\8fC\90³\83t\83\89\83O
                FBoolData: Boolean;                                             //\82¢\82ë\82ñ\82È\97p\93r\82É\8eg\82¤yo
                FSPID: string;                                                          //\8f\91\82«\8d\9e\82Ý\97pSPID
@@ -219,9 +219,9 @@ type
                procedure Delete(index: integer);
                procedure DeleteList(index: integer);
                procedure Clear; override;
-               function Find(ItemFileName: string): TThreadItem;
+               function FindThreadFromFileName(ItemFileName: string): TThreadItem;
                function FindThreadFromURL( inURL : string ) : TThreadItem;
-               function GetIndex(ItemFileName: string): Integer;
+               function GetIndexFromFileName(ItemFileName: string): Integer;
                function GetIndexFromURL(URL: string): Integer;
                procedure LoadSettings;
                procedure SaveSettings;
@@ -585,7 +585,7 @@ begin
        Board := FindBBSID(BBSID);
        if Board = nil then
                Exit;
-       Result := Board.Find(FileName);
+       Result := Board.FindThreadFromFileName(FileName);
 end;
 
 function TBBS.FindCategoryFromTitle( inTitle : string ) : TCategory;
@@ -636,25 +636,25 @@ end;
 
 function TCategory.GetBoard(index: integer): TBoard;
 begin
-       Result := TBoard(inherited Items[index]);
+       Result := TBoard( Objects[index] );
 end;
 
 procedure TCategory.SetBoard(index: integer; value: TBoard);
 begin
-       inherited Items[index] := value;
+       Objects[index] := value;
+       Strings[index] := value.URL
 end;
 
 function TCategory.Add(item: TBoard): integer;
 begin
        Item.ParentCategory := self;
-       Result := inherited Add(item);
+       Result := AddObject( item.URL, item );
 end;
 
 procedure TCategory.Delete(index: integer);
 begin
        if Items[index] <> nil then
                TBoard(Items[index]).Free;
-       Items[index] := nil;
        inherited Delete(index);
 end;
 
@@ -708,13 +708,11 @@ function TCategory.FindBoardFromURL(inURL: string): TBoard;
 var
        i       : Integer;
 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;
+       i := IndexOf( inURL );
+       if i >= 0 then
+               Result := TBoard( Objects[ i ] )
+       else
+               Result := nil;
 end;
 
 //*************************************************************************
@@ -864,24 +862,26 @@ end;
 
 function TBoard.GetThreadItem(index: integer): TThreadItem;
 begin
-       Result := TThreadItem(inherited Items[index]);
+       Result := TThreadItem( Objects[index] );
 end;
 
 procedure TBoard.SetThreadItem(index: integer; value: TThreadItem);
 begin
-       inherited Items[index] := value;
+       Objects[index] := value;
+       Strings[index] := value.URL;
 end;
 
 function TBoard.Add(Item: TThreadItem): Integer;
 begin
        Item.ParentBoard := Self;
-       Result := inherited Add(Item);
+       Result := inherited AddObject(Item.URL, Item);
 end;
 
 procedure TBoard.Insert(Index: Integer; Item: TThreadItem);
 begin
        Item.ParentBoard := Self;
-       inherited Insert(Index, Item);
+       inherited InsertObject(Index, Item.URL, Item);
+
 end;
 
 //Index\82Å\8ew\92è\82³\82ê\82½\83X\83\8c\83b\83h\83I\83u\83W\83F\83N\83g\82ð\94j\8aü
@@ -889,7 +889,6 @@ procedure TBoard.Delete(index: Integer);
 begin
        if Items[index] <> nil then
                TThreadItem(Items[index]).Free;
-       Items[index] := nil;
        inherited Delete(index);
 end;
 
@@ -906,10 +905,10 @@ begin
 //     FUnRead := 0;
        for i := Count - 1 downto 0 do
                Delete(i);
-    Capacity := Count;
+        Capacity := Count;
 end;
 
-function TBoard.Find(ItemFileName: string): TThreadItem;
+function TBoard.FindThreadFromFileName(ItemFileName: string): TThreadItem;
 var
        i: integer;
 begin
@@ -922,7 +921,7 @@ begin
        end;
 end;
 
-function TBoard.GetIndex(ItemFileName: string): Integer;
+function TBoard.GetIndexFromFileName(ItemFileName: string): Integer;
 var
        i: integer;
 begin
@@ -936,16 +935,8 @@ begin
 end;
 
 function TBoard.GetIndexFromURL(URL: string): Integer;
-var
-       i: integer;
 begin
-       Result := -1;
-       for i := 0 to Count - 1 do begin
-               if Pos( URL, Items[ i ].URL ) = 1 then begin
-                       Result := i;
-                       Exit;
-               end;
-       end;
+       Result := IndexOf( URL );
 end;
 
 function TBoard.FindThreadFromURL( inURL : string ) : TThreadItem;
@@ -955,14 +946,12 @@ begin
 
        if not IsThreadDatRead then
                GikoSys.ReadSubjectFile( Self );
-               
-       for i := Count - 1 downto 0 do begin
-               if Pos( inURL, Items[ i ].URL ) = 1 then begin
-                       Result := Items[ i ];
-                       Exit;
-               end;
-       end;
-       Result := nil;
+
+       i := IndexOf( inURL );
+       if i >= 0 then
+               Result := TThreadItem( Objects[ i ] )
+       else
+               Result := nil;
 
 end;
 
index c8ffcee..42d9086 100644 (file)
@@ -378,7 +378,7 @@ begin
 
                                                if not board.IsThreadDatRead then
                                                        GikoSys.ReadSubjectFile( board );
-                                               threadItem := board.Find( Node.Attributes[ 'thread' ] );
+                                               threadItem := board.FindThreadFromFileName( Node.Attributes[ 'thread' ] );
                                                if threadItem = nil then begin
                                                        threadItem := TThreadItem.Create(
                                                                board.BoardPlugIn,
index bb3e3a9..39e1b0b 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -2545,7 +2545,7 @@ begin
                                if (threadItem = nil) and GikoSys.Is2chHost( Host ) then begin
                                        board := BBSs[ 0 ].FindBBSID( PathRec.FBBS );
                                        if board <> nil then
-                                               threadItem := board.Find( PathRec.FKey + '.dat' );
+                                               threadItem := board.FindThreadFromFileName( PathRec.FKey + '.dat' );
 
                                end;
                 
@@ -2673,7 +2673,7 @@ begin
                wkCategory := TCategory( FActiveList );
                Sort.SortOrder := FSortOrder;
                Sort.SortIndex := Column.Index;
-               wkCategory.Sort(BoardSortProc);
+               wkCategory.CustomSort(BoardSortProc);
                ListView.Refresh;
        //end else if TObject(TreeView.Selected.Data) is TBoard then begin
        end else if TObject( FActiveList ) is TBoard then begin
@@ -2681,7 +2681,7 @@ begin
                wkBoard := TBoard( FActiveList );
                Sort.SortOrder := FSortOrder;
                Sort.SortIndex := Column.Index;
-               wkBoard.Sort(ThreadItemSortProc);
+               wkBoard.CustomSort(ThreadItemSortProc);
                ListView.Refresh;
        end;
        FSortIndex := Column.Index;
@@ -6609,7 +6609,7 @@ begin
                                                        end;
                                                end;
 
-                                               ThreadItem := Board.Find( tmpThread.FileName );
+                                               ThreadItem := Board.FindThreadFromFileName( tmpThread.FileName );
                                                if ThreadItem = nil then begin
                                                        ThreadItem := tmpThread;
                                                        Board.Insert( 0, ThreadItem );
@@ -6674,7 +6674,7 @@ begin
                ThreadItem := Board.FindThreadFromURL( URL );
                //\81@\89ß\8b\8e\83\8d\83O\91q\8cÉ\82©\82ç\81A\83_\83E\83\\82µ\82½\83X\83\8c\82ª\94­\8c©\82Å\82«\82È\82¢\82Ì\82Å\82±\82±\82Å\92T\82·\82æ\82¤\82É\82·\82é (2004/01/22)
                if ThreadItem = nil then begin
-                       ThreadItem := Board.Find( BBSKey + '.dat' );
+                       ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
                end;
 
                if ThreadItem = nil then begin
index 0991ca1..6494dc9 100644 (file)
@@ -972,7 +972,7 @@ begin
                                Rec.FFileName := Trim(Rec.FFileName);
                                if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
                                Inc(NumCount);
-                               index := Board.GetIndex(Rec.FFileName);
+                               index := Board.GetIndexFromFileName(Rec.FFileName);
                                if index = -1 then begin
                                        //\90V\82µ\82¢\83X\83\8c\83b\83h
                                        NewItem := TThreadItem.Create(
index 944e0c3..1b56834 100644 (file)
--- a/Sort.pas
+++ b/Sort.pas
@@ -6,8 +6,8 @@ uses
        BoardGroup,DateUtils;
 
        function CategorySortProc(Item1, Item2: Pointer): integer;
-       function BoardSortProc(Item1, Item2: Pointer): integer;
-       function ThreadItemSortProc(Item1, Item2: Pointer): integer;
+       function BoardSortProc(List: TStringList; Item1, Item2: Integer): integer;
+       function ThreadItemSortProc(List: TStringList; Item1, Item2: Integer): integer;
        function CompareBool(Item1, Item2: Boolean): integer;
        function CompareInt(Item1, Item2: Integer): Integer;
        function CompareDate(Item1, Item2: TDateTime): Integer;
@@ -36,13 +36,13 @@ begin
                Result := Result * -1;
 end;
 
-function BoardSortProc(Item1, Item2: Pointer): integer;
+function BoardSortProc(List: TStringList; Item1, Item2: Integer): integer;
 var
        BoardItem1: TBoard;
        BoardItem2: TBoard;
 begin
-       BoardItem1 := TBoard(Item1);
-       BoardItem2 := TBoard(Item2);
+       BoardItem1 := TBoard(List.Objects[Item1]);
+       BoardItem2 := TBoard(List.Objects[Item2]);
        if SortIndex = 0 then
                if SortNoFlag then
                        Result := CompareInt(BoardItem1.No, BoardItem2.No)
@@ -57,13 +57,13 @@ begin
                Result := Result * -1;
 end;
 
-function ThreadItemSortProc(Item1, Item2: Pointer): integer;
+function ThreadItemSortProc(List: TStringList; Item1, Item2: Integer): integer;
 var
        ThreadItem1: TThreadItem;
        ThreadItem2: TThreadItem;
 begin
-       ThreadItem1 := TThreadItem(Item1);
-       ThreadItem2 := TThreadItem(Item2);
+       ThreadItem1 := TThreadItem(List.Objects[ Item1 ]);
+       ThreadItem2 := TThreadItem(List.Objects[ Item2 ]);
        case SortIndex of
                0:
                        begin