OSDN Git Service

カラムソートのカラム位置に対する依存性を改善(不完全)。
authoryoffy <yoffy>
Wed, 8 Sep 2004 15:52:10 +0000 (15:52 +0000)
committeryoffy <yoffy>
Wed, 8 Sep 2004 15:52:10 +0000 (15:52 +0000)
※完全にするには TGikoForm.ActiveListTrueColumn を解決、もしくは代替策で対処する事。

Giko.pas
Sort.pas

index b0b1e27..fab98da 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -1085,6 +1085,8 @@ type
                procedure ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
                /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
                procedure ActiveListColumnSave;
+               /// ListView \82Ì Column \82ð\90^\82Ì\83J\83\89\83\80\82É\95Ï\8a·
+               function        ActiveListTrueColumn( column : TListColumn ) : TListColumn;
        protected
                procedure CreateParams(var Params: TCreateParams); override;
                procedure WndProc(var Message: TMessage); override;
@@ -2320,9 +2322,11 @@ begin
 
                FSortIndex := GikoSys.Setting.BBSSortIndex;
                FSortOrder := GikoSys.Setting.BBSSortOrder;
-               for i := ListView.Columns.Count - 1 downto 0 do
-                       if FSortIndex = ListView.Column[ i ].Tag then
+               for i := ListView.Columns.Count - 1 downto 0 do begin
+                       idx := ListView.Column[ i ].Tag;
+                       if FSortIndex = Ord( GikoSys.Setting.BBSColumnOrder[ idx ] ) then
                                ListViewSort( nil, ListView.Column[ i ] );
+               end;
 
                Result := ABBS2ch.Count;
        finally
@@ -2383,9 +2387,11 @@ begin
 
                FSortIndex := GikoSys.Setting.CategorySortIndex;
                FSortOrder := GikoSys.Setting.CategorySortOrder;
-               for i := ListView.Columns.Count - 1 downto 0 do
-                       if FSortIndex = ListView.Column[ i ].Tag then
+               for i := ListView.Columns.Count - 1 downto 0 do begin
+                       idx := ListView.Column[ i ].Tag;
+                       if FSortIndex = Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] ) then
                                ListViewSort( nil, ListView.Column[ i ] );
+               end;
 
                Result := Category.Count;
        finally
@@ -2449,9 +2455,11 @@ begin
 
                FSortIndex := GikoSys.Setting.BoardSortIndex;
                FSortOrder := GikoSys.Setting.BoardSortOrder;
-               for i := ListView.Columns.Count - 1 downto 0 do
-                       if FSortIndex = ListView.Column[ i ].Tag then
+               for i := ListView.Columns.Count - 1 downto 0 do begin
+                       idx := ListView.Column[ i ].Tag;
+                       if FSortIndex = Ord( GikoSys.Setting.BoardColumnOrder[ idx ] ) then
                                ListViewSort( nil, ListView.Column[ i ] );
+               end;
 
                Result := Board.Count;
        finally
@@ -2984,29 +2992,93 @@ begin
        Result := FHttpState;
 end;
 
+{*!
+\brief         ListView \82Ì Column \82ð\90^\82Ì\83J\83\89\83\80\82É\95Ï\8a·
+
+Delphi 6 Personal \82Å\82Ì ListView \82Å\82Í ListViewColumnClick \83C\83x\83\93\83g\82Å
+\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
+*}
+function       TGikoForm.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;
+
 procedure TGikoForm.ListViewColumnClick(Sender: TObject;
        Column: TListColumn);
+var
+       id, idx                 : Integer;
+       orderList               : TList;
 begin
-       if FSortIndex = Column.Index then
+       idx := ActiveListTrueColumn( Column ).Tag;
+
+       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;
+
+       id := Integer( orderList[ idx ] );
+
+       if FSortIndex = id then
                FSortOrder := not FSortOrder
        else
                FSortOrder := False;
+
        ListViewSort(Sender, Column);
 end;
 
 procedure TGikoForm.ListViewSort(Sender: TObject; Column: TListColumn);
 var
-       i: Integer;
+       i, id, idx      : Integer;
+       orderList               : TList;
        wkBBS: TBBS;
        wkCategory: TCategory;
        wkBoard: TBoard;
 begin
