Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/Giko.pas

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

revision 1.622 by h677, Fri Dec 29 13:04:04 2006 UTC revision 1.623 by h677, Sun Dec 31 01:29:28 2006 UTC
# Line 19  uses Line 19  uses
19          HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager,          HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager,
20          ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,          ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,
21          IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem,          IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem,
22      ShellAPI,Preview;      ShellAPI,Preview, HistoryList;
23    
24  const  const
25          NGWORDNAME_PANEL = 3;          NGWORDNAME_PANEL = 3;
26          THREADSIZE_PANEL = 2;          THREADSIZE_PANEL = 2;
27                    
28  type  type
29          TGikoTreeType = (gttNone, gtt2ch, gttHistory, gttFavorite);  
30          TToolBarSettingSenderType = (tssNone, tssMain, tssList, tssBrowser);          TToolBarSettingSenderType = (tssNone, tssMain, tssList, tssBrowser);
31          TMinimizeType = (mtNone, mtMinimizing, mtMinimized);          TMinimizeType = (mtNone, mtMinimizing, mtMinimized);
32          TResizeType = (rtNone, rtResizing);          TResizeType = (rtNone, rtResizing);
# Line 569  type Line 569  type
569                  FActiveList: TObject;                  FActiveList: TObject;
570                  FActiveContent: TBrowserRecord; //                  FActiveContent: TBrowserRecord; //
571                  FActiveBBS : TBBS;                  FActiveBBS : TBBS;
572                  FHistoryList: TList;                                    //ヒストリリスト                  FHistoryList: THistoryList;                                     //ヒストリリスト
573                  FTreeType: TGikoTreeType;                  FTreeType: TGikoTreeType;
574                  FWorkCount: Integer;                  FWorkCount: Integer;
575                  FNameCookie: string;                  FNameCookie: string;
# Line 722  type Line 722  type
722                  procedure SetListViewType(AViewType: TGikoViewType); overload;                  procedure SetListViewType(AViewType: TGikoViewType); overload;
723                  procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;                  procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;
724                  procedure PlaySound(SoundEventName: string);                  procedure PlaySound(SoundEventName: string);
                 function AddHistory( FavItem: TFavoriteThreadItem ): Boolean;  
                 procedure ClearHistory;  
                 procedure       SaveHistory;  
                 procedure       LoadHistory;  
