6 Windows, Messages, SysUtils, Classes,
7 GikoSystem, BoardGroup;
10 TGikoRoundType = (grtBoard, grtItem);
13 TRoundList = class(TObject)
17 function GetCount(RoundType: TGikoRoundType): Integer;
18 function GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
19 function ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;
21 RoundNameList: TStringList;
24 destructor Destroy; override;
25 function Add(Board: TBoard): Integer; overload;
26 function Add(ThreadItem: TThreadItem): Integer; overload;
27 procedure Delete(Board: TBoard); overload;
28 procedure Delete(ThreadItem: TThreadItem); overload;
30 function Find(Board: TBoard): Integer; overload;
31 function Find(ThreadItem: TThreadItem): Integer; overload;
32 property Count[RoundType: TGikoRoundType]: Integer read GetCount;
33 property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;
34 procedure SetRoundName(Board: TBoard; RoundName: string); overload;
35 procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;
37 procedure LoadRoundFile;
38 procedure SaveRoundFile;
41 TRoundItem = class(TObject)
43 // FBBSType: TGikoBBSType;
45 FRoundType: TGikoRoundType;
50 FBoolData: Boolean; //
\82¢
\82ë
\82¢
\82ë
\8eg
\82¤
\82å
\82£
52 // property BBSType: TGikoBBSType read FBBSType write FBBSType;
53 property RoundName: string read FRoundName write FRoundName;
54 property RoundType: TGikoRoundType read FRoundType write FRoundType;
55 property BBSID: string read FBBSID write FBBSID;
56 property BoardTitle: string read FBoardTitle write FBoardTitle;
57 property ThreadTitle: string read FThreadTitle write FThreadTitle;
58 property FileName: string read FFileName write FFileName;
59 property BoolData: Boolean read FBoolData write FBoolData;
63 RoundList: TRoundList;
67 ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch'; //
\82 \82Æ
\82ÅBoardGroup
\82Ö
\88Ú
\93®
68 ROUND_ITEM_FILENAME: string = 'RoundItem.2ch'; //
\93¯
\8fã
69 ROUND_INDEX_VERSION: string = '1.00';
71 constructor TRoundList.Create;
74 FBoardList := TList.Create;
75 FItemList := TList.Create;
76 RoundNameList := TStringList.Create;
77 RoundNameList.Sorted := True;
78 RoundNameList.Duplicates := dupIgnore;
81 destructor TRoundList.Destroy;
90 function TRoundList.Add(Board: TBoard): Integer;
97 if idx = -1 then begin
98 Item := TRoundItem.Create;
99 // Item.BBSType := gbt2ch; //
\82Æ
\82è
\82 \82¦
\82¸
100 Item.RoundType := grtBoard;
101 Item.BBSID := Board.BBSID;
102 Item.BoardTitle := Board.Title;
103 Item.ThreadTitle := '';
105 Item.RoundName := Board.RoundName;
106 Result := FBoardList.Add(Item);
110 function TRoundList.Add(ThreadItem: TThreadItem): Integer;
116 idx := Find(ThreadItem);
117 if idx = -1 then begin
118 Item := TRoundItem.Create;
119 // Item.BBSType := gbt2ch; //
\82Æ
\82è
\82 \82¦
\82¸
120 Item.RoundType := grtItem;
121 Item.BBSID := ThreadItem.ParentBoard.BBSID;
122 Item.BoardTitle := ThreadItem.ParentBoard.Title;
123 Item.ThreadTitle := ThreadItem.Title;
124 Item.FileName := ThreadItem.FileName;
125 Item.RoundName := ThreadItem.RoundName;
126 Result := FItemList.Add(Item);
130 procedure TRoundList.Delete(Board: TBoard);
136 if idx <> -1 then begin
137 Item := TRoundItem(FBoardList[idx]);
139 FBoardList.Delete(idx);
143 procedure TRoundList.Delete(ThreadItem: TThreadItem);
148 idx := Find(ThreadItem);
149 if idx <> -1 then begin
150 Item := TRoundItem(FItemList[idx]);
152 FItemList.Delete(idx);
156 procedure TRoundList.Clear;
160 for i := FBoardList.Count - 1 downto 0 do begin
161 TRoundItem(FBoardList[i]).Free;
162 FBoardList.Delete(i);
164 for i := FItemList.Count - 1 downto 0 do begin
165 TRoundItem(FItemList[i]).Free;
170 function TRoundList.Find(Board: TBoard): Integer;
176 for i := 0 to FBoardList.Count - 1 do begin
177 Item := TRoundItem(FBoardList[i]);
178 if Item.FRoundType <> grtBoard then Continue;
179 if Item.FBBSID = Board.BBSID then begin
186 function TRoundList.Find(ThreadItem: TThreadItem): Integer;
192 for i := 0 to FItemList.Count - 1 do begin
193 Item := TRoundItem(FItemList[i]);
194 if Item.FRoundType <> grtItem then Continue;
195 if (Item.FBBSID = ThreadItem.ParentBoard.BBSID) and (Item.FFileName = ThreadItem.FileName) then begin
202 procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
208 if idx <> -1 then begin
209 Item := TRoundItem(FBoardList[idx]);
210 Item.RoundName := RoundName;
214 procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);
219 idx := Find(ThreadItem);
220 if idx <> -1 then begin
221 Item := TRoundItem(FItemList[idx]);
222 Item.RoundName := RoundName;
226 function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;
229 if RoundType = grtBoard then
230 Result := FBoardList.Count
231 else if RoundType = grtItem then
232 Result := FItemList.Count;
235 function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
238 if RoundType = grtBoard then begin
239 if (Index >= 0) and (Index < FBoardList.Count) then
240 Result := TRoundItem(FBoardList[Index]);
241 end else if RoundType = grtItem then begin
242 if (Index >= 0) and (Index < FItemList.Count) then
243 Result := TRoundItem(FItemList[Index]);
247 procedure TRoundList.LoadRoundFile;
254 sl := TStringList.Create;
256 //
\83{
\81[
\83h
\8f\84\89ñ
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
257 FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
258 if FileExists(FileName) then begin
259 sl.LoadFromFile(FileName);
260 //
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\82È
\82Ì
\82Å
\96³
\8e\8b
261 for i := 1 to sl.Count - 1 do begin
262 Item := ParseRoundLine(sl[i], grtBoard);
263 FBoardList.Add(Item);
264 RoundNameList.Add(Item.RoundName);
267 //
\83X
\83\8c\8f\84\89ñ
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
268 FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
269 if FileExists(FileName) then begin
270 sl.LoadFromFile(FileName);
271 //
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\82È
\82Ì
\82Å
\96³
\8e\8b
272 for i := 1 to sl.Count - 1 do begin
273 Item := ParseRoundLine(sl[i], grtItem);
275 RoundNameList.Add(Item.RoundName);
283 procedure TRoundList.SaveRoundFile;
291 GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir);
293 sl := TStringList.Create;
295 FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
296 sl.Add(ROUND_INDEX_VERSION);
297 for i := 0 to FBoardList.Count - 1 do begin
298 Item := TRoundItem(FBoardList[i]);
300 + Item.BoardTitle + #1
304 sl.SaveToFile(FileName);
306 FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
307 sl.Add(ROUND_INDEX_VERSION);
308 for i := 0 to FItemList.Count - 1 do begin
309 Item := TRoundItem(FItemList[i]);
311 + Item.BoardTitle + #1
313 + Item.ThreadTitle + #1
317 sl.SaveToFile(FileName);
323 function TRoundList.ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;
328 Result := TRoundItem.Create;
329 if RoundType = grtBoard then begin
330 Result.ThreadTitle := '';
331 Result.FileName := '';
332 Result.RoundType := grtBoard;
333 for i := 0 to 2 do begin
334 s := GikoSys.GetTokenIndex(Line, #1, i);
336 0: Result.BBSID := s;
337 1: Result.BoardTitle := s;
338 2: Result.RoundName := s;
341 end else if RoundType = grtItem then begin
342 Result.RoundType := grtItem;
343 for i := 0 to 4 do begin
344 s := GikoSys.GetTokenIndex(Line, #1, i);
346 0: Result.BBSID := s;
347 1: Result.BoardTitle := s;
348 2: Result.FileName := s;
349 3: Result.ThreadTitle := s;
350 4: Result.RoundName := s;