-       for i := 0 to ListView.Columns.Count - 1 do
+       idx := ActiveListTrueColumn( Column ).Tag;
+
+       for i := 0 to ListView.Columns.Count - 1 do begin
                ListView.Column[i].ImageIndex := -1;
+       end;
+
        if FSortOrder then
-               ListView.Column[Column.Index].ImageIndex := ITEM_ICON_SORT1
+               ListView.Column[ idx ].ImageIndex := ITEM_ICON_SORT1
        else
-               ListView.Column[Column.Index].ImageIndex := ITEM_ICON_SORT2;
+               ListView.Column[ idx ].ImageIndex := ITEM_ICON_SORT2;
 
        Sort.SortNoFlag := ListNumberVisibleAction.Checked;
 
@@ -3014,35 +3086,39 @@ begin
        if TObject( FActiveList ) is TBBS then begin
                //wkBBS := TBBS(TreeView.Selected.Data);
                wkBBS := TBBS( FActiveList );
+               orderList := GikoSys.Setting.BBSColumnOrder;
+               id := Integer( orderList[ idx ] );
                Sort.SortOrder := FSortOrder;
-               Sort.SortIndex := Column.Index;
-               GikoSys.Setting.BBSSortIndex := Column.Index;
+               Sort.SortIndex := id;
+               GikoSys.Setting.BBSSortIndex := id;
                GikoSys.Setting.BBSSortOrder := FSortOrder;
                wkBBS.Sort(CategorySortProc);
-               ListView.Refresh;
        //end else if TObject(TreeView.Selected.Data) is TCategory then begin
        end else if TObject( FActiveList ) is TCategory then begin
                //wkCategory := TCategory(TreeView.Selected.Data);
                wkCategory := TCategory( FActiveList );
+               orderList := GikoSys.Setting.CategoryColumnOrder;
+               id := Integer( orderList[ idx ] );
                Sort.SortOrder := FSortOrder;
-               Sort.SortIndex := Column.Index;
-               GikoSys.Setting.CategorySortIndex := Column.Index;
+               Sort.SortIndex := id;
+               GikoSys.Setting.CategorySortIndex := id;
                GikoSys.Setting.CategorySortOrder := FSortOrder;
                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
                //wkBoard := TBoard(TreeView.Selected.Data);
                wkBoard := TBoard( FActiveList );
+               orderList := GikoSys.Setting.BoardColumnOrder;
+               id := Integer( orderList[ idx ] );
                Sort.SortOrder := FSortOrder;
-               Sort.SortIndex := Column.Index;
-               Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount;
-               GikoSys.Setting.BoardSortIndex := Column.Index;
+               Sort.SortIndex := id;
+               GikoSys.Setting.BoardSortIndex := id;
                GikoSys.Setting.BoardSortOrder := FSortOrder;
                wkBoard.CustomSort(ThreadItemSortProc);
-               ListView.Refresh;
        end;
