OSDN Git Service

・板一覧更新の処理メッセージを追加
[gikonavigoeson/gikonavi.git] / ListViewUtils.pas
index d0fe51e..07f8bbd 100644 (file)
@@ -10,27 +10,31 @@ type
        TListViewUtils = class(TObject)
        private
                {Private \90é\8c¾}
+
+               class procedure DrawCategoryItem(BBS: TBBS; Item: TListItem; ListView: TListView);
+               class procedure DrawBoardItem(Category: TCategory; Item: TListItem; ListView: TListView);
+               class procedure DrawThreadItem(Board: TBoard; Item: TListItem; ListView: TListView);
+               class procedure DrawItemLogThread(Thread: TThreadItem; Item: TListItem; ColumnCount: Integer);
+               class procedure DrawItemNoLogThread(Thread: TThreadItem; Item: TListItem; ColumnCount: Integer);
        public
                {Public \90é\8c¾}
                class procedure SetBoardTreeNode(inBBS : TBBS; treeView: TTreeView);
                class function SetCategoryListItem(ABBS2ch: TBBS; ListView: TListView;
-                       NumberVisible: Boolean; var vSortIndex: Integer; var vSortOrder: Boolean): Integer;
+                       NumberVisible: Boolean): Integer;
                class procedure ListViewSort(Sender: TObject; ListView: TListView; Column: TListColumn;
-                       NumberVisible: Boolean; var vSortOrder: Boolean;        var vSortIndex: Integer);
+                       NumberVisible: Boolean; vSortOrder: Boolean);
                class function  ActiveListTrueColumn( column : TListColumn ) : TListColumn;
                class function SetBoardListItem(Category: TCategory; ListView: TListView;
-                       NumberVisible: Boolean; var vSortIndex: Integer; var vSortOrder: Boolean): Integer;
+                       NumberVisible: Boolean): Integer;
                class function SetThreadListItem(Board: TBoard; ListView: TListView;
-                       NumberVisible: Boolean; var vSortIndex: Integer; var vSortOrder: Boolean): Integer;
+                       NumberVisible: Boolean): Integer;
                class procedure ListViewData(Sender: TObject; Item: TListItem);
-
        end;
 
-
 implementation
 
 uses
-       GikoSystem, Sort, Setting, Giko, MojuUtils, GikoDataModule;
+       GikoSystem, Sort, Setting, Giko, MojuUtils, GikoDataModule, DateUtils, Math;
 
 const
        //\83c\83\8a\81[\81E\83\8a\83X\83g\83A\83C\83R\83\93
@@ -76,9 +80,9 @@ begin
 
                // \83L\83\83\83r\83l\83b\83g\95\\8e¦\91O\82É\8dÄ\83\\81[\83g
                if ( GikoSys.Setting.BBSSortIndex <> 0 ) or ( GikoSys.Setting.BBSSortOrder <> true ) then begin
-                       Sort.SortOrder := true;
-                       Sort.SortIndex := 0;
-                       Sort.SortNoFlag := true;
+                       Sort.SetSortOrder(true);
+                       Sort.SetSortIndex(0);
+                       Sort.SetSortNoFlag(true);
                        inBBS.Sort(CategorySortProc);
                end;
 
@@ -95,9 +99,9 @@ begin
 
                        // \83L\83\83\83r\83l\83b\83g\95\\8e¦\91O\82É\8dÄ\83\\81[\83g
                        if ( GikoSys.Setting.CategorySortIndex <> 0 ) or ( GikoSys.Setting.CategorySortOrder <> true ) then begin
-                               Sort.SortOrder := true;
-                               Sort.SortIndex := 0;
-                               Sort.SortNoFlag := true;
+                               Sort.SetSortOrder(true);
+                               Sort.SetSortIndex(0);
+                               Sort.SetSortNoFlag(true);
                                Category.CustomSort(BoardSortProc);
                        end;
 
@@ -137,9 +141,7 @@ end;
 class function TListViewUtils.SetCategoryListItem(
        ABBS2ch: TBBS;
        ListView: TListView;
-       NumberVisible: Boolean;
-       var vSortIndex: Integer;
-       var vSortOrder: Boolean
+       NumberVisible: Boolean
 ): Integer;
 var
        TitleColumn     : TListColumn;
@@ -179,12 +181,13 @@ begin
                GikoForm.FolderImage.Picture := nil;
                GikoForm.ItemIcon16.GetBitmap(1, GikoForm.FolderImage.Picture.Bitmap);
 
-               vSortIndex := GikoSys.Setting.BBSSortIndex;
-               vSortOrder := GikoSys.Setting.BBSSortOrder;
                for i := ListView.Columns.Count - 1 downto 0 do begin
