Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/Sort.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.13 - (show annotations) (download) (as text)
Mon Sep 27 16:20:51 2004 UTC (19 years, 6 months ago) by yoffy
Branch: MAIN
CVS Tags: b49, v1_50_2_606, v1_51_0_612, v1_50_0_581, v1_50_0_580, v1_50_0_587, v1_50_0_586, v1_51_1_639, v1_50_0_595, v1_50_0_572, marged-Bb50, v1_51_0_626, b51, v1_51_0_622, v1_50_0_598, v1_50_0_590, bv1_49_0_564, v1_50_0_593, v1_50_0_596, bv1_49_0_563, v1_50_0_557, v1_50_0_585, v1_51_0_611, v1_51_0_620, v1_52_0_643, v1_51_0_634, v1_51_0_635, v1_51_0_636, v1_51_0_637, v1_51_0_632, v1_51_0_633, v1_49_0_548, v1_50_0_603, v1_50_0_582, v1_49_0_547, v1_50_0_604, v1_51_0_638, v1_49_0_554, merged-remodeling, v1_50_0_577, v1_49_0_551, v1_50_0_606, v1_50_0_588, v1_52_0_642, v1_51_0_616, v1_51_0_614, v1_51_0_615, v1_51_0_613, v1_51_1_640, v1_51_0_618, v1_51_0_619, bv1_49_0_565, b50, v1_49_0_552, v1_50_0_574, v1_49_0_553, v1_50_0_584, v_step1, v1_49_0_546, v1_50_0_573, v1_50_0_600, v1_51_0_630, v1_50_0_571, v1_51_0_631, v1_49_2_569, root-of-draw, v1_50_0_576, v1_50_2_604, v1_50_0_578, v1_51_0_628, v1_50_0_579, v1_51_0_617, root-of-Bb50, root-of-Bb51, root-of-remodel, v1_50_0_594, v1_50_0_602, v1_51_0_629, v1_51_0_627, v1_50_0_601, v1_51_0_625, v1_51_0_623, v1_50_0_605, v1_50_0_599, v1_50_0_561, v1_51_0_624, v1_51_1_641, v1_51_0_621
Branch point for: Bb51, remodeling, Bb50, Bb49, Bdraw
Changes since 1.12: +0 -1 lines
File MIME type: text/x-pascal
カラムの表示が自由に変えられるようになったため、未取得レス数の表示オプションを削除。