725                  procedure ShowBBSTree( inBBS : TBBS );                  procedure ShowBBSTree( inBBS : TBBS );
726                  procedure ShowBBSTreeOld( inBBS : TBBS );                  procedure ShowBBSTreeOld( inBBS : TBBS );
727                  procedure ShowHistoryTree;                  procedure ShowHistoryTree;
# Line 1138  begin Line 1134  begin
1134    
1135    
1136          // ヒストリリスト(LoadHistory よりも先に行うこと)          // ヒストリリスト(LoadHistory よりも先に行うこと)
1137          FHistoryList := TList.Create;          FHistoryList := THistoryList.Create;
1138    
1139          // 履歴読み込み          // 履歴読み込み
1140          LoadHistory;          FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1141            TreeView, FTreeType);
1142    
1143          //お気に入り読み込み          //お気に入り読み込み
1144          FavoriteDM.SetFavTreeView(FavoriteTreeView);          FavoriteDM.SetFavTreeView(FavoriteTreeView);
# Line 1616  begin Line 1613  begin
1613    
1614          //ヒストリリスト保存          //ヒストリリスト保存
1615          try          try
1616                  SaveHistory;                  FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1617          except          except
1618          end;          end;
1619          try          try
1620                  try                  try
1621                          ClearHistory;                          FHistoryList.Clear;
1622                  except                  except
1623                  end;                  end;
1624          finally          finally
# Line 1767  begin Line 1764  begin
1764    
1765          //履歴の保存と破棄          //履歴の保存と破棄
1766          try          try
1767                  SaveHistory;                  FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1768                  ClearHistory;                  FHistoryList.Clear;
1769          except          except
1770          end;          end;
1771    
# Line 1819  begin Line 1816  begin
1816          ShowBBSTree( BBSs[ 0 ] );          ShowBBSTree( BBSs[ 0 ] );
1817    
1818          // 履歴読み込み          // 履歴読み込み
1819          LoadHistory;      FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1820            TreeView, FTreeType);
1821    
1822          //お気に入り読み込み          //お気に入り読み込み
1823          FavoriteDM.ReadFavorite;          FavoriteDM.ReadFavorite;
# Line 2539  begin Line 2537  begin
2537                                  FBrowsers.Move(BROWSER_COUNT - 1, 0);                                  FBrowsers.Move(BROWSER_COUNT - 1, 0);
2538                  end;                  end;
2539                  favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title );                  favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title );
2540                  if not AddHistory( favItem ) then                  if not FHistoryList.AddHistory( favItem, TreeView, FTreeType ) then
2541                          favItem.Free;                          favItem.Free;
2542    
2543                  for i := 0 to BrowserTab.Tabs.Count - 1 do begin                  for i := 0 to BrowserTab.Tabs.Count - 1 do begin
# Line 3019  begin Line 3017  begin
3017          end;          end;
3018  end;  end;
3019    
3020  function TGikoForm.AddHistory( favItem : TFavoriteThreadItem ): Boolean;  //履歴から削除
 var  
         i: Integer;  
         Item: TFavoriteThreadItem;  
         Node: TTreeNode;  
 begin  
 //      Result := False;  
 //      if (GetActiveContent = ThreadItem) and  
 //                      (ThreadItem.Count <= ThreadItem.Kokomade) then  
 //              Exit;  
 //      if GetActiveContent = ThreadItem then  
 //              Exit;  
   
         Result := True;  
         if FTreeType = gttHistory then  
         TreeView.Selected := nil;  
   
         for i := 0 to FHistoryList.Count - 1 do begin  
                 if TObject(FHistoryList[i]) is TFavoriteThreadItem then begin  
                         Item := TFavoriteThreadItem(FHistoryList[i]);  
                         if Item.URL = favItem.URL then begin  
 //                              SetContent(ThreadItem);  
                                 FHistoryList.Move(i, 0);  
                                 if FTreeType = gttHistory then  
                                         if TreeView.Items.GetFirstNode <> TreeView.Items[ i ] then  
                                                 TreeView.Items[ i ].MoveTo( TreeView.Items.GetFirstNode, naInsert );  
                                                                 Result := false;  
                                 Exit;  
                         end;  
                 end;  
         end;  
   
         if FHistoryList.Count > 0 then  
                 FHistoryList.Insert( 0, favItem )  
         else  
                 FHistoryList.Add( favItem );  
 //      SetContent(ThreadItem);  
 //      while GikoSys.Setting.AddressHistoryCount < FHistoryList.Count do begin  
         while GikoSys.Setting.MaxRecordCount < FHistoryList.Count do begin  
                 i := FHistoryList.Count - 1;  
                 TObject( FHistoryList.Items[ i ] ).Free;  
                 FHistoryList.Delete( i );  
         end;  
   
         if FTreeType = gttHistory then begin  
                 Node := TreeView.Items.Add( nil, favItem.Title );  
                 Node.MoveTo( TreeView.Items.GetFirstNode, naInsert );  
                 {  
                 if favItem.NewArrival then begin  
                         Node.ImageIndex := ITEM_ICON_THREADNEW1;  
                         Node.SelectedIndex := ITEM_ICON_THREADNEW2;  
                 end else begin  
                         Node.ImageIndex := ITEM_ICON_THREADLOG1;  
                         Node.SelectedIndex := ITEM_ICON_THREADLOG2;  
                 end;  
                 }  
                 // 負荷をかけたくないので NewArrival のチェックを行わない  
                 // ※favItem.Item プロパティは dat の読み込みを必要とする  
                 Node.ImageIndex := ITEM_ICON_THREADLOG1;  
                 Node.SelectedIndex := ITEM_ICON_THREADLOG2;  
                 Node.Data := favItem;  
                 //while GikoSys.Setting.AddressHistoryCount < TreeView.Items.Count do begin  
                 while GikoSys.Setting.MaxRecordCount < TreeView.Items.Count do begin  
                         i := TreeView.Items.Count - 1;  
                         TreeView.Items.Item[ i ].Delete;  
                 end;  
         end;  
 end;  
   
3021  procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );  procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );
 var  
         i: Integer;  
         node: TTreeNode;  
 begin  
         // キャビネットに履歴が表示されていたら、  
         // キャビネット内のアイテムも削除する。  
         if (FTreeType = gttHistory) then begin  
                 node := TreeView.Items.GetFirstNode;  
                 while (node <> nil) do begin  
                         if ( TFavoriteThreadItem(node.Data).Item  = threadItem ) then begin  
                                 TreeView.Items.Delete(node);  
                                 TreeView.Refresh;  
                                 node := nil;  
                         end else begin  
                                 node := node.GetNext;  
                         end;  
                 end;  
         end;  
         for i := 0 to FHistoryList.Count - 1 do begin  
                 if threadItem = TFavoriteThreadItem( FHistoryList.Items[i] ).Item then begin  
                         TFavoriteThreadItem( FHistoryList.Items[ i ] ).Free;  
                         FHistoryList.Delete(i);  
                         FHistoryList.Capacity := FHistoryList.Count;  
                         Break;  
                 end;  
         end;  
 end;  
   
 procedure TGikoForm.ClearHistory;  
 var  
         i : Integer;  