-                       idx := ListView.Column[ i ].Tag;
-                       if vSortIndex = Ord( GikoSys.Setting.BBSColumnOrder[ idx ] ) then
-                               ListViewSort( nil, ListView, ListView.Column[ i ], NumberVisible, vSortOrder, vSortIndex );
+                       if (GikoSys.Setting.BBSSortIndex
+                                       = Integer(GikoSys.Setting.BBSColumnOrder[ ListView.Column[ i ].Tag ])) then begin
+                               ListViewSort( nil, ListView, ListView.Column[ i ],
+                                        NumberVisible, GikoSys.Setting.BBSSortOrder);
+                               Break;
+                       end;
                end;
 
                Result := ABBS2ch.Count;
@@ -198,11 +201,10 @@ class procedure TListViewUtils.ListViewSort(
        ListView: TListView;
        Column: TListColumn;
        NumberVisible: Boolean;
-       var vSortOrder: Boolean;
-       var vSortIndex: Integer
+       vSortOrder: Boolean
 );
 var
-       i, id, idx      : Integer;
+       i, idx  : Integer;
        orderList               : TList;
        wkBBS: TBBS;
        wkCategory: TCategory;
@@ -213,53 +215,41 @@ begin
        for i := 0 to ListView.Columns.Count - 1 do begin
                ListView.Column[i].ImageIndex := -1;
        end;
-
-       if SortOrder then
+       if vSortOrder then
                ListView.Column[ idx ].ImageIndex := ITEM_ICON_SORT1
        else
                ListView.Column[ idx ].ImageIndex := ITEM_ICON_SORT2;
 
-       Sort.SortNoFlag := NumberVisible;
 
-       //if TObject(TreeView.Selected.Data) is TBBS then begin
+       Sort.SetSortNoFlag(NumberVisible);
+
        if TObject( GikoForm.ActiveList ) is TBBS then begin
-               //wkBBS := TBBS(TreeView.Selected.Data);
                wkBBS := TBBS( GikoForm.ActiveList );
                orderList := GikoSys.Setting.BBSColumnOrder;
-               id := Integer( orderList[ idx ] );
-               Sort.SortOrder := vSortOrder;
-               Sort.SortIndex := id;
-               GikoSys.Setting.BBSSortIndex := id;
-               GikoSys.Setting.BBSSortOrder := vSortOrder;
+               Sort.SetSortOrder(vSortOrder);
+               Sort.SetSortIndex(Integer( orderList[ idx ] ));
+               GikoSys.Setting.BBSSortIndex := Sort.GetSortIndex;
+               GikoSys.Setting.BBSSortOrder := Sort.GetSortOrder;
                wkBBS.Sort(Sort.CategorySortProc);
-       //end else if TObject(TreeView.Selected.Data) is TCategory then begin
        end else if TObject( GikoForm.ActiveList ) is TCategory then begin
-               //wkCategory := TCategory(TreeView.Selected.Data);
                wkCategory := TCategory( GikoForm.ActiveList );
                orderList := GikoSys.Setting.CategoryColumnOrder;
-               id := Integer( orderList[ idx ] );
-               Sort.SortOrder := vSortOrder;
-               Sort.SortIndex := id;
-               GikoSys.Setting.CategorySortIndex := id;
-               GikoSys.Setting.CategorySortOrder := vSortOrder;
+               Sort.SetSortOrder(vSortOrder);
+               Sort.SetSortIndex(Integer( orderList[ idx ] ));
+               GikoSys.Setting.CategorySortIndex := Sort.GetSortIndex;
+               GikoSys.Setting.CategorySortOrder := Sort.GetSortOrder;
                wkCategory.CustomSort(BoardSortProc);
-       //end else if TObject(TreeView.Selected.Data) is TBoard then begin
        end else if TObject( GikoForm.ActiveList ) is TBoard then begin
-               //wkBoard := TBoard(TreeView.Selected.Data);
                wkBoard := TBoard( GikoForm.ActiveList );
                orderList := GikoSys.Setting.BoardColumnOrder;
-               id := Integer( orderList[ idx ] );
-               Sort.SortOrder := vSortOrder;
-               Sort.SortIndex := id;
-               GikoSys.Setting.BoardSortIndex := id;
-               GikoSys.Setting.BoardSortOrder := vSortOrder;
+               Sort.SetSortOrder(vSortOrder);
+               Sort.SetSortIndex(Integer( orderList[ idx ] ));
+               GikoSys.Setting.BoardSortIndex := Sort.GetSortIndex;
+               GikoSys.Setting.BoardSortOrder := Sort.GetSortOrder;
                wkBoard.CustomSort(ThreadItemSortProc);
-       end else begin
-               id := 0;
        end;
 
        ListView.Refresh;
-       vSortIndex := id;
 end;
 
 {!
@@ -269,49 +259,16 @@ Delphi 6 Personal 
 \90³\82µ\82¢\83J\83\89\83\80\82ª\93n\82³\82ê\82È\82¢\82½\82ß\81A\90³\82µ\82¢\83J\83\89\83\80\82É\95Ï\8a·\82µ\82Ü\82·\81B
 }
 class function TListViewUtils.ActiveListTrueColumn( column : TListColumn ) : TListColumn;