1 unit Sort;
2
3 interface
4 uses
5 Windows, Messages, SysUtils, Classes, Controls, Forms,
6 BoardGroup,DateUtils,
7 Setting;
8
9 function CategorySortProc(Item1, Item2: Pointer): integer;
10 function BoardSortProc(List: TStringList; Item1, Item2: Integer): integer;
11 function ThreadItemSortProc(List: TStringList; Item1, Item2: Integer): integer;
12 function CompareBool(Item1, Item2: Boolean): integer;
13 function CompareInt(Item1, Item2: Integer): Integer;
14 function CompareDate(Item1, Item2: TDateTime): Integer;
15
16 var
17 SortOrder: Boolean;
18 SortIndex: Integer;
19 SortNoFlag: Boolean;
20
21 implementation
22
23 function CategorySortProc(Item1, Item2: Pointer): integer;
24 var
25 CategoryItem1: TCategory;
26 CategoryItem2: TCategory;
27 begin
28 CategoryItem1 := TCategory(Item1);
29 CategoryItem2 := TCategory(Item2);
30
31 case TGikoBBSColumnID( SortIndex ) of
32 gbbscTitle:
33 if SortNoFlag then
34 Result := CompareInt(CategoryItem1.No, CategoryItem2.No)
35 else
36 Result := AnsiCompareText(CategoryItem1.Title, CategoryItem2.Title);
37 else
38 Result := CompareInt(CategoryItem1.No, CategoryItem2.No)
39 end;
40
41 if not SortOrder then
42 Result := Result * -1;
43 end;
44
45 function BoardSortProc(List: TStringList; Item1, Item2: Integer): integer;
46 var
47 BoardItem1: TBoard;
48 BoardItem2: TBoard;
49 begin
50 BoardItem1 := TBoard(List.Objects[Item1]);
51 BoardItem2 := TBoard(List.Objects[Item2]);
52 case TGikoCategoryColumnID( SortIndex ) of
53 gccTitle:
54 if SortNoFlag then
55 Result := CompareInt(BoardItem1.No, BoardItem2.No)
56 else
57 Result := AnsiCompareText(BoardItem1.Title, BoardItem2.Title);
58
59 gccRoundName:
60 Result := CompareInt(BoardItem1.Count, BoardItem2.Count);
61
62 gccLastModified:
63 Result := CompareDate(BoardItem1.RoundDate, BoardItem2.RoundDate);
64 else
65 Result := CompareInt(BoardItem1.No, BoardItem2.No)
66 end;
67
68 if not SortOrder then
69 Result := Result * -1;
70 end;
71
72 function ThreadItemSortProc(List: TStringList; Item1, Item2: Integer): integer;
73 var
74 ThreadItem1: TThreadItem;
75 ThreadItem2: TThreadItem;
76 begin
77 ThreadItem1 := TThreadItem(List.Objects[ Item1 ]);
78 ThreadItem2 := TThreadItem(List.Objects[ Item2 ]);
79 case TGikoBoardColumnID( SortIndex ) of
80 gbcTitle:
81 begin
82 if SortNoFlag then
83 Result := CompareInt(ThreadItem1.No, ThreadItem2.No)
84 else
85 Result := AnsiCompareText(ThreadItem1.Title, ThreadItem2.Title)
86 end;
87
88 gbcAllCount: Result := CompareInt(ThreadItem1.AllResCount, ThreadItem2.AllResCount);
89 gbcLocalCount: Result := CompareInt(ThreadItem1.Count, ThreadItem2.Count);
90 gbcNonAcqCount:
91 begin
92 if ThreadItem1.IsLogFile and ThreadItem2.IsLogFile then
93 Result := CompareInt(ThreadItem1.AllResCount - ThreadItem1.Count, ThreadItem2.AllResCount - ThreadItem2.Count)
94 else if ThreadItem1.IsLogFile then
95 Result := 1
96 else if ThreadItem2.IsLogFile then
97 Result := -1
98 else
99 Result := 0;
100 end;
101
102 gbcNewCount: Result := CompareInt(ThreadItem1.NewResCount, ThreadItem2.NewResCount);
103 gbcUnReadCount: Result := 0;
104 gbcRoundName: Result := AnsiCompareText(ThreadItem1.RoundName, ThreadItem2.RoundName);
105 gbcRoundDate: Result := CompareDateTime(ThreadItem1.RoundDate, ThreadItem2.RoundDate); {gbcLastModified:}
106 gbcCreated: Result := CompareDateTime(ThreadItem1.CreateDate, ThreadItem2.CreateDate);
107 gbcLastModified: Result := CompareDateTime(ThreadItem1.LastModified, ThreadItem2.LastModified); {gbcLastModified:}
108 else
109 Result := 0;
110 end;
111
112 { if SortIndex = 0 then
113 if SortNoFlag then
114 Result := CompareInt(ThreadItem1.No, ThreadItem2.No)
115 else
116 Result := CompareText(ThreadItem1.Title, ThreadItem2.Title)
117 else if SortIndex = 1 then
118 Result := CompareInt(ThreadItem1.Count, ThreadItem2.Count)
119 else if SortIndex = 2 then
120 // Result := CompareInt(ThreadItem1.RoundNo, ThreadItem2.RoundNo)
121 Result := CompareText(ThreadItem1.RoundName, ThreadItem2.RoundName)
122 else
123 Result := CompareDate(ThreadItem1.LastModified, ThreadItem2.LastModified);
124 }
125 if not SortOrder then
126 Result := Result * -1;
127
128 // 鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申1鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?
129 if Result = 0 then begin
130 if SortNoFlag then
131 Result := CompareInt(ThreadItem1.No, ThreadItem2.No)
132 else
133 Result := AnsiCompareText(ThreadItem1.Title, ThreadItem2.Title)
134 end;
135 end;
136
137 function CompareBool(Item1, Item2: Boolean): Integer;
138 begin
139 if (Item1 = True) and (Item2 = False) then
140 Result := 1
141 else if (Item2 = False) and (Item2 = True) then
142 Result := -1
143 else
144 Result := 0;
145 end;
146
147 function CompareInt(Item1, Item2: Integer): Integer;
148 begin
149 if Item1 > Item2 then
150 Result := 1
151 else if Item1 < Item2 then
152 Result := -1
153 else
154 Result := 0;
155 end;
156
157 function CompareDate(Item1, Item2: TDateTime): Integer;
158 begin
159 if Item1 > Item2 then
160 Result := 1
161 else if Item1 < Item2 then
162 Result := -1
163 else
164 Result := 0;
165 end;
166
167 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26