Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/RoundData.pas

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

revision 1.5 by h677, Tue Dec 9 19:26:29 2003 UTC revision 1.6 by h677, Wed Dec 10 13:52:57 2003 UTC
# Line 12  type Line 12  type
12    
13          TRoundList = class(TObject)          TRoundList = class(TObject)
14          private          private
15            FOldFileRead: Boolean;
16                  FBoardList: TList;                  FBoardList: TList;
17                  FItemList: TList;                  FItemList: TList;
18                  function GetCount(RoundType: TGikoRoundType): Integer;                  function GetCount(RoundType: TGikoRoundType): Integer;
# Line 29  type Line 30  type
30                  function Add(ThreadItem: TThreadItem): Integer; overload;                  function Add(ThreadItem: TThreadItem): Integer; overload;
31                  procedure Delete(Board: TBoard); overload;                  procedure Delete(Board: TBoard); overload;
32                  procedure Delete(ThreadItem: TThreadItem); overload;                  procedure Delete(ThreadItem: TThreadItem); overload;
33            procedure Delete(URL: string; RoundType: TGikoRoundType); overload;
34                  procedure Clear;                  procedure Clear;
35                  function Find(Board: TBoard): Integer; overload;                  function Find(Board: TBoard): Integer; overload;
36                  function Find(ThreadItem: TThreadItem): Integer; overload;                  function Find(ThreadItem: TThreadItem): Integer; overload;
37            function Find(URL: string; RoundType: TGikoRoundType): Integer; overload;
38                  property Count[RoundType: TGikoRoundType]: Integer read GetCount;                  property Count[RoundType: TGikoRoundType]: Integer read GetCount;
39            property OldFileRead: Boolean read FOldFileRead;
40                  property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;                  property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;
41                  procedure SetRoundName(Board: TBoard; RoundName: string); overload;                  procedure SetRoundName(Board: TBoard; RoundName: string); overload;
42                  procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;                  procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;
43    
         //procedure ConvertRoundFile; //bata44以前のRoundfileを変換する  