-{*
-var
-       i, idx          : Integer;
-       orderList       : TList;
-*}
 begin
-
        // \90³\82µ\82­\95Ï\8a·\82·\82é\95û\96@\82ª\95ª\82©\82ç\82È\82¢\82Ì\82Å\95Û\97¯
        Result := column;
        Exit;
-{*
-       Result := column;
-
-       if TObject( FActiveList ) is TBBS then
-               orderList := GikoSys.Setting.BBSColumnOrder
-       else if TObject( FActiveList ) is TCategory then
-               orderList := GikoSys.Setting.CategoryColumnOrder
-       else if TObject( FActiveList ) is TBoard then
-               orderList := GikoSys.Setting.BoardColumnOrder
-       else
-               Exit;
-
-       idx := column.Tag;
-
-       for i := 0 to ListView.Columns.Count - 1 do begin
-               if Integer( orderList[ ListView.Column[ i ].Tag ] ) = 0 then begin
-                       if idx = 0 then
-                               Result := ListView.Column[ i ]
-                       else if idx <= i then
-                               Result := ListView.Column[ idx - 1 ];
-                       Exit;
-               end;
-       end;
-*}
-
 end;
 //ListView\82ÉBoardItem\82ð\90Ý\92è\82·\82é
 class function TListViewUtils.SetBoardListItem(
        Category: TCategory;
        ListView: TListView;
-       NumberVisible: Boolean;
-       var vSortIndex: Integer;
-       var vSortOrder: Boolean
+       NumberVisible: Boolean
 ): Integer;
 var
        TitleColumn     : TListColumn;
@@ -366,12 +323,13 @@ begin
                GikoForm.FolderImage.Picture := nil;
                GikoForm.ItemIcon16.GetBitmap(3, GikoForm.FolderImage.Picture.Bitmap);
 
-               vSortIndex := GikoSys.Setting.CategorySortIndex;
-               vSortOrder := GikoSys.Setting.CategorySortOrder;
                for i := ListView.Columns.Count - 1 downto 0 do begin
-                       idx := ListView.Column[ i ].Tag;
-                       if vSortIndex = Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] ) then
-                               ListViewSort( nil, ListView, ListView.Column[ i ], NumberVisible, vSortOrder, vSortIndex );
+                       if (GikoSys.Setting.CategorySortIndex =
+                               Integer( GikoSys.Setting.CategoryColumnOrder[ ListView.Columns[i].Tag ] )) then begin
+                               ListViewSort( nil, ListView, ListView.Column[ i ],
+                                        NumberVisible, GikoSys.Setting.CategorySortOrder);
+                               Break;
+                       end;
                end;
 
                Result := Category.Count;
@@ -383,9 +341,7 @@ end;
 class function TListViewUtils.SetThreadListItem(
        Board: TBoard;
        ListView: TListView;
-       NumberVisible: Boolean;
-       var vSortIndex: Integer;
-       var vSortOrder: Boolean
+       NumberVisible: Boolean
 ): Integer;
 var
        TitleColumn     : TListColumn;
@@ -449,6 +405,16 @@ begin
                                Board.NewThreadCount := Board.GetNewThreadCount;
                                ListView.Items.Count := Board.NewThreadCount;
                        end;
+                       gvtArch:
+                       begin
+                               Board.ArchiveThreadCount := Board.GetArchiveThreadCount;
+                               ListView.Items.Count := Board.ArchiveThreadCount;
+                       end;
+                       gvtLive:
+                       begin
+                               Board.LiveThreadCount := Board.GetLiveThreadCount;
+                               ListView.Items.Count := Board.LiveThreadCount;
+                       end;
                        gvtUser:
                        begin
                                Board.UserThreadCount:= Board.GetUserThreadCount;
@@ -460,12 +426,13 @@ begin
                GikoForm.FolderImage.Picture := nil;
                GikoForm.ItemIcon16.GetBitmap(5, GikoForm.FolderImage.Picture.Bitmap);
 
-               vSortIndex := GikoSys.Setting.BoardSortIndex;
-               vSortOrder := GikoSys.Setting.BoardSortOrder;
                for i := ListView.Columns.Count - 1 downto 0 do begin
-                       idx := ListView.Column[ i ].Tag;
-                       if vSortIndex = Ord( GikoSys.Setting.BoardColumnOrder[ idx ] ) then
-                               ListViewSort( nil, ListView, ListView.Column[ i ], NumberVisible, vSortOrder, vSortIndex );
+                       if (GikoSys.Setting.BoardSortIndex
+                               = Integer( GikoSys.Setting.BoardColumnOrder[ ListView.Columns[ i ].Tag ] )) then begin
+                               ListViewSort( nil, ListView, ListView.Column[ i ],
+                                        NumberVisible, GikoSys.Setting.BoardSortOrder);
+                               Break;
+                       end;
                end;
 
                Result := Board.Count;
@@ -476,285 +443,317 @@ end;
 
 class procedure TListViewUtils.ListViewData(Sender: TObject; Item: TListItem);
 var