3022  begin  begin
3023          //FHistoryList.Clear;      FHistoryList.DeleteHistory( threadItem, TreeView, TreeType );
   
         try  
                 for i := FHistoryList.Count - 1 downto 0 do begin  
                         if TObject(FHistoryList[ i ]) is TFavoriteThreadItem then  
                 TFavoriteThreadItem(FHistoryList[ i ]).Free  
             else if TObject(FHistoryList[ i ]) is TFavoriteBoardItem then  
                 TFavoriteBoardItem(FHistoryList[ i ]).Free;  
   
                         //FHistoryList.Delete(i);  
         end;  
         except  
         end;  
   
         FHistoryList.Clear;  
     FHistoryList.Capacity := FHistoryList.Count;  
   
 end;  
   
 procedure TGikoForm.SaveHistory;  
 var  
         i, bound        : Integer;  
         saveList        : TstringList;  
 begin  
   
         saveList := TStringList.Create;  
         try  
                 FHistoryList.Pack;  
         FHistoryList.Capacity := FHistoryList.Count;  
                 saveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');  
                 saveList.Add('<address>');  
                 bound := FHistoryList.Count - 1;  
                 for i := bound downto 0 do begin  
                         // title は今のところ使っていない  
                         saveList.Add(  
                                 '<history url="' + HtmlEncode( TFavoriteThreadItem( FHistoryList[ i ] ).URL ) + '"' +  
                                 ' title="' + HtmlEncode( MojuUtils.Sanitize(TFavoriteThreadItem( FHistoryList[ i ] ).Title )) + '"/>');  
                 end;  
                 saveList.Add('</address>');  
                 saveList.SaveToFile( GikoSys.GetConfigDir + 'History.xml' );  
         finally  
                 saveList.Free;  
         end;  
   
 end;  
   
 procedure TGikoForm.LoadHistory;  
 var  
         i, bound                : Integer;  
         fileName                : string;  
         XMLDoc                  : IXMLDocument;  
         XMLNode                 : IXMLNode;  
         HistoryNode     : IXMLNode;  
         s                                               : string;  
         favItem                 : TFavoriteThreadItem;  
 {$IFDEF DEBUG}  
         st, rt : Cardinal;  
 {$ENDIF}  
 begin  
 {$IFDEF DEBUG}  
         st := GetTickCount;  
 {$ENDIF}  
   
         fileName := GikoSys.GetConfigDir + 'History.xml';  
   
         if FileExists( fileName ) then begin  
                 try  
                         XMLDoc := IXMLDocument.Create;  
                         //XMLDoc := LoadXMLDocument(FileName);  
                         LoadXMLDocument(FileName, XMLDoc);  
                         try  
                                 XMLNode := XMLDoc.DocumentElement;  
   
                                 if XMLNode.NodeName = 'address' then begin  
                                         bound := XMLNode.ChildNodes.Count - 1;  
                                         for i := 0 to bound do begin  
                                                 HistoryNode := XMLNode.ChildNodes[i];  
                                                 if HistoryNode.NodeName = 'history' then begin  
                                                         //if FReadCount >= sl.Count then begin  
                                                                 s := Trim(HistoryNode.Attributes['url']);  
                                                                 if s <> '' then begin  
                                                                         favItem := TFavoriteThreadItem.Create(  
                                                                                 s, MojuUtils.UnSanitize(HistoryNode.Attributes[ 'title' ]) );  
                                                                         if not AddHistory( favItem ) then  
                                                                                 favItem.Free;  
                                                                 end;  
                                                         //end;  
                                                 end;  
                                         end;  
                                 end;  
                         finally  
                                 XMLDoc.Free;  
                         end;  
                 except  
                 end;  
         end;  
 {$IFDEF DEBUG}  
         rt := GetTickCount - st;  
         Writeln('Runtime(Load Histroy) : ' + IntToStr(rt) + ' ms');  
 {$ENDIF}  
   
3024  end;  end;
3025    
3026  procedure TGikoForm.ShowBBSTreeOld(  procedure TGikoForm.ShowBBSTreeOld(
# Line 5071  begin Line 4870  begin
4870                  if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then                  if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then
4871                          if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then                          if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then
4872                                  Exit;                                  Exit;
                 ClearHistory;  
4873                  FHistoryList.Clear;                  FHistoryList.Clear;
4874                  TreeView.Items.Clear;                  TreeView.Items.Clear;
4875          end;          end;

Legend:
Removed from v.1.622  
changed lines
  Added in v.1.623

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