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.10 - (show annotations) (download) (as text)
Thu Sep 16 14:09:52 2004 UTC (19 years, 7 months ago) by yoffy
Branch: MAIN
Changes since 1.9: +4 -0 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 SortNonAcquiredCountFlag: Boolean;
21
22 implementation
23
24 function CategorySortProc(Item1, Item2: Pointer): integer;
25 var
26 CategoryItem1: TCategory;
27 CategoryItem2: TCategory;
28 begin
29 CategoryItem1 := TCategory(Item1);
30 CategoryItem2 := TCategory(Item2);
31
32 case TGikoBBSColumnID( SortIndex ) of
33 gbbscTitle:
34 if SortNoFlag then
35 Result := CompareInt(CategoryItem1.No, CategoryItem2.No)
36 else
37 Result := AnsiCompareText(CategoryItem1.Title, CategoryItem2.Title);
38 else
39 Result := CompareInt(CategoryItem1.No, CategoryItem2.No)
40 end;
41
42 if not SortOrder then
43 Result := Result * -1;
44 end;
45
46 function BoardSortProc(List: TStringList; Item1, Item2: Integer): integer;
47 var
48 BoardItem1: TBoard;
49 BoardItem2: TBoard;
50 begin
51 BoardItem1 := TBoard(List.Objects[Item1]);
52 BoardItem2 := TBoard(List.Objects[Item2]);
53 case TGikoCategoryColumnID( SortIndex ) of
54 gccTitle:
55 if SortNoFlag then
56 Result := CompareInt(BoardItem1.No, BoardItem2.No)
57 else
58 Result := AnsiCompareText(BoardItem1.Title, BoardItem2.Title);
59
60 gccRoundName:
61 Result := CompareInt(BoardItem1.Count, BoardItem2.Count);
62
63 gccLastModified:
64 Result := CompareDate(BoardItem1.RoundDate, BoardItem2.RoundDate);
65 else
66 Result := CompareInt(BoardItem1.No, BoardItem2.No)
67 end;
68
69 if not SortOrder then
70 Result := Result * -1;
71 end;
72
73 function ThreadItemSortProc(List: TStringList; Item1, Item2: Integer): integer;
74 var
75 ThreadItem1: TThreadItem;
76 ThreadItem2: TThreadItem;
77 begin
78 ThreadItem1 := TThreadItem(List.Objects[ Item1 ]);
79 ThreadItem2 := TThreadItem(List.Objects[ Item2 ]);
80 case TGikoBoardColumnID( SortIndex ) of
81 gbcTitle:
82 begin
83 if SortNoFlag then
84 Result := CompareInt(ThreadItem1.No, ThreadItem2.No)
85 else
86 Result := AnsiCompareText(ThreadItem1.Title, ThreadItem2.Title)
87 end;
88
89 gbcAllCount: Result := CompareInt(ThreadItem1.AllResCount, ThreadItem2.AllResCount);
90 gbcLocalCount: Result := CompareInt(ThreadItem1.Count, ThreadItem2.Count);
91 gbcNonAcqCount:
92 begin
93 if ThreadItem1.IsLogFile and ThreadItem2.IsLogFile then
94 Result := CompareInt(ThreadItem1.AllResCount - ThreadItem1.Count, ThreadItem2.AllResCount - ThreadItem2.Count)
95 else if ThreadItem1.IsLogFile then
96 Result := 1
97 else if ThreadItem2.IsLogFile then
98 Result := -1
99 else
100 Result := 0;
101 end;
102
103 gbcNewCount: Result := CompareInt(ThreadItem1.NewResCount, ThreadItem2.NewResCount);
104 gbcUnReadCount: Result := 0;
105 gbcRoundName: Result := AnsiCompareText(ThreadItem1.RoundName, ThreadItem2.RoundName);
106 gbcLastModified: Result := CompareDateTime(ThreadItem1.RoundDate, ThreadItem2.RoundDate);
107 gbcCreated: Result := CompareDateTime(ThreadItem1.CreateDate, ThreadItem2.CreateDate);
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