-//     FileName: string;
-//     DateTime: TDateTime;
-       BoardCnt: Integer;
-       BBS: TBBS;
-       Category: TCategory;
-       Board: TBoard;
-       ThreadItem: TThreadItem;
-       RepStr: string;
-               ActivListObj : TObject;
-       i, idx : Integer;
+       ActivListObj : TObject;
        ListView : TListView;
 begin
        if (Sender <> nil) and (Sender is TListView) then begin
-               ListView := TListView(Sender)
-       end else begin
-               Exit;
+               ListView := TListView(Sender);
+               ActivListObj := GikoForm.ActiveList;
+               if ActivListObj is TBBS then begin
+                       DrawCategoryItem(TBBS(ActivListObj), Item, ListView);
+               end else if ActivListObj is TCategory then begin
+                       DrawBoardItem(TCategory(ActivListObj), Item, ListView);
+               end else if ActivListObj is TBoard then begin
+                       DrawThreadItem(TBoard(ActivListObj), Item, ListView);
+               end;
        end;
+end;
+//! \83\8a\83X\83g\83r\83\85\81[\82Ì\83A\83C\83e\83\80\82ð\95`\89æ\82·\82é\81i\83J\83e\83S\83\8a\81[\97p\81j
+class procedure TListViewUtils.DrawCategoryItem(
+       BBS: TBBS; Item: TListItem; ListView: TListView
+);
+var
+       Category : TCategory;
+begin
 
-       ActivListObj := GikoForm.ActiveList;
-       if ActivListObj is TBBS then begin
-               //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
-               BBS := TBBS(ActivListObj);
-
-               GikoForm.ListView.StateImages := nil;
+       //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
+       ListView.StateImages := nil;
 
-               if (BBS = nil) or (BBS.Count <= 0) or (Item = nil)
-                       or (Item.Index >= BBS.Count) or (ListView.Items.Count = 0)
-                       or (not (BBS.Items[Item.index] is TCategory)) then Exit;
-               //if BBS.Count <= 0 then Exit;
-               //if Item = nil then Exit;
-               //if Item.Index >= BBS.Count then Exit;
-               //if ListView.Items.Count = 0 then Exit;
+       if (BBS = nil) or (BBS.Count <= 0) or (Item = nil)
+               or (Item.Index >= BBS.Count) or (ListView.Items.Count = 0)
+               or (not (BBS.Items[Item.index] is TCategory)) then Exit;
 
-               //if not (BBS.Items[Item.index] is TCategory) then Exit;
-               Category := TCategory(BBS.Items[Item.index]);
+       Category := TCategory(BBS.Items[Item.index]);
 
-               if Category = nil then Exit;
+       if (Category = nil) then Exit;
 
-               if GikoDM.ListNumberVisibleAction.Checked then
-                       Item.Caption := IntToStr(Category.No) + ': ' + Category.Title
-               else
-                       Item.Caption := Category.Title;
-
-               Item.ImageIndex := ITEM_ICON_CATEGORY1;
-               Item.Data := Category;
+    if GikoDM.ListNumberVisibleAction.Checked then
+               Item.Caption := IntToStr(Category.No) + ': ' + Category.Title
+       else
+               Item.Caption := Category.Title;
 
-       end else if ActivListObj is TCategory then begin
+       Item.ImageIndex := ITEM_ICON_CATEGORY1;
+       Item.Data := Category;
+end;
+//! \83\8a\83X\83g\83r\83\85\81[\82Ì\83A\83C\83e\83\80\82ð\95`\89æ\82·\82é\81i\94Â\97p\81j
+class procedure TListViewUtils.DrawBoardItem(
+       Category: TCategory; Item: TListItem; ListView: TListView
+);
+var
+       Board: TBoard;
+       i, idx : Integer;
+begin
+       //===== \94Â\83\8a\83X\83g =====
+       ListView.StateImages := nil;
 
-               //===== \94Â\83\8a\83X\83g =====
-               Category := TCategory(ActivListObj);
+       if (Category = nil) or (Category.Count <= 0) or (Item = nil)
+               or (Item.Index >= Category.Count) or (ListView.Items.Count = 0)
+               or (not (Category.Items[Item.Index] is TBoard))  then Exit;
 
-               ListView.StateImages := nil;
+       Board := TBoard(Category.Items[Item.Index]);
 
-               if (Category = nil) or (Category.Count <= 0) or (Item = nil)
-                       or (Item.Index >= Category.Count) or (ListView.Items.Count = 0)
-                       or (not (Category.Items[Item.Index] is TBoard))  then Exit;
-               //if Category.Count <= 0 then Exit;
-               //if Item = nil then Exit;
-               //if Item.Index >= Category.Count then Exit;
-               //if ListView.Items.Count = 0 then Exit;
+       if (Board = nil)  then Exit;
 
-               //if not (Category.Items[Item.Index] is TBoard) then Exit;
-               Board := TBoard(Category.Items[Item.Index]);
+       if GikoDM.ListNumberVisibleAction.Checked then
+               Item.Caption := IntToStr(Board.No) + ': ' + Board.Title
+       else
+               Item.Caption := Board.Title;
 