-       FSortIndex := Column.Index;
+
+       ListView.Refresh;
+       FSortIndex := id;
 end;
 
 procedure TGikoForm.MenuToolBarCustomDrawButton(Sender: TToolBar;
index 41160a6..a695b5d 100644 (file)
--- a/Sort.pas
+++ b/Sort.pas
@@ -3,7 +3,8 @@ unit Sort;
 interface
 uses
        Windows, Messages, SysUtils, Classes, Controls, Forms,
-       BoardGroup,DateUtils;
+       BoardGroup,DateUtils,
+       Setting;
 
        function CategorySortProc(Item1, Item2: Pointer): integer;
        function BoardSortProc(List: TStringList; Item1, Item2: Integer): integer;
@@ -28,10 +29,13 @@ begin
        CategoryItem1 := TCategory(Item1);
        CategoryItem2 := TCategory(Item2);
 
-       if SortNoFlag then
-               Result := CompareInt(CategoryItem1.No, CategoryItem2.No)
-       else
-               Result := AnsiCompareText(CategoryItem1.Title, CategoryItem2.Title);
+       case TGikoBBSColumnID( SortIndex ) of
+       gbbscTitle:
+               if SortNoFlag then
+                       Result := CompareInt(CategoryItem1.No, CategoryItem2.No)
+               else
+                       Result := AnsiCompareText(CategoryItem1.Title, CategoryItem2.Title);
+       end;
 
        if not SortOrder then
                Result := Result * -1;
@@ -44,15 +48,19 @@ var
 begin
        BoardItem1 := TBoard(List.Objects[Item1]);
        BoardItem2 := TBoard(List.Objects[Item2]);
-       if SortIndex = 0 then
+       case TGikoCategoryColumnID( SortIndex ) of
+       gccTitle:
                if SortNoFlag then
                        Result := CompareInt(BoardItem1.No, BoardItem2.No)
                else
-                       Result := AnsiCompareText(BoardItem1.Title, BoardItem2.Title)
-       else if SortIndex = 1 then
-               Result := CompareInt(BoardItem1.Count, BoardItem2.Count)
-    else
+                       Result := AnsiCompareText(BoardItem1.Title, BoardItem2.Title);
+
+       gccRoundName:
+               Result := CompareInt(BoardItem1.Count, BoardItem2.Count);
+
+       gccLastModified:
                Result := CompareDate(BoardItem1.RoundDate, BoardItem2.RoundDate);
+       end;
 
        if not SortOrder then
                Result := Result * -1;
@@ -65,34 +73,34 @@ var
 begin
        ThreadItem1 := TThreadItem(List.Objects[ Item1 ]);
        ThreadItem2 := TThreadItem(List.Objects[ Item2 ]);
-       case SortIndex of
-               0:
+       case TGikoBoardColumnID( SortIndex ) of
+               gbcTitle:
                        begin
                                if SortNoFlag then
                                        Result := CompareInt(ThreadItem1.No, ThreadItem2.No)
                                else
                                        Result := AnsiCompareText(ThreadItem1.Title, ThreadItem2.Title)
                        end;
-               1: Result := CompareInt(ThreadItem1.AllResCount, ThreadItem2.AllResCount);
-               2:
+
+               gbcAllCount:                    Result := CompareInt(ThreadItem1.AllResCount, ThreadItem2.AllResCount);
+               gbcLocalCount:          Result := CompareInt(ThreadItem1.Count, ThreadItem2.Count);
+               gbcNonAcqCount:
                        begin
-                               if SortNonAcquiredCountFlag then
-                                       if ThreadItem1.IsLogFile and ThreadItem2.IsLogFile then
-                                               Result := CompareInt(ThreadItem1.AllResCount - ThreadItem1.Count, ThreadItem2.AllResCount - ThreadItem2.Count)
-                                       else if ThreadItem1.IsLogFile then
-                                               Result := 1
-                                       else if ThreadItem2.IsLogFile then
-                                               Result := -1
-                                       else
-                                               Result := 0
+                               if ThreadItem1.IsLogFile and ThreadItem2.IsLogFile then
+                                       Result := CompareInt(ThreadItem1.AllResCount - ThreadItem1.Count, ThreadItem2.AllResCount - ThreadItem2.Count)
+                               else if ThreadItem1.IsLogFile then
+                                       Result := 1
+                               else if ThreadItem2.IsLogFile then
+                                       Result := -1
                                else
-                                       Result := CompareInt(ThreadItem1.Count, ThreadItem2.Count);
+                                       Result := 0;
                        end;
-               3: Result := CompareInt(ThreadItem1.NewResCount, ThreadItem2.NewResCount);
-               4: Result := 0;
-               5: Result := AnsiCompareText(ThreadItem1.RoundName, ThreadItem2.RoundName);
-               6: Result := CompareDateTime(ThreadItem1.RoundDate, ThreadItem2.RoundDate);
-               7: Result := CompareDateTime(ThreadItem1.CreateDate, ThreadItem2.CreateDate);
+
+               gbcNewCount:                    Result := CompareInt(ThreadItem1.NewResCount, ThreadItem2.NewResCount);
+               gbcUnReadCount:         Result := 0;
+               gbcRoundName:           Result := AnsiCompareText(ThreadItem1.RoundName, ThreadItem2.RoundName);
+               gbcLastModified:        Result := CompareDateTime(ThreadItem1.RoundDate, ThreadItem2.RoundDate);
+               gbcCreated:                             Result := CompareDateTime(ThreadItem1.CreateDate, ThreadItem2.CreateDate);
        else
                Result := 0;
        end;