44                  procedure LoadRoundBoardFile;                  procedure LoadRoundBoardFile;
45          procedure LoadRoundThreadFile;          procedure LoadRoundThreadFile;
46                  procedure SaveRoundFile;                  procedure SaveRoundFile;
# Line 48  type Line 51  type
51  //              FBBSType: TGikoBBSType;  //              FBBSType: TGikoBBSType;
52                  FRoundName: string;                  FRoundName: string;
53                  FRoundType: TGikoRoundType;                  FRoundType: TGikoRoundType;
54      FItem                       : TObject;      //Item                      : TObject;
55      FURL                        : string;      FURL                        : string;
56                  FBoardTitle: string;                  FBoardTitle: string;
57                  FThreadTitle: string;                  FThreadTitle: string;
58                  FFileName: string;                  FFileName: string;
59                  FBoolData: Boolean;             //いろいろ使うょぅ                  FBoolData: Boolean;             //いろいろ使うょぅ
60          public          public
61  //              property BBSType: TGikoBBSType read FBBSType write FBBSType;  
62            constructor Create;
63        //property BBSType: TGikoBBSType read FBBSType write FBBSType;
64                  property RoundName: string read FRoundName write FRoundName;                  property RoundName: string read FRoundName write FRoundName;
65                  property RoundType: TGikoRoundType read FRoundType write FRoundType;                  property RoundType: TGikoRoundType read FRoundType write FRoundType;
66      property Item : TObject read FItem write FItem;      //property Item : TObject read FItem write FItem;
67      property URL : string read FURL write FURL;      property URL : string read FURL write FURL;
68                  property BoardTitle: string read FBoardTitle write FBoardTitle;                  property BoardTitle: string read FBoardTitle write FBoardTitle;
69                  property ThreadTitle: string read FThreadTitle write FThreadTitle;                  property ThreadTitle: string read FThreadTitle write FThreadTitle;
# Line 75  const Line 80  const
80          ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //同上          ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //同上
81          ROUND_INDEX_VERSION: string = '2.00';          ROUND_INDEX_VERSION: string = '2.00';
82    
83    constructor TRoundItem.Create;
84    begin
85            inherited Create;
86    end;
87  constructor TRoundList.Create;  constructor TRoundList.Create;
88  begin  begin
89          inherited;          inherited;
# Line 83  begin Line 92  begin
92          RoundNameList := TStringList.Create;          RoundNameList := TStringList.Create;
93          RoundNameList.Sorted := True;          RoundNameList.Sorted := True;
94          RoundNameList.Duplicates := dupIgnore;          RoundNameList.Duplicates := dupIgnore;
95        FOldFileRead := false;
96  end;  end;
97    
98  destructor TRoundList.Destroy;  destructor TRoundList.Destroy;
# Line 105  begin Line 115  begin
115                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
116  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
117                  Item.RoundType := grtBoard;                  Item.RoundType := grtBoard;
118          Item.Item := Board;  //      Item.Item := Board;
119          Item.URL := Board.URL;          Item.URL := Board.URL;
120                  Item.BoardTitle := Board.Title;                  Item.BoardTitle := Board.Title;
121                  Item.ThreadTitle := '';                  Item.ThreadTitle := '';
# Line 126  begin Line 136  begin
136                  Item := TRoundItem.Create;                  Item := TRoundItem.Create;
137  //              Item.BBSType := gbt2ch; //とりあえず  //              Item.BBSType := gbt2ch; //とりあえず
138                  Item.RoundType := grtItem;                  Item.RoundType := grtItem;
139                  Item.Item := ThreadItem;  //              Item.Item := ThreadItem;
140          Item.URL := Threaditem.URL;          Item.URL := Threaditem.URL;
141                  Item.BoardTitle := ThreadItem.ParentBoard.Title;                  Item.BoardTitle := ThreadItem.ParentBoard.Title;
142                  Item.ThreadTitle := ThreadItem.Title;                  Item.ThreadTitle := ThreadItem.Title;
# Line 207  begin Line 217  begin
217                  end;                  end;
218          end;          end;
219  end;  end;
220    function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer;
221    var
222            i: Integer;
223            Item: TRoundItem;
224    begin
225            Result := -1;
226            for i := 0 to FItemList.Count - 1 do begin
227                    Item := TRoundItem(FItemList[i]);
228                    if Item.FRoundType <> RoundType then Continue;
229                    if Item.FURL = URL then begin
230                            Result := i;
231                            Exit;
232                    end;
233            end;
234    end;
235    procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
236    var
237            idx: Integer;
238            Item: TRoundItem;
239        board: TBoard;
240        threadItem: TThreadItem;
241    begin
242            idx := Find(URL, RoundType);
243            if idx <> -1 then begin
244                    Item := TRoundItem(FItemList[idx]);
245                    Item.Free;
246                    FItemList.Delete(idx);
247            if RoundType = grtBoard then begin
248                    board := BBSsFindBoardFromURL(URL);
249                board.Round := False;
250                board.RoundName := '';
251            end else begin
252                threadItem := BBSsFindThreadFromURL(URL);
253                threadItem.Round := false;
254                threadItem.RoundName := '';
255            end;
256            end;
257    end;
258    
259  procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);  procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
260  var  var
# Line 265  begin Line 313  begin
313                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
314                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
315                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
316                Item := TRoundItem.Create;
317              //1行目はバージョン              //1行目はバージョン
318                          if sl[0] = ROUND_INDEX_VERSION then begin                          if sl[0] = ROUND_INDEX_VERSION then begin
319                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
320    
321                                          Item := ParseRoundBoardLine(sl[i]);                                          Item := ParseRoundBoardLine(sl[i]);
322                                          FBoardList.Add(Item);                                          FBoardList.Add(Item);
323                                          RoundNameList.Add(Item.RoundName);                                          RoundNameList.Add(Item.RoundName);
324                                  end;                                  end;
325              end else begin              end else begin
326                                  for i := 1 to sl.Count - 1 do begin                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので
327                                          Item := ParseOldRoundBoardLine(sl[i]);                                          for i := 1 to sl.Count - 1 do begin
328                                          FBoardList.Add(Item);                                                  Item := ParseOldRoundBoardLine(sl[i]);
329                                          RoundNameList.Add(Item.RoundName);                                                  FBoardList.Add(Item);
330                                  end;                                                  RoundNameList.Add(Item.RoundName);
331                                            end;
332                    end else
333                            FOldFileRead := true;
334              end;              end;
335                  end;                  end;
336          finally          finally
# Line 301  begin Line 354  begin
354                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
355                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
356                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
357                Item := TRoundItem.Create;
358                          //1行目はバージョン                          //1行目はバージョン
359              if sl[0] = ROUND_INDEX_VERSION then begin              if sl[0] = ROUND_INDEX_VERSION then begin
360                                  for i := 1 to sl.Count - 1 do begin                                  for i := 1 to sl.Count - 1 do begin
361    
362                                          Item := ParseRoundThreadLine(sl[i], boardList);                                          Item := ParseRoundThreadLine(sl[i], boardList);
363                                          FItemList.Add(Item);                                          FItemList.Add(Item);
364                                          RoundNameList.Add(Item.RoundName);                                          RoundNameList.Add(Item.RoundName);
365                                  end;                                  end;
366              end else begin              end else begin
367                    LoadRoundBoardFile;
368                  for i := 1 to sl.Count - 1 do begin                  for i := 1 to sl.Count - 1 do begin
369                                          Item := ParseOldRoundThreadLine(sl[i], boardList);                                          Item := ParseOldRoundThreadLine(sl[i], boardList);
370                                          FItemList.Add(Item);                                          FItemList.Add(Item);
# Line 381  begin Line 437  begin
437                  0:                  0:
438                  begin                  begin
439                          Result.URL := s;                          Result.URL := s;
                 Result.Item := BBSsFindBoardFromURL( s );  