-               if Board = nil then Exit;
+       if Item.SubItems.Count <> ListView.Columns.Count then begin
+               Item.SubItems.Clear;
+               Item.SubItems.Capacity := GikoSys.Setting.CategoryColumnOrder.Count;
+               for i := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 1 do
+                       Item.SubItems.Add('');
+       end;
 
-               if GikoDM.ListNumberVisibleAction.Checked then
-                       Item.Caption := IntToStr(Board.No) + ': ' + Board.Title
-                       //Item.Caption := IntToStr(Item.Index + 1) + ': ' + Board.Title
-               else
-                       Item.Caption := Board.Title;
+       Item.ImageIndex := ITEM_ICON_BOARD1;
+       idx := 0;
+       for i := 0 to ListView.Columns.Count - 1 do begin
+               if GikoSys.Setting.CategoryColumnOrder.Count <= i then
+                       Break;
+               case GikoSys.Setting.CategoryColumnOrder[ i ] of
+               gccTitle:
+                       // Item.Caption \82Í SubItems \82É\8aÜ\82Ü\82ê\96³\82¢\82Ì\82Å
+                       Dec( idx );
+
+               gccRoundName:
+                       if Board.Round then
+                               Item.SubItems[ idx ] := Board.RoundName // '\97\\96ñ'
+                       else
+                               Item.SubItems[ idx ] := '';
 
-               if Item.SubItems.Count <> ListView.Columns.Count then begin
-                       Item.SubItems.Clear;
-                       Item.SubItems.Capacity := GikoSys.Setting.CategoryColumnOrder.Count;
-                       for i := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 1 do
-                               Item.SubItems.Add('');
+               gccLastModified:
+                       if Board.RoundDate = ZERO_DATE then begin
+                               Item.SubItems[ idx ] := '';
+                       end else
+                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Board.RoundDate);
                end;
+               Inc( idx );
+       end;
 
-               Item.ImageIndex := ITEM_ICON_BOARD1;
-               idx := 0;
-               for i := 0 to ListView.Columns.Count - 1 do begin
-                       if GikoSys.Setting.CategoryColumnOrder.Count <= i then
-                               Break;
-//                             case TGikoCategoryColumnID( ListView.Column[ i ].Tag ) of
-                       case GikoSys.Setting.CategoryColumnOrder[ i ] of
-                       gccTitle:
-                               // Item.Caption \82Í SubItems \82É\8aÜ\82Ü\82ê\96³\82¢\82Ì\82Å
-                               Dec( idx );
-
-                       gccRoundName:
-                               if Board.Round then
-                                       Item.SubItems[ idx ] := Board.RoundName // '\97\\96ñ'
-                               else
-                                       Item.SubItems[ idx ] := '';
+       Item.Data := Board;
 
-                       gccLastModified:
-                               if Board.RoundDate = ZERO_DATE then begin
-                                       Item.SubItems[ idx ] := '';
-                               end else
-                                       Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Board.RoundDate);
-                       end;
-                       Inc( idx );
-               end;
+end;
+//! \83\8a\83X\83g\83r\83\85\81[\82Ì\83A\83C\83e\83\80\82ð\95`\89æ\82·\82é\81i\83X\83\8c\83b\83h\97p\81j
+class procedure TListViewUtils.DrawThreadItem(
+       Board: TBoard; Item: TListItem;ListView : TListView
+);
+var
+       ThreadItem: TThreadItem;
+       BoardCnt: Integer;
+       RepStr: String;
+       i: Integer;
+begin
+       //===== \83X\83\8c\83\8a\83X\83g =====
+       if GikoSys.Setting.ListIconVisible then
+               ListView.StateImages := GikoForm.StateIconImageList
+       else
+               ListView.StateImages := nil;
 
-               Item.Data := Board;
 
-       end else if ActivListObj is TBoard then begin
+       case GikoForm.ViewType of
+               gvtAll: BoardCnt := Board.Count;
+               gvtLog: BoardCnt := Board.LogThreadCount;
+               gvtNew: BoardCnt := Board.NewThreadCount;
+               gvtArch: BoardCnt := Board.ArchiveThreadCount;
+               gvtLive: BoardCnt := Board.LiveThreadCount;
+               gvtUser: BoardCnt := Board.UserThreadCount;
+               else
+                       BoardCnt := 0;
+       end;
 
