ギコナビ
Revision | 7b3a37b98cd1964059f9b2bad6af96fd05dbc0fb (tree) |
---|---|
Time | 2006-12-31 10:29:28 |
Author | h677 <h677> |
Commiter | h677 |
履歴を別クラス(THistoryList)に分離
@@ -19,14 +19,14 @@ uses | ||
19 | 19 | HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager, |
20 | 20 | ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection, |
21 | 21 | IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem, |
22 | - ShellAPI,Preview; | |
22 | + ShellAPI,Preview, HistoryList; | |
23 | 23 | |
24 | 24 | const |
25 | 25 | NGWORDNAME_PANEL = 3; |
26 | 26 | THREADSIZE_PANEL = 2; |
27 | 27 | |
28 | 28 | type |
29 | - TGikoTreeType = (gttNone, gtt2ch, gttHistory, gttFavorite); | |
29 | + | |
30 | 30 | TToolBarSettingSenderType = (tssNone, tssMain, tssList, tssBrowser); |
31 | 31 | TMinimizeType = (mtNone, mtMinimizing, mtMinimized); |
32 | 32 | TResizeType = (rtNone, rtResizing); |
@@ -569,7 +569,7 @@ type | ||
569 | 569 | FActiveList: TObject; |
570 | 570 | FActiveContent: TBrowserRecord; // |
571 | 571 | FActiveBBS : TBBS; |
572 | - FHistoryList: TList; //qXgXg | |
572 | + FHistoryList: THistoryList; //qXgXg | |
573 | 573 | FTreeType: TGikoTreeType; |
574 | 574 | FWorkCount: Integer; |
575 | 575 | FNameCookie: string; |
@@ -722,10 +722,6 @@ type | ||
722 | 722 | procedure SetListViewType(AViewType: TGikoViewType); overload; |
723 | 723 | procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload; |
724 | 724 | procedure PlaySound(SoundEventName: string); |
725 | - function AddHistory( FavItem: TFavoriteThreadItem ): Boolean; | |
726 | - procedure ClearHistory; | |
727 | - procedure SaveHistory; | |
728 | - procedure LoadHistory; | |
729 | 725 | procedure ShowBBSTree( inBBS : TBBS ); |
730 | 726 | procedure ShowBBSTreeOld( inBBS : TBBS ); |
731 | 727 | procedure ShowHistoryTree; |
@@ -1138,10 +1134,11 @@ begin | ||
1138 | 1134 | |
1139 | 1135 | |
1140 | 1136 | // qXgXg(LoadHistory æèàæÉs¤±Æ) |
1141 | - FHistoryList := TList.Create; | |
1137 | + FHistoryList := THistoryList.Create; | |
1142 | 1138 | |
1143 | 1139 | // ðÇÝÝ |
1144 | - LoadHistory; | |
1140 | + FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml', | |
1141 | + TreeView, FTreeType); | |
1145 | 1142 | |
1146 | 1143 | //¨CÉüèÇÝÝ |
1147 | 1144 | FavoriteDM.SetFavTreeView(FavoriteTreeView); |
@@ -1616,12 +1613,12 @@ begin | ||
1616 | 1613 | |
1617 | 1614 | //qXgXgÛ¶ |
1618 | 1615 | try |
1619 | - SaveHistory; | |
1616 | + FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml'); | |
1620 | 1617 | except |
1621 | 1618 | end; |
1622 | 1619 | try |
1623 | 1620 | try |
1624 | - ClearHistory; | |
1621 | + FHistoryList.Clear; | |
1625 | 1622 | except |
1626 | 1623 | end; |
1627 | 1624 | finally |
@@ -1767,8 +1764,8 @@ begin | ||
1767 | 1764 | |
1768 | 1765 | //ðÌÛ¶Æjü |
1769 | 1766 | try |
1770 | - SaveHistory; | |
1771 | - ClearHistory; | |
1767 | + FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml'); | |
1768 | + FHistoryList.Clear; | |
1772 | 1769 | except |
1773 | 1770 | end; |
1774 | 1771 |
@@ -1819,7 +1816,8 @@ begin | ||
1819 | 1816 | ShowBBSTree( BBSs[ 0 ] ); |
1820 | 1817 | |
1821 | 1818 | // ðÇÝÝ |
1822 | - LoadHistory; | |
1819 | + FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml', | |
1820 | + TreeView, FTreeType); | |
1823 | 1821 | |
1824 | 1822 | //¨CÉüèÇÝÝ |
1825 | 1823 | FavoriteDM.ReadFavorite; |
@@ -2539,7 +2537,7 @@ begin | ||
2539 | 2537 | FBrowsers.Move(BROWSER_COUNT - 1, 0); |
2540 | 2538 | end; |
2541 | 2539 | favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title ); |
2542 | - if not AddHistory( favItem ) then | |
2540 | + if not FHistoryList.AddHistory( favItem, TreeView, FTreeType ) then | |
2543 | 2541 | favItem.Free; |
2544 | 2542 | |
2545 | 2543 | for i := 0 to BrowserTab.Tabs.Count - 1 do begin |
@@ -3019,209 +3017,10 @@ begin | ||
3019 | 3017 | end; |
3020 | 3018 | end; |
3021 | 3019 | |
3022 | -function TGikoForm.AddHistory( favItem : TFavoriteThreadItem ): Boolean; | |
3023 | -var | |
3024 | - i: Integer; | |
3025 | - Item: TFavoriteThreadItem; | |
3026 | - Node: TTreeNode; | |
3027 | -begin | |
3028 | -// Result := False; | |
3029 | -// if (GetActiveContent = ThreadItem) and | |
3030 | -// (ThreadItem.Count <= ThreadItem.Kokomade) then | |
3031 | -// Exit; | |
3032 | -// if GetActiveContent = ThreadItem then | |
3033 | -// Exit; | |
3034 | - | |
3035 | - Result := True; | |
3036 | - if FTreeType = gttHistory then | |
3037 | - TreeView.Selected := nil; | |
3038 | - | |
3039 | - for i := 0 to FHistoryList.Count - 1 do begin | |
3040 | - if TObject(FHistoryList[i]) is TFavoriteThreadItem then begin | |
3041 | - Item := TFavoriteThreadItem(FHistoryList[i]); | |
3042 | - if Item.URL = favItem.URL then begin | |
3043 | -// SetContent(ThreadItem); | |
3044 | - FHistoryList.Move(i, 0); | |
3045 | - if FTreeType = gttHistory then | |
3046 | - if TreeView.Items.GetFirstNode <> TreeView.Items[ i ] then | |
3047 | - TreeView.Items[ i ].MoveTo( TreeView.Items.GetFirstNode, naInsert ); | |
3048 | - Result := false; | |
3049 | - Exit; | |
3050 | - end; | |
3051 | - end; | |
3052 | - end; | |
3053 | - | |
3054 | - if FHistoryList.Count > 0 then | |
3055 | - FHistoryList.Insert( 0, favItem ) | |
3056 | - else | |
3057 | - FHistoryList.Add( favItem ); | |
3058 | -// SetContent(ThreadItem); | |
3059 | -// while GikoSys.Setting.AddressHistoryCount < FHistoryList.Count do begin | |
3060 | - while GikoSys.Setting.MaxRecordCount < FHistoryList.Count do begin | |
3061 | - i := FHistoryList.Count - 1; | |
3062 | - TObject( FHistoryList.Items[ i ] ).Free; | |
3063 | - FHistoryList.Delete( i ); | |
3064 | - end; | |
3065 | - | |
3066 | - if FTreeType = gttHistory then begin | |
3067 | - Node := TreeView.Items.Add( nil, favItem.Title ); | |
3068 | - Node.MoveTo( TreeView.Items.GetFirstNode, naInsert ); | |
3069 | - { | |
3070 | - if favItem.NewArrival then begin | |
3071 | - Node.ImageIndex := ITEM_ICON_THREADNEW1; | |
3072 | - Node.SelectedIndex := ITEM_ICON_THREADNEW2; | |
3073 | - end else begin | |
3074 | - Node.ImageIndex := ITEM_ICON_THREADLOG1; | |
3075 | - Node.SelectedIndex := ITEM_ICON_THREADLOG2; | |
3076 | - end; | |
3077 | - } | |
3078 | - // ×𩯽ȢÌÅ NewArrival Ì`FbNðsíÈ¢ | |
3079 | - // ¦favItem.Item vpeBÍ dat ÌÇÝÝðKvÆ·é | |
3080 | - Node.ImageIndex := ITEM_ICON_THREADLOG1; | |
3081 | - Node.SelectedIndex := ITEM_ICON_THREADLOG2; | |
3082 | - Node.Data := favItem; | |
3083 | - //while GikoSys.Setting.AddressHistoryCount < TreeView.Items.Count do begin | |
3084 | - while GikoSys.Setting.MaxRecordCount < TreeView.Items.Count do begin | |
3085 | - i := TreeView.Items.Count - 1; | |
3086 | - TreeView.Items.Item[ i ].Delete; | |
3087 | - end; | |
3088 | - end; | |
3089 | -end; | |
3090 | - | |
3020 | +//ð©çí | |
3091 | 3021 | procedure TGikoForm.DeleteHistory( threadItem: TThreadItem ); |
3092 | -var | |
3093 | - i: Integer; | |
3094 | - node: TTreeNode; | |
3095 | -begin | |
3096 | - // LrlbgÉðª\¦³êÄ¢½çA | |
3097 | - // LrlbgàÌACeàí·éB | |
3098 | - if (FTreeType = gttHistory) then begin | |
3099 | - node := TreeView.Items.GetFirstNode; | |
3100 | - while (node <> nil) do begin | |
3101 | - if ( TFavoriteThreadItem(node.Data).Item = threadItem ) then begin | |
3102 | - TreeView.Items.Delete(node); | |
3103 | - TreeView.Refresh; | |
3104 | - node := nil; | |
3105 | - end else begin | |
3106 | - node := node.GetNext; | |
3107 | - end; | |
3108 | - end; | |
3109 | - end; | |
3110 | - for i := 0 to FHistoryList.Count - 1 do begin | |
3111 | - if threadItem = TFavoriteThreadItem( FHistoryList.Items[i] ).Item then begin | |
3112 | - TFavoriteThreadItem( FHistoryList.Items[ i ] ).Free; | |
3113 | - FHistoryList.Delete(i); | |
3114 | - FHistoryList.Capacity := FHistoryList.Count; | |
3115 | - Break; | |
3116 | - end; | |
3117 | - end; | |
3118 | -end; | |
3119 | - | |
3120 | -procedure TGikoForm.ClearHistory; | |
3121 | -var | |
3122 | - i : Integer; | |
3123 | 3022 | begin |
3124 | - //FHistoryList.Clear; | |
3125 | - | |
3126 | - try | |
3127 | - for i := FHistoryList.Count - 1 downto 0 do begin | |
3128 | - if TObject(FHistoryList[ i ]) is TFavoriteThreadItem then | |
3129 | - TFavoriteThreadItem(FHistoryList[ i ]).Free | |
3130 | - else if TObject(FHistoryList[ i ]) is TFavoriteBoardItem then | |
3131 | - TFavoriteBoardItem(FHistoryList[ i ]).Free; | |
3132 | - | |
3133 | - //FHistoryList.Delete(i); | |
3134 | - end; | |
3135 | - except | |
3136 | - end; | |
3137 | - | |
3138 | - FHistoryList.Clear; | |
3139 | - FHistoryList.Capacity := FHistoryList.Count; | |
3140 | - | |
3141 | -end; | |
3142 | - | |
3143 | -procedure TGikoForm.SaveHistory; | |
3144 | -var | |
3145 | - i, bound : Integer; | |
3146 | - saveList : TstringList; | |
3147 | -begin | |
3148 | - | |
3149 | - saveList := TStringList.Create; | |
3150 | - try | |
3151 | - FHistoryList.Pack; | |
3152 | - FHistoryList.Capacity := FHistoryList.Count; | |
3153 | - saveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>'); | |
3154 | - saveList.Add('<address>'); | |
3155 | - bound := FHistoryList.Count - 1; | |
3156 | - for i := bound downto 0 do begin | |
3157 | - // title Í¡ÌƱëgÁĢȢ | |
3158 | - saveList.Add( | |
3159 | - '<history url="' + HtmlEncode( TFavoriteThreadItem( FHistoryList[ i ] ).URL ) + '"' + | |
3160 | - ' title="' + HtmlEncode( MojuUtils.Sanitize(TFavoriteThreadItem( FHistoryList[ i ] ).Title )) + '"/>'); | |
3161 | - end; | |
3162 | - saveList.Add('</address>'); | |
3163 | - saveList.SaveToFile( GikoSys.GetConfigDir + 'History.xml' ); | |
3164 | - finally | |
3165 | - saveList.Free; | |
3166 | - end; | |
3167 | - | |
3168 | -end; | |
3169 | - | |
3170 | -procedure TGikoForm.LoadHistory; | |
3171 | -var | |
3172 | - i, bound : Integer; | |
3173 | - fileName : string; | |
3174 | - XMLDoc : IXMLDocument; | |
3175 | - XMLNode : IXMLNode; | |
3176 | - HistoryNode : IXMLNode; | |
3177 | - s : string; | |
3178 | - favItem : TFavoriteThreadItem; | |
3179 | -{$IFDEF DEBUG} | |
3180 | - st, rt : Cardinal; | |
3181 | -{$ENDIF} | |
3182 | -begin | |
3183 | -{$IFDEF DEBUG} | |
3184 | - st := GetTickCount; | |
3185 | -{$ENDIF} | |
3186 | - | |
3187 | - fileName := GikoSys.GetConfigDir + 'History.xml'; | |
3188 | - | |
3189 | - if FileExists( fileName ) then begin | |
3190 | - try | |
3191 | - XMLDoc := IXMLDocument.Create; | |
3192 | - //XMLDoc := LoadXMLDocument(FileName); | |
3193 | - LoadXMLDocument(FileName, XMLDoc); | |
3194 | - try | |
3195 | - XMLNode := XMLDoc.DocumentElement; | |
3196 | - | |
3197 | - if XMLNode.NodeName = 'address' then begin | |
3198 | - bound := XMLNode.ChildNodes.Count - 1; | |
3199 | - for i := 0 to bound do begin | |
3200 | - HistoryNode := XMLNode.ChildNodes[i]; | |
3201 | - if HistoryNode.NodeName = 'history' then begin | |
3202 | - //if FReadCount >= sl.Count then begin | |
3203 | - s := Trim(HistoryNode.Attributes['url']); | |
3204 | - if s <> '' then begin | |
3205 | - favItem := TFavoriteThreadItem.Create( | |
3206 | - s, MojuUtils.UnSanitize(HistoryNode.Attributes[ 'title' ]) ); | |
3207 | - if not AddHistory( favItem ) then | |
3208 | - favItem.Free; | |
3209 | - end; | |
3210 | - //end; | |
3211 | - end; | |
3212 | - end; | |
3213 | - end; | |
3214 | - finally | |
3215 | - XMLDoc.Free; | |
3216 | - end; | |
3217 | - except | |
3218 | - end; | |
3219 | - end; | |
3220 | -{$IFDEF DEBUG} | |
3221 | - rt := GetTickCount - st; | |
3222 | - Writeln('Runtime(Load Histroy) : ' + IntToStr(rt) + ' ms'); | |
3223 | -{$ENDIF} | |
3224 | - | |
3023 | + FHistoryList.DeleteHistory( threadItem, TreeView, TreeType ); | |
3225 | 3024 | end; |
3226 | 3025 | |
3227 | 3026 | procedure TGikoForm.ShowBBSTreeOld( |
@@ -5071,7 +4870,6 @@ begin | ||
5071 | 4870 | if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then |
5072 | 4871 | if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then |
5073 | 4872 | Exit; |
5074 | - ClearHistory; | |
5075 | 4873 | FHistoryList.Clear; |
5076 | 4874 | TreeView.Items.Clear; |
5077 | 4875 | end; |
@@ -12,7 +12,7 @@ uses | ||
12 | 12 | MSHTML_TLB, |
13 | 13 | {$IFEND} |
14 | 14 | ComCtrls, BrowserRecord, Graphics, Messages, Setting, Dialogs, |
15 | - ActiveX, MoveHistoryItem; | |
15 | + ActiveX, MoveHistoryItem, HistoryList; | |
16 | 16 | |
17 | 17 | const |
18 | 18 | CAPTION_NAME: string = 'MRir'; |
@@ -0,0 +1,227 @@ | ||
1 | +unit HistoryList; | |
2 | + | |
3 | +interface | |
4 | + | |
5 | +uses | |
6 | + Windows, Messages, SysUtils, Classes, Graphics, Controls, | |
7 | + BoardGroup, Favorite, ComCtrls, GikoXMLDoc; | |
8 | + | |
9 | +type | |
10 | + TGikoTreeType = (gttNone, gtt2ch, gttHistory, gttFavorite); | |
11 | + | |
12 | + THistoryList = class(TList) | |
13 | + public | |
14 | + function AddHistory( favItem : TFavoriteThreadItem; TreeView : TTreeView; | |
15 | + TreeType: TGikoTreeType): Boolean; | |
16 | + procedure DeleteHistory( threadItem: TThreadItem; TreeView : TTreeView; | |
17 | + TreeType: TGikoTreeType ); | |
18 | + procedure Clear; override; | |
19 | + procedure SaveToFile(const FileName: String); | |
20 | + procedure LoadFromFile(const FileName: String; | |
21 | + TreeView : TTreeView; TreeType: TGikoTreeType); | |
22 | + end; | |
23 | + | |
24 | + | |
25 | +implementation | |
26 | + | |
27 | +uses | |
28 | + Giko, GikoSystem, Setting, YofUtils, MojuUtils; | |
29 | + | |
30 | +const | |
31 | + ITEM_ICON_THREADLOG1 = 6; //XACRiO èj | |
32 | + ITEM_ICON_THREADLOG2 = 7; //XACRiO èj | |
33 | + | |
34 | + | |
35 | +function THistoryList.AddHistory( | |
36 | + favItem : TFavoriteThreadItem; TreeView : TTreeView; | |
37 | + TreeType: TGikoTreeType ): Boolean; | |
38 | +var | |
39 | + i: Integer; | |
40 | + Item: TFavoriteThreadItem; | |
41 | + Node: TTreeNode; | |
42 | +begin | |
43 | + Result := True; | |
44 | + if TreeType = gttHistory then | |
45 | + TreeView.Selected := nil; | |
46 | + | |
47 | + for i := 0 to Self.Count - 1 do begin | |
48 | + if TObject(Self[i]) is TFavoriteThreadItem then begin | |
49 | + Item := TFavoriteThreadItem(Self[i]); | |
50 | + if Item.URL = favItem.URL then begin | |
51 | + Self.Move(i, 0); | |
52 | + if TreeType = gttHistory then | |
53 | + if TreeView.Items.GetFirstNode <> TreeView.Items[ i ] then | |
54 | + TreeView.Items[ i ].MoveTo( TreeView.Items.GetFirstNode, naInsert ); | |
55 | + Result := false; | |
56 | + Exit; | |
57 | + end; | |
58 | + end; | |
59 | + end; | |
60 | + | |
61 | + if Self.Count > 0 then | |
62 | + Self.Insert( 0, favItem ) | |
63 | + else | |
64 | + Self.Add( favItem ); | |
65 | + | |
66 | + while GikoSys.Setting.MaxRecordCount < Self.Count do begin | |
67 | + i := Self.Count - 1; | |
68 | + TObject( Self.Items[ i ] ).Free; | |
69 | + Self.Delete( i ); | |
70 | + end; | |
71 | + | |
72 | + if TreeType = gttHistory then begin | |
73 | + Node := TreeView.Items.Add( nil, favItem.Title ); | |
74 | + Node.MoveTo( TreeView.Items.GetFirstNode, naInsert ); | |
75 | + { | |
76 | + if favItem.NewArrival then begin | |
77 | + Node.ImageIndex := ITEM_ICON_THREADNEW1; | |
78 | + Node.SelectedIndex := ITEM_ICON_THREADNEW2; | |
79 | + end else begin | |
80 | + Node.ImageIndex := ITEM_ICON_THREADLOG1; | |
81 | + Node.SelectedIndex := ITEM_ICON_THREADLOG2; | |
82 | + end; | |
83 | + } | |
84 | + // ×𩯽ȢÌÅ NewArrival Ì`FbNðsíÈ¢ | |
85 | + // ¦favItem.Item vpeBÍ dat ÌÇÝÝðKvÆ·é | |
86 | + Node.ImageIndex := ITEM_ICON_THREADLOG1; | |
87 | + Node.SelectedIndex := ITEM_ICON_THREADLOG2; | |
88 | + Node.Data := favItem; | |
89 | + //while GikoSys.Setting.AddressHistoryCount < TreeView.Items.Count do begin | |
90 | + while GikoSys.Setting.MaxRecordCount < TreeView.Items.Count do begin | |
91 | + i := TreeView.Items.Count - 1; | |
92 | + TreeView.Items.Item[ i ].Delete; | |
93 | + end; | |
94 | + end; | |
95 | +end; | |
96 | + | |
97 | +procedure THistoryList.DeleteHistory( threadItem: TThreadItem; | |
98 | + TreeView : TTreeView; TreeType: TGikoTreeType ); | |
99 | +var | |
100 | + i: Integer; | |
101 | + node: TTreeNode; | |
102 | +begin | |
103 | + // LrlbgÉðª\¦³êÄ¢½çA | |
104 | + // LrlbgàÌACeàí·éB | |
105 | + if (TreeType = gttHistory) then begin | |
106 | + node := TreeView.Items.GetFirstNode; | |
107 | + while (node <> nil) do begin | |
108 | + if ( TFavoriteThreadItem(node.Data).Item = threadItem ) then begin | |
109 | + TreeView.Items.Delete(node); | |
110 | + TreeView.Refresh; | |
111 | + node := nil; | |
112 | + end else begin | |
113 | + node := node.GetNext; | |
114 | + end; | |
115 | + end; | |
116 | + end; | |
117 | + for i := 0 to Self.Count - 1 do begin | |
118 | + if threadItem = TFavoriteThreadItem( Self.Items[i] ).Item then begin | |
119 | + TFavoriteThreadItem( Self.Items[ i ] ).Free; | |
120 | + Self.Delete(i); | |
121 | + Self.Capacity := Self.Count; | |
122 | + Break; | |
123 | + end; | |
124 | + end; | |
125 | +end; | |
126 | + | |
127 | +procedure THistoryList.Clear; | |
128 | +var | |
129 | + i : Integer; | |
130 | +begin | |
131 | + try | |
132 | + for i := Self.Count - 1 downto 0 do begin | |
133 | + if TObject(Self[ i ]) is TFavoriteThreadItem then | |
134 | + TFavoriteThreadItem(Self[ i ]).Free | |
135 | + else if TObject(Self[ i ]) is TFavoriteBoardItem then | |
136 | + TFavoriteBoardItem(Self[ i ]).Free; | |
137 | + end; | |
138 | + except | |
139 | + end; | |
140 | + | |
141 | + inherited Clear; | |
142 | + Self.Capacity := Self.Count; | |
143 | + | |
144 | +end; | |
145 | + | |
146 | +procedure THistoryList.SaveToFile(const FileName: String); | |
147 | +var | |
148 | + i, bound : Integer; | |
149 | + saveList : TstringList; | |
150 | +begin | |
151 | + | |
152 | + saveList := TStringList.Create; | |
153 | + try | |
154 | + Self.Pack; | |
155 | + Self.Capacity := Self.Count; | |
156 | + saveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>'); | |
157 | + saveList.Add('<address>'); | |
158 | + bound := Self.Count - 1; | |
159 | + for i := bound downto 0 do begin | |
160 | + // title Í¡ÌƱëgÁĢȢ | |
161 | + saveList.Add( | |
162 | + '<history url="' + HtmlEncode( TFavoriteThreadItem( Self[ i ] ).URL ) + '"' + | |
163 | + ' title="' + HtmlEncode( MojuUtils.Sanitize(TFavoriteThreadItem( Self[ i ] ).Title )) + '"/>'); | |
164 | + end; | |
165 | + saveList.Add('</address>'); | |
166 | + saveList.SaveToFile( FileName ); | |
167 | + finally | |
168 | + saveList.Free; | |
169 | + end; | |
170 | + | |
171 | +end; | |
172 | + | |
173 | +procedure THistoryList.LoadFromFile(const FileName: String; | |
174 | + TreeView : TTreeView; TreeType: TGikoTreeType); | |
175 | +var | |
176 | + i, bound : Integer; | |
177 | + XMLDoc : IXMLDocument; | |
178 | + XMLNode : IXMLNode; | |
179 | + HistoryNode : IXMLNode; | |
180 | + s : string; | |
181 | + favItem : TFavoriteThreadItem; | |
182 | +{$IFDEF DEBUG} | |
183 | + st, rt : Cardinal; | |
184 | +{$ENDIF} | |
185 | +begin | |
186 | +{$IFDEF DEBUG} | |
187 | + st := GetTickCount; | |
188 | +{$ENDIF} | |
189 | + if FileExists( FileName ) then begin | |
190 | + try | |
191 | + XMLDoc := IXMLDocument.Create; | |
192 | + //XMLDoc := LoadXMLDocument(FileName); | |
193 | + LoadXMLDocument(FileName, XMLDoc); | |
194 | + try | |
195 | + XMLNode := XMLDoc.DocumentElement; | |
196 | + | |
197 | + if XMLNode.NodeName = 'address' then begin | |
198 | + bound := XMLNode.ChildNodes.Count - 1; | |
199 | + for i := 0 to bound do begin | |
200 | + HistoryNode := XMLNode.ChildNodes[i]; | |
201 | + if HistoryNode.NodeName = 'history' then begin | |
202 | + //if FReadCount >= sl.Count then begin | |
203 | + s := Trim(HistoryNode.Attributes['url']); | |
204 | + if s <> '' then begin | |
205 | + favItem := TFavoriteThreadItem.Create( | |
206 | + s, MojuUtils.UnSanitize(HistoryNode.Attributes[ 'title' ]) ); | |
207 | + if not AddHistory( favItem, TreeView, TreeType ) then | |
208 | + favItem.Free; | |
209 | + end; | |
210 | + //end; | |
211 | + end; | |
212 | + end; | |
213 | + end; | |
214 | + finally | |
215 | + XMLDoc.Free; | |
216 | + end; | |
217 | + except | |
218 | + end; | |
219 | + end; | |
220 | +{$IFDEF DEBUG} | |
221 | + rt := GetTickCount - st; | |
222 | + Writeln('Runtime(Load Histroy) : ' + IntToStr(rt) + ' ms'); | |
223 | +{$ENDIF} | |
224 | + | |
225 | +end; | |
226 | + | |
227 | +end. |
@@ -74,7 +74,8 @@ uses | ||
74 | 74 | InputAssistDataModule in 'InputAssistDataModule.pas' {InputAssistDM: TDataModule}, |
75 | 75 | DefaultFileManager in 'DefaultFileManager.pas', |
76 | 76 | MoveHistoryItem in 'MoveHistoryItem.pas', |
77 | - SambaTimer in 'SambaTimer.pas'; | |
77 | + SambaTimer in 'SambaTimer.pas', | |
78 | + HistoryList in 'HistoryList.pas'; | |
78 | 79 | |
79 | 80 | {$R *.RES} |
80 | 81 | {$R gikoResource.res} |