440                  end;                  end;
441              1: Result.BoardTitle := s;              1: Result.BoardTitle := s;
442              2: Result.RoundName := s;              2: Result.RoundName := s;
# Line 405  begin Line 460  begin
460                          Result.URL := s;                          Result.URL := s;
461                  threadItem := BBSsFindThreadFromURL( s );                  threadItem := BBSsFindThreadFromURL( s );
462                  if threadItem <> nil then begin                  if threadItem <> nil then begin
                         Result.Item := threadItem;  
463                          BoardList.Add( threadItem.ParentBoard.URL );                          BoardList.Add( threadItem.ParentBoard.URL );
464                  end;                  end;
465                  end;                  end;
# Line 421  function TRoundList.ParseOldRoundBoardLi Line 475  function TRoundList.ParseOldRoundBoardLi
475      var      var
476      i: Integer;      i: Integer;
477          s: string;          s: string;
         buf: string;  
478      board: TBoard;      board: TBoard;
     threadItem: TThreadItem;  
479  begin  begin
480          Result := TRoundItem.Create;          Result := TRoundItem.Create;
481      Result.ThreadTitle := '';      Result.ThreadTitle := '';
482      Result.FileName := '';      Result.FileName := '';
483      Result.RoundType := grtBoard;      Result.RoundType := grtBoard;
484      for i := 0 to 1 do begin      for i := 0 to 2 do begin
485          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
486          case i of          case i of
487                  0:                  0:
488                  begin                  begin
                 Result.BoardTitle := s;  
489                  board := BBSs[ 0 ].FindBBSID( s );                  board := BBSs[ 0 ].FindBBSID( s );
490                          Result.URL := board.URL;                          Result.URL := board.URL;
                 Result.Item := BBSsFindBoardFromURL( Result.URL );  
491                  end;                  end;
492              1: Result.RoundName := s;              1: Result.FBoardTitle := s;
493                2: Result.RoundName := s;
494          end;          end;
495      end;      end;
496  end;  end;
# Line 451  function TRoundList.ParseOldRoundThreadL Line 502  function TRoundList.ParseOldRoundThreadL
502          buf: string;          buf: string;
503      board: TBoard;      board: TBoard;
504      threadItem: TThreadItem;      threadItem: TThreadItem;
505        bbsID: string;
506  begin  begin
507          Result := TRoundItem.Create;          Result := TRoundItem.Create;
508      Result.RoundType := grtItem;      Result.RoundType := grtItem;
509      for i := 0 to 3 do begin      for i := 0 to 4 do begin
510          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
511          case i of          case i of
512                  0: Result.BoardTitle := s;              0: bbsID := s;
513              1:              1: Result.BoardTitle := s;
514                2:
515                  begin                  begin
516                  Result.FileName := s;                  Result.FileName := s;
517                  board := BBSs[ 0 ].FindBoardFromTitle(Result.BoardTitle);                  board := BBSs[ 0 ].FindBoardFromTitle(Result.BoardTitle);
# Line 466  begin Line 519  begin
519                      BoardList.Add(board.URL);                      BoardList.Add(board.URL);
520                      buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);                      buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
521                                          Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';                                          Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
                     threadItem := BBSsFindThreadFromURL(Result.URL);  
                     if threadItem <> nil then begin  
                         Result.Item := threadItem;  
                     end;  
522                  end;                  end;
523              end;              end;
524              2: Result.ThreadTitle := s;              3: Result.ThreadTitle := s;
525              3: Result.RoundName := s;              4: Result.RoundName := s;
526          end;          end;
527      end;      end;
528  end;  end;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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