-               //===== \83X\83\8c\83\8a\83X\83g =====
-               Board := TBoard(ActivListObj);
+       if (BoardCnt <= 0) or (Item = nil) or (Item.Index >= BoardCnt)
+               or (ListView.Items.Count = 0) or (not (Board.Items[Item.Index] is TThreadItem)) then Exit;
+
+       //\89ü\91P\82·\82×\82«\83u\83\8d\83b\83N/////////////////////////////////////////////////////
+       ThreadItem := nil;
+       case GikoForm.ViewType of
+               gvtAll: if Item.Index >= Board.Count then Exit else
+                                                       ThreadItem := TThreadItem(Board.Items[Item.Index]);
+               gvtLog:         ThreadItem := Board.GetLogThread(Item.Index);
+               gvtNew:         ThreadItem := Board.GetNewThread(Item.Index);
+               gvtArch:    ThreadItem := Board.GetArchiveThread(Item.Index);
+               gvtLive:    ThreadItem := Board.GetLiveThread(Item.Index);
+               gvtUser:        ThreadItem := Board.GetUserThread(Item.Index);
+       end;
+       //////////////////////////////////////////////////////////////////////////
+
+       if (ThreadItem = nil)  then Exit;
+
+       RepStr := CustomStringReplace(ThreadItem.Title, '&lt;', '<' );
+       RepStr := CustomStringReplace(RepStr, '&gt;', '>' );
+       RepStr := CustomStringReplace(RepStr, '&quot;', '"' );
+       RepStr := CustomStringReplace(RepStr, '&amp;', '&' );
+       //RepStr := StringReplace(RepStr, '\81\97\81M', ',', [rfReplaceAll]);
+
+    if (ThreadNgList.IsNG(RepStr) = True) then
+        RepStr := '\81\83\82 \82Ú\81`\82ñ\81\84'
+    else if (GikoSys.Setting.ThreadTitleTrim = True) then
+        RepStr := GikoSys.TrimThreadTitle(RepStr);
+
+       if Item.SubItems.Count <> ListView.Columns.Count then begin
+               Item.SubItems.Clear;
+               Item.SubItems.Capacity := GikoSys.Setting.BoardColumnOrder.Count;
+               for i := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 1 do
+                       Item.SubItems.Add('');
+       end;
 
-               if GikoSys.Setting.ListIconVisible then
-                       ListView.StateImages := GikoForm.StateIconImageList
-               else
-                       ListView.StateImages := nil;
+       if GikoDM.ListNumberVisibleAction.Checked then
+               Item.Caption := IntToStr(ThreadItem.No) + ': ' + RepStr
+       else
+               Item.Caption := RepStr;
+
+       case ThreadItem.AgeSage of
+               gasNone: Item.StateIndex := -1;
+               gasNew: Item.StateIndex := 0;
+               gasAge: Item.StateIndex := 1;
+               gasSage: Item.StateIndex := 2;
+               gasArch: Item.StateIndex := 3;
+       end;
 
+       if ThreadItem.IsLogFile then begin
+               DrawItemLogThread(ThreadItem, Item, ListView.Columns.Count);
+       end else begin
+               DrawItemNoLogThread(ThreadItem, Item, GikoSys.Setting.BoardColumnOrder.Count);
+       end;
 
-               case GikoForm.ViewType of
-                       gvtAll: BoardCnt := Board.Count;
-                       gvtLog: BoardCnt := Board.LogThreadCount;
-                       gvtNew: BoardCnt := Board.NewThreadCount;
-                       gvtUser: BoardCnt := Board.UserThreadCount;
+       Item.Data := ThreadItem;
+end;
+//! \83\8d\83O\97L\82è\83X\83\8c\83b\83h\82ð\95`\89æ\82·\82é
+class procedure TListViewUtils.DrawItemLogThread(Thread: TThreadItem; Item: TListItem; ColumnCount: Integer);
+var
+       i, idx : Integer;
+       spanday: Double;
+begin
+       idx := 0;
+       for i := 0 to ColumnCount - 1 do begin
+               if GikoSys.Setting.BoardColumnOrder.Count <= i then
+                       Break;
+
+               case GikoSys.Setting.BoardColumnOrder[ i ] of
+               gbcTitle:
+                       // Item.Caption \82Í SubItems \82É\8aÜ\82Ü\82ê\96³\82¢\82Ì\82Å
+                       Dec( idx );
+               gbcAllCount:
+                       Item.SubItems[ idx ] := IntToStr(Thread.AllResCount);
+               gbcLocalCount:
+                       Item.SubItems[ idx ] := IntToStr(Thread.Count);
+               gbcNonAcqCount:
+                       Item.SubItems[ idx ] := IntToStr(Thread.AllResCount - Thread.Count);
+               gbcNewCount:
+                       if Thread.NewResCount = 0 then
+                               Item.SubItems[ idx ] := ''
                        else
