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;
96 if idx = -1 then begin
97 Item := TRoundItem.Create;
98 // Item.BBSType := gbt2ch; //
\82Æ
\82è
\82 \82¦
\82¸
99 Item.RoundType := grtBoard;
100 Item.BBSID := Board.BBSID;
101 Item.BoardTitle := Board.Title;
102 Item.ThreadTitle := '';
104 Item.RoundName := Board.RoundName;
105 FBoardList.Add(Item);
109 function TRoundList.Add(ThreadItem: TThreadItem): Integer;
114 idx := Find(ThreadItem);
115 if idx = -1 then begin
116 Item := TRoundItem.Create;
117 // Item.BBSType := gbt2ch; //
\82Æ
\82è
\82 \82¦
\82¸
118 Item.RoundType := grtItem;
119 Item.BBSID := ThreadItem.ParentBoard.BBSID;
120 Item.BoardTitle := ThreadItem.ParentBoard.Title;
121 Item.ThreadTitle := ThreadItem.Title;
122 Item.FileName := ThreadItem.FileName;
123 Item.RoundName := ThreadItem.RoundName;
128 procedure TRoundList.Delete(Board: TBoard);
134 if idx <> -1 then begin
135 Item := TRoundItem(FBoardList[idx]);
137 FBoardList.Delete(idx);
141 procedure TRoundList.Delete(ThreadItem: TThreadItem);
146 idx := Find(ThreadItem);
147 if idx <> -1 then begin
148 Item := TRoundItem(FItemList[idx]);
150 FItemList.Delete(idx);
154 procedure TRoundList.Clear;
158 for i := FBoardList.Count - 1 downto 0 do begin
159 TRoundItem(FBoardList[i]).Free;
160 FBoardList.Delete(i);
162 for i := FItemList.Count - 1 downto 0 do begin
163 TRoundItem(FItemList[i]).Free;
168 function TRoundList.Find(Board: TBoard): Integer;
174 for i := 0 to FBoardList.Count - 1 do begin
175 Item := TRoundItem(FBoardList[i]);
176 if Item.FRoundType <> grtBoard then Continue;
177 if Item.FBBSID = Board.BBSID then begin
184 function TRoundList.Find(ThreadItem: TThreadItem): Integer;
190 for i := 0 to FItemList.Count - 1 do begin
191 Item := TRoundItem(FItemList[i]);
192 if Item.FRoundType <> grtItem then Continue;
193 if (Item.FBBSID = ThreadItem.ParentBoard.BBSID) and (Item.FFileName = ThreadItem.FileName) then begin
200 procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
206 if idx <> -1 then begin
207 Item := TRoundItem(FBoardList[idx]);
208 Item.RoundName := RoundName;
212 procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);
217 idx := Find(ThreadItem);
218 if idx <> -1 then begin
219 Item := TRoundItem(FItemList[idx]);
220 Item.RoundName := RoundName;
224 function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;
227 if RoundType = grtBoard then
228 Result := FBoardList.Count
229 else if RoundType = grtItem then
230 Result := FItemList.Count;
233 function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
236 if RoundType = grtBoard then begin
237 if (Index >= 0) and (Index < FBoardList.Count) then
238 Result := TRoundItem(FBoardList[Index]);
239 end else if RoundType = grtItem then begin
240 if (Index >= 0) and (Index < FItemList.Count) then
241 Result := TRoundItem(FItemList[Index]);
245 procedure TRoundList.LoadRoundFile;
252 sl := TStringList.Create;
254 //
\83{
\81[
\83h
\8f\84\89ñ
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
255 FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
256 if FileExists(FileName) then begin
257 sl.LoadFromFile(FileName);
258 //
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\82È
\82Ì
\82Å
\96³
\8e\8b
259 for i := 1 to sl.Count - 1 do begin
260 Item := ParseRoundLine(sl[i], grtBoard);
261 FBoardList.Add(Item);
262 RoundNameList.Add(Item.RoundName);
265 //
\83X
\83\8c\8f\84\89ñ
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
266 FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
267 if FileExists(FileName) then begin
268 sl.LoadFromFile(FileName);
269 //
\82P
\8ds
\96Ú
\82Í
\83o
\81[
\83W
\83\87\83\93\82È
\82Ì
\82Å
\96³
\8e\8b
270 for i := 1 to sl.Count - 1 do begin
271 Item := ParseRoundLine(sl[i], grtItem);
273 RoundNameList.Add(Item.RoundName);
281 procedure TRoundList.SaveRoundFile;
289 GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir);
291 sl := TStringList.Create;
293 FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
294 sl.Add(ROUND_INDEX_VERSION);
295 for i := 0 to FBoardList.Count - 1 do begin
296 Item := TRoundItem(FBoardList[i]);
298 + Item.BoardTitle + #1
302 sl.SaveToFile(FileName);
304 FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
305 sl.Add(ROUND_INDEX_VERSION);
306 for i := 0 to FItemList.Count - 1 do begin
307 Item := TRoundItem(FItemList[i]);
309 + Item.BoardTitle + #1
311 + Item.ThreadTitle + #1
315 sl.SaveToFile(FileName);
321 function TRoundList.ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;
326 Result := TRoundItem.Create;
327 if RoundType = grtBoard then begin
328 Result.ThreadTitle := '';
329 Result.FileName := '';
330 Result.RoundType := grtBoard;
331 for i := 0 to 2 do begin
332 s := GikoSys.GetTokenIndex(Line, #1, i);
334 0: Result.BBSID := s;
335 1: Result.BoardTitle := s;
336 2: Result.RoundName := s;
339 end else if RoundType = grtItem then begin
340 Result.RoundType := grtItem;
341 for i := 0 to 4 do begin
342 s := GikoSys.GetTokenIndex(Line, #1, i);
344 0: Result.BBSID := s;
345 1: Result.BoardTitle := s;
346 2: Result.FileName := s;
347 3: Result.ThreadTitle := s;
348 4: Result.RoundName := s;