OSDN Git Service

・履歴を保存するようにしてみた。
authoryoffy <yoffy>
Sun, 23 Nov 2003 18:00:42 +0000 (18:00 +0000)
committeryoffy <yoffy>
Sun, 23 Nov 2003 18:00:42 +0000 (18:00 +0000)
Giko.pas

index 6724a4b..295e529 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -19,7 +19,8 @@ uses
        Editor, RoundData, RoundName, KeySetting, GikoPanel, Favorite, FavoriteAdd,
        FavoriteArrange, AddressHistory, Preview, HTMLDocumentEvent, Kotehan,
        HintWindow, GikoCoolBar, GikoListView, ToolBarSetting, ToolBarUtil,
-       IndividualAbon, Dialogs, Search, ExternalBoardManager, ExternalBoardPlugInMain, StdActns;
+       IndividualAbon, Dialogs, Search, ExternalBoardManager, ExternalBoardPlugInMain,
+       StdActns, GikoXMLDoc;
 
 type
        TGikoTreeType = (gttNone, gtt2ch, gttHistory);
@@ -961,6 +962,8 @@ type
                function AddHistory(ThreadItem: TThreadItem): Boolean;
                procedure DeleteHistory(ThreadItem: TThreadItem);
                procedure ClearHistory;
+               procedure       SaveHistory;
+               procedure       LoadHistory;
                procedure ShowBBSTree( inBBS : TBBS );
                procedure ShowHistoryTree;
                procedure SetHistoryTreeNode;
@@ -1100,7 +1103,7 @@ begin
        //\83A\83h\83\8c\83X\97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
        AddressHistoryDM.ReadHistory(AddressComboBox.Items, GikoSys.Setting.AddressHistoryCount);
 
-       // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
+       // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
        InitializeBoardPlugIns;
 
        EnabledCloseButton := True;
@@ -1124,6 +1127,12 @@ begin
                end;
        end;
 
+       // \83q\83X\83g\83\8a\83\8a\83X\83g(LoadHistory \82æ\82è\82à\90æ\82É\8ds\82¤\82±\82Æ)
+       FHistoryList := TList.Create;
+
+       // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
+       LoadHistory;
+
        //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
 //     FFavorite := TFavorite.Create(FavoriteTreeView);
        FavoriteDM.SetFavTreeView(FavoriteTreeView);
@@ -1330,9 +1339,6 @@ begin
        FControlThread.OnWorkEnd := WorkEnd;
 //     ProgressPanel.Width := FControlThread.MaxThreadCount * 12;
 
-       //\83q\83X\83g\83\8a\83\8a\83X\83g
-       FHistoryList := TList.Create;
-
        // \8di\8d\9e\8c\9f\8dõ\97\9a\97ð
        SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
 
@@ -1706,6 +1712,12 @@ begin
        except
        end;
 
+       //\83q\83X\83g\83\8a\83\8a\83X\83g\95Û\91
+       try
+               SaveHistory;
+       except
+       end;
+
        //\83q\83X\83g\83\8a\83\8a\83X\83g
        try
                FHistoryList.Free;
@@ -1841,7 +1853,7 @@ begin
        if BrowserTab.Tabs.Count >= 1 then
                DeleteTab(TThreadItem(BrowserTab.Tabs.Objects[0]));
        //\83q\83X\83g\83\8a\83\8a\83X\83g
-       FHistoryList.Clear;
+       //FHistoryList.Clear;
        //TreeView\83N\83\8a\83A\81iBBS2ch.Free\82Ì\8cã\82É\83N\83\8a\83A\82·\82é\82ÆXP\83X\83^\83C\83\8b\8e\9e\82É\83G\83\89\81[\8fo\82é\81j
        TreeView.Items.Clear;
 
@@ -3442,7 +3454,7 @@ begin
 
        if FTreeType = gttHistory then begin
                Node := TreeView.Items.Add(nil, ThreadItem.Title);
-               if Item.NewArrival then begin
+               if ThreadItem.NewArrival then begin
                        Node.ImageIndex := ITEM_ICON_THREADNEW1;
                        Node.SelectedIndex := ITEM_ICON_THREADNEW2;
                end else begin
@@ -3470,6 +3482,72 @@ begin
        FHistoryList.Clear;
 end;
 
+procedure TGikoForm.SaveHistory;
+var
+       i, bound        : Integer;
+       saveList        : TstringList;
+begin
+
+       saveList := TStringList.Create;
+       try
+               FHistoryList.Pack;
+               saveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');
+               saveList.Add('<address>');
+               bound := FHistoryList.Count - 1;
+               for i := 0 to bound do begin
+                       // title \82Í\8d¡\82Ì\82Æ\82±\82ë\8eg\82Á\82Ä\82¢\82È\82¢
+                       saveList.Add(
+                               '<history url="' + HttpEncode( TThreadItem( FHistoryList[ i ] ).URL ) + '"' +
+                               ' title="' + HttpEncode( TThreadItem( 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;
+       threadItem      : TThreadItem;
+begin
+
+       fileName := GikoSys.GetConfigDir + 'History.xml';
+
+       if FileExists( fileName ) then begin
+               try
+                       XMLDoc := LoadXMLDocument(FileName);
+                       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
+                                                               threadItem := BBSsFindThreadFromURL( s );
+                                                               if threadItem <> nil then
+                                                                       AddHistory( threadItem );
+                                                       end;
+                                               //end;
+                                       end;
+                               end;
+                       end;
+               except
+               end;
+       end;
+
+end;
+
 procedure TGikoForm.ShowBBSTree(
        inBBS : TBBS
 );