-                               BoardCnt := 0;
-               end;
-               {
-               case GikoForm.ViewType of
-                       gvtAll: BoardCnt := Board.Count;
-                       gvtLog: BoardCnt := Board.GetLogThreadCount;
-                       gvtNew: BoardCnt := Board.GetNewThreadCount;
-                       gvtUser: BoardCnt := Board.GetUserThreadCount;
+                               Item.SubItems[ idx ] := IntToStr(Thread.NewResCount);
+               gbcUnReadCount:
+                       Item.SubItems[ idx ] := '';
+               gbcRoundName:
+                       if Thread.Round then
+                               Item.SubItems[ idx ] := Thread.RoundName
                        else
-                               BoardCnt := 0;
-               end;
-               }
-//             if Board = nil then Exit;
-               if (BoardCnt <= 0) or (Item = nil) or (Item.Index > BoardCnt)
-                       or (ListView.Items.Count = 0) or (not (Board.Items[Item.Index] is TThreadItem)) then Exit;
-
-               //\89ü\91P\82·\82×\82«\83u\83\8d\83b\83N/////////////////////////////////////////////////////
-               ThreadItem := nil;
-               case GikoForm.ViewType of
-                       gvtAll: if Item.Index >= Board.Count then Exit else
-                                                               ThreadItem := TThreadItem(Board.Items[Item.Index]);
-                       gvtLog:         ThreadItem := Board.GetLogThread(Item.Index);
-                       gvtNew:         ThreadItem := Board.GetNewThread(Item.Index);
-                       gvtUser:        ThreadItem := Board.GetUserThread(Item.Index);
-               end;
-               //////////////////////////////////////////////////////////////////////////
-               
-               if ThreadItem = nil then Exit;
-
-               RepStr := CustomStringReplace(ThreadItem.Title, '&lt;', '<' );
-               RepStr := CustomStringReplace(RepStr, '&gt;', '>' );
-               RepStr := CustomStringReplace(RepStr, '&quot;', '"' );
-               RepStr := CustomStringReplace(RepStr, '&amp;', '&' );
-               //RepStr := StringReplace(RepStr, '\81\97\81M', ',', [rfReplaceAll]);
-               if Item.SubItems.Count <> ListView.Columns.Count then begin
-                       Item.SubItems.Clear;
-                       Item.SubItems.Capacity := GikoSys.Setting.BoardColumnOrder.Count;
-                       for i := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 1 do
-                               Item.SubItems.Add('');
-               end;
-
-               if GikoDM.ListNumberVisibleAction.Checked then
-                       Item.Caption := IntToStr(ThreadItem.No) + ': ' + RepStr
-               else
-                       Item.Caption := RepStr;
-
-               case ThreadItem.AgeSage of
-                       gasNone: Item.StateIndex := -1;
-                       gasNew: Item.StateIndex := 0;
-                       gasAge: Item.StateIndex := 1;
-                       gasSage: Item.StateIndex := 2;
-               end;
-
-               if ThreadItem.IsLogFile then begin
-                       idx := 0;
-                       for i := 0 to ListView.Columns.Count - 1 do begin
-                       if GikoSys.Setting.BoardColumnOrder.Count <= i then
-                               Break;
-//                             case TGikoBoardColumnID( ListView.Column[ i ].Tag ) of
-                               case GikoSys.Setting.BoardColumnOrder[ i ] of
-                               gbcTitle:
-                                       // Item.Caption \82Í SubItems \82É\8aÜ\82Ü\82ê\96³\82¢\82Ì\82Å
-                                       Dec( idx );
-
-                               gbcAllCount:
-                                       Item.SubItems[ idx ] := IntToStr(ThreadItem.AllResCount);
-
-                               gbcLocalCount:
-                                       Item.SubItems[ idx ] := IntToStr(ThreadItem.Count);
-
-                               gbcNonAcqCount:
-                                       Item.SubItems[ idx ] := IntToStr(ThreadItem.AllResCount - ThreadItem.Count);
-
-                               gbcNewCount:
-                                       if ThreadItem.NewResCount = 0 then
-                                               Item.SubItems[ idx ] := ''
-                                       else
-                                               Item.SubItems[ idx ] := IntToStr(ThreadItem.NewResCount);
-
-                               gbcUnReadCount:
-                                       Item.SubItems[ idx ] := '';
-
-                               gbcRoundName:
-                                       if ThreadItem.Round then
-                                               Item.SubItems[ idx ] := ThreadItem.RoundName
-                                       else
-                                               Item.SubItems[ idx ] := '';
-
-                               gbcRoundDate://gbcLastModified:
-                                       if (ThreadItem.RoundDate = ZERO_DATE)  then begin
-                                               Item.SubItems[ idx ] := '';
-                                       end else
-                                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.RoundDate);
-
-                               gbcCreated:
-                                       if ThreadItem.CreateDate = ZERO_DATE then begin
-                                               Item.SubItems[ idx ] := '';
-                                       end else
-                                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.CreateDate);
-
-                               gbcLastModified:
-                                       if (ThreadItem.LastModified = ZERO_DATE)  then begin
+                               Item.SubItems[ idx ] := '';
+               gbcRoundDate://gbcLastModified:
+                       if (Thread.RoundDate = ZERO_DATE)  then begin
+                               Item.SubItems[ idx ] := '';
+                       end else
+                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Thread.RoundDate);
+               gbcCreated:
+                       if Thread.CreateDate = ZERO_DATE then begin
+                               Item.SubItems[ idx ] := '';
+                       end else
+                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Thread.CreateDate);
+               gbcLastModified:
+                       if (Thread.LastModified = ZERO_DATE)  then begin
+                               Item.SubItems[ idx ] := '';
+                       end else
+                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Thread.LastModified);
+               gbcVigor:
+                       begin
+                               if (Thread.CreateDate <> ZERO_DATE)  then begin
+                                       if (Thread.AgeSage <> gasArch) then begin
+                                               spanday := DaySpan(Sort.GetSortDate, Thread.CreateDate);
+                                       end else begin
+                                               spanday := DaySpan(Thread.LastModified, Thread.CreateDate);
+                                       end;
+                                       if (spanday > 0) then begin
+                                               Item.SubItems[ idx ] := Format('%f', [Thread.AllResCount / spanday]);
+                                       end else begin
                                                Item.SubItems[ idx ] := '';
-                                       end else
-                                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.LastModified);
-
-
+                                       end;
+                               end else begin
+                                       Item.SubItems[ idx ] := '';
                                end;
-                               Inc( idx );
                        end;
+               end;
+               Inc( idx );
+       end;
 
-                       if ThreadItem.NewArrival then
-                               Item.ImageIndex := ITEM_ICON_THREADNEW1
-                       else
-                               Item.ImageIndex := ITEM_ICON_THREADLOG1;
-
-
-               end else begin
-                       idx := 0;
-                       for i := 0 to GikoSys.Setting.BoardColumnOrder.Count - 1 do begin
-//                             case TGikoBoardColumnID( ListView.Column[ i ].Tag ) of
-                               case GikoSys.Setting.BoardColumnOrder[ i ] of
-                               gbcTitle:
-                                       // Item.Caption \82Í SubItems \82É\8aÜ\82Ü\82ê\96³\82¢\82Ì\82Å
-                                       Dec( idx );
-
-                               gbcAllCount:
-                                       Item.SubItems[ idx ] := IntToStr(ThreadItem.AllResCount);
-
-                               gbcRoundDate://gbcLastModified:
-                                       Item.SubItems[ idx ] := '';
+       if Thread.NewArrival then
+               Item.ImageIndex := ITEM_ICON_THREADNEW1
+       else
+               Item.ImageIndex := ITEM_ICON_THREADLOG1;
+end;
+//! \83\8d\83O\82È\82µ\83X\83\8c\83b\83h\82ð\95`\89æ\82·\82é
+class procedure TListViewUtils.DrawItemNoLogThread(Thread: TThreadItem; Item: TListItem; ColumnCount: Integer);
+var
+       i, idx: Integer;
+       spanday: Double;
+begin
+       idx := 0;
+       for i := 0 to ColumnCount - 1do begin
+               case GikoSys.Setting.BoardColumnOrder[ i ] of
+               gbcTitle:
+                       // Item.Caption \82Í SubItems \82É\8aÜ\82Ü\82ê\96³\82¢\82Ì\82Å
+                       Dec( idx );
+               gbcAllCount:
+                       Item.SubItems[ idx ] := IntToStr(Thread.AllResCount);
+               gbcRoundDate://gbcLastModified:
+                       Item.SubItems[ idx ] := '';
+               gbcCreated:
+                       if Thread.CreateDate = ZERO_DATE then begin
+                               Item.SubItems[ idx ] := '';
+                       end else
+                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Thread.CreateDate);
+               gbcLastModified:
+                       Item.SubItems[ idx ] := '';
+               gbcVigor:
+                       begin
+                               if (Thread.CreateDate <> ZERO_DATE)  then begin
+                                       if (Thread.AgeSage <> gasArch) then begin
+                                               spanday := DaySpan(Sort.GetSortDate, Thread.CreateDate);
+                                       end else begin
+                                               spanday := DaySpan(Thread.LastModified, Thread.CreateDate);
+                                       end;
 
-                               gbcCreated:
-                                       if ThreadItem.CreateDate = ZERO_DATE then begin
+                                       if (spanday > 0) then begin
+                                               Item.SubItems[ idx ] := Format('%f', [Thread.AllResCount / spanday]);
+                                       end else begin
                                                Item.SubItems[ idx ] := '';
-                                       end else
-                                               Item.SubItems[ idx ] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.CreateDate);
-
-                               gbcLastModified:
-                                       Item.SubItems[ idx ] := '';
-
-                               else
+                                       end;
+                               end else begin
                                        Item.SubItems[ idx ] := '';
                                end;
-                               Inc( idx );
                        end;
-                       if ThreadItem.NewArrival then
-                               Item.ImageIndex := ITEM_ICON_THREADNEW1
-                       else
-                               Item.ImageIndex := ITEM_ICON_THREAD1;
+               else
+                       Item.SubItems[ idx ] := '';
                end;
 
-               Item.Data := ThreadItem;
-
+               Inc( idx );
        end;
+       if Thread.NewArrival then
+               Item.ImageIndex := ITEM_ICON_THREADNEW1
+       else
+               Item.ImageIndex := ITEM_ICON_THREAD1;
 end;
 
 end.