ギコナビ
修订版 | 44f7b19497eba1b4a4ab6f5e98e6cafb72806c3b (tree) |
---|---|
时间 | 2007-02-04 23:12:52 |
作者 | h677 <h677> |
Commiter | h677 |
NGワードの拡張作業
@@ -1311,6 +1311,12 @@ object GikoDM: TGikoDM | ||
1311 | 1311 | Hint = #31227#36578#12375#12390#12356#12427#26495#12398'URL'#12434#26908#32034#12377#12427 |
1312 | 1312 | OnExecute = NewBoardSearchActionExecute |
1313 | 1313 | end |
1314 | + object NGWordEditFormAction: TAction | |
1315 | + Category = 'NGword' | |
1316 | + Caption = 'NG'#12527#12540#12489#32232#38598#12501#12457#12540#12512 | |
1317 | + Hint = 'NG'#12527#12540#12489#32232#38598#12501#12457#12540#12512#12458#12540#12503#12531 | |
1318 | + OnExecute = NGWordEditFormActionExecute | |
1319 | + end | |
1314 | 1320 | end |
1315 | 1321 | object ToobarImageList: TImageList |
1316 | 1322 | Left = 44 |
@@ -231,6 +231,7 @@ type | ||
231 | 231 | NewImageLinkToClipBoardAction: TAction; |
232 | 232 | SetForcusForAddresBarAction: TAction; |
233 | 233 | NewBoardSearchAction: TAction; |
234 | + NGWordEditFormAction: TAction; | |
234 | 235 | procedure EditNGActionExecute(Sender: TObject); |
235 | 236 | procedure ReloadActionExecute(Sender: TObject); |
236 | 237 | procedure GoFowardActionExecute(Sender: TObject); |
@@ -434,6 +435,7 @@ type | ||
434 | 435 | procedure AllImageLinkToClipbordActionExecute(Sender: TObject); |
435 | 436 | procedure SetForcusForAddresBarActionExecute(Sender: TObject); |
436 | 437 | procedure NewBoardSearchActionExecute(Sender: TObject); |
438 | + procedure NGWordEditFormActionExecute(Sender: TObject); | |
437 | 439 | private |
438 | 440 | { Private é¾ } |
439 | 441 | procedure ClearResFilter; |
@@ -486,7 +488,7 @@ uses | ||
486 | 488 | GikoBayesian, About, ShellAPI, |
487 | 489 | RoundName, RoundData, Menus, ListViewUtils, |
488 | 490 | ThreadControl, GikoMessage, InputAssist, |
489 | - DefaultFileManager, Forms, NewBoardURL; | |
491 | + DefaultFileManager, Forms, NewBoardURL, NGWordEdit; | |
490 | 492 | |
491 | 493 | const |
492 | 494 | MSG_ERROR : string = 'G['; |
@@ -4336,5 +4338,17 @@ begin | ||
4336 | 4338 | end; |
4337 | 4339 | end; |
4338 | 4340 | |
4341 | +procedure TGikoDM.NGWordEditFormActionExecute(Sender: TObject); | |
4342 | +var | |
4343 | + form: TNGWordEditForm; | |
4344 | +begin | |
4345 | + form := TNGWordEditForm.Create(Self); | |
4346 | + try | |
4347 | + form.ShowModal; | |
4348 | + finally | |
4349 | + form.Release; | |
4350 | + end; | |
4351 | +end; | |
4352 | + | |
4339 | 4353 | end. |
4340 | 4354 |
@@ -262,7 +262,7 @@ const | ||
262 | 262 | ZERO_DATE: Integer = 25569; |
263 | 263 | BETA_VERSION_NAME_E = 'beta'; |
264 | 264 | BETA_VERSION_NAME_J = 'ÊÞÀ'; |
265 | - BETA_VERSION = 54; | |
265 | + BETA_VERSION = 55; | |
266 | 266 | BETA_VERSION_BUILD = ''; //!< debugÅÈÇ |
267 | 267 | APP_NAME = 'gikoNavi'; |
268 | 268 | BE_PHP_URL = 'http://be.2ch.net/test/p.php?i='; |
@@ -0,0 +1,209 @@ | ||
1 | +object NGWordEditForm: TNGWordEditForm | |
2 | + Left = 278 | |
3 | + Top = 178 | |
4 | + Width = 490 | |
5 | + Height = 401 | |
6 | + Caption = 'NGWordEditForm' | |
7 | + Color = clBtnFace | |
8 | + Font.Charset = SHIFTJIS_CHARSET | |
9 | + Font.Color = clWindowText | |
10 | + Font.Height = -12 | |
11 | + Font.Name = #65325#65331' '#65328#12468#12471#12483#12463 | |
12 | + Font.Style = [] | |
13 | + Menu = MainMenu1 | |
14 | + OldCreateOrder = False | |
15 | + OnCreate = FormCreate | |
16 | + OnDestroy = FormDestroy | |
17 | + PixelsPerInch = 96 | |
18 | + TextHeight = 12 | |
19 | + object Panel1: TPanel | |
20 | + Left = 0 | |
21 | + Top = 0 | |
22 | + Width = 482 | |
23 | + Height = 153 | |
24 | + Align = alTop | |
25 | + BevelOuter = bvNone | |
26 | + Caption = 'Panel1' | |
27 | + TabOrder = 0 | |
28 | + object Panel3: TPanel | |
29 | + Left = 359 | |
30 | + Top = 0 | |
31 | + Width = 123 | |
32 | + Height = 153 | |
33 | + Align = alRight | |
34 | + BevelOuter = bvLowered | |
35 | + Caption = 'Panel3' | |
36 | + TabOrder = 0 | |
37 | + object AddButton: TButton | |
38 | + Left = 24 | |
39 | + Top = 16 | |
40 | + Width = 75 | |
41 | + Height = 25 | |
42 | + Caption = #36861#21152 | |
43 | + TabOrder = 0 | |
44 | + OnClick = AddButtonClick | |
45 | + end | |
46 | + object DeleteButton: TButton | |
47 | + Left = 24 | |
48 | + Top = 40 | |
49 | + Width = 75 | |
50 | + Height = 25 | |
51 | + Caption = #21066#38500 | |
52 | + TabOrder = 1 | |
53 | + OnClick = DeleteButtonClick | |
54 | + end | |
55 | + object Button3: TButton | |
56 | + Left = 24 | |
57 | + Top = 80 | |
58 | + Width = 75 | |
59 | + Height = 25 | |
60 | + Caption = 'Button3' | |
61 | + TabOrder = 2 | |
62 | + end | |
63 | + object Button4: TButton | |
64 | + Left = 24 | |
65 | + Top = 104 | |
66 | + Width = 75 | |
67 | + Height = 25 | |
68 | + Caption = 'Button4' | |
69 | + TabOrder = 3 | |
70 | + end | |
71 | + end | |
72 | + object GikoListView1: TGikoListView | |
73 | + Left = 0 | |
74 | + Top = 0 | |
75 | + Width = 359 | |
76 | + Height = 153 | |
77 | + Align = alClient | |
78 | + Checkboxes = True | |
79 | + Columns = <> | |
80 | + GridLines = True | |
81 | + ReadOnly = True | |
82 | + RowSelect = True | |
83 | + TabOrder = 1 | |
84 | + ViewStyle = vsReport | |
85 | + OnSelectItem = GikoListView1SelectItem | |
86 | + end | |
87 | + end | |
88 | + object Panel2: TPanel | |
89 | + Left = 0 | |
90 | + Top = 153 | |
91 | + Width = 482 | |
92 | + Height = 202 | |
93 | + Align = alClient | |
94 | + BevelOuter = bvNone | |
95 | + Caption = 'Panel2' | |
96 | + TabOrder = 1 | |
97 | + object Panel4: TPanel | |
98 | + Left = 0 | |
99 | + Top = 0 | |
100 | + Width = 482 | |
101 | + Height = 41 | |
102 | + Align = alTop | |
103 | + BevelOuter = bvNone | |
104 | + TabOrder = 0 | |
105 | + object Label1: TLabel | |
106 | + Left = 16 | |
107 | + Top = 8 | |
108 | + Width = 48 | |
109 | + Height = 12 | |
110 | + Caption = #36969#21512#22580#25152 | |
111 | + end | |
112 | + object Label2: TLabel | |
113 | + Left = 237 | |
114 | + Top = 11 | |
115 | + Width = 47 | |
116 | + Height = 12 | |
117 | + Caption = 'NG'#12527#12540#12489 | |
118 | + end | |
119 | + object ComboBox1: TComboBox | |
120 | + Left = 80 | |
121 | + Top = 8 | |
122 | + Width = 145 | |
123 | + Height = 20 | |
124 | + ItemHeight = 12 | |
125 | + ItemIndex = 0 | |
126 | + TabOrder = 0 | |
127 | + Text = #20840#12390 | |
128 | + Items.Strings = ( | |
129 | + #20840#12390 | |
130 | + #21517#21069#27396 | |
131 | + #12513#12540#12523#27396 | |
132 | + #26085#20184#12539'ID' | |
133 | + #26412#25991) | |
134 | + end | |
135 | + object NGWordEdit: TEdit | |
136 | + Left = 296 | |
137 | + Top = 8 | |
138 | + Width = 161 | |
139 | + Height = 20 | |
140 | + TabOrder = 1 | |
141 | + Text = 'NGWordEdit' | |
142 | + end | |
143 | + end | |
144 | + object Panel5: TPanel | |
145 | + Left = 359 | |
146 | + Top = 41 | |
147 | + Width = 123 | |
148 | + Height = 161 | |
149 | + Align = alRight | |
150 | + BevelOuter = bvLowered | |
151 | + Caption = 'Panel5' | |
152 | + TabOrder = 1 | |
153 | + object ModifiedNGButton: TButton | |
154 | + Left = 24 | |
155 | + Top = 65 | |
156 | + Width = 75 | |
157 | + Height = 25 | |
158 | + Caption = #22793#26356 | |
159 | + TabOrder = 0 | |
160 | + end | |
161 | + object AddNGButton: TButton | |
162 | + Left = 24 | |
163 | + Top = 16 | |
164 | + Width = 75 | |
165 | + Height = 25 | |
166 | + Caption = #36861#21152 | |
167 | + TabOrder = 1 | |
168 | + OnClick = AddNGButtonClick | |
169 | + end | |
170 | + object DeleteNGButton: TButton | |
171 | + Left = 24 | |
172 | + Top = 41 | |
173 | + Width = 75 | |
174 | + Height = 25 | |
175 | + Caption = #21066#38500 | |
176 | + TabOrder = 2 | |
177 | + OnClick = DeleteNGButtonClick | |
178 | + end | |
179 | + end | |
180 | + object GikoListView2: TGikoListView | |
181 | + Left = 0 | |
182 | + Top = 41 | |
183 | + Width = 359 | |
184 | + Height = 161 | |
185 | + Align = alClient | |
186 | + Columns = <> | |
187 | + GridLines = True | |
188 | + ReadOnly = True | |
189 | + RowSelect = True | |
190 | + TabOrder = 2 | |
191 | + ViewStyle = vsReport | |
192 | + end | |
193 | + end | |
194 | + object MainMenu1: TMainMenu | |
195 | + Left = 376 | |
196 | + Top = 48 | |
197 | + object File1: TMenuItem | |
198 | + Caption = 'File' | |
199 | + object Load1: TMenuItem | |
200 | + Caption = 'Load' | |
201 | + OnClick = Load1Click | |
202 | + end | |
203 | + object Save1: TMenuItem | |
204 | + Caption = 'Save' | |
205 | + OnClick = Save1Click | |
206 | + end | |
207 | + end | |
208 | + end | |
209 | +end |
@@ -0,0 +1,232 @@ | ||
1 | +unit NGWordEdit; | |
2 | + | |
3 | +interface | |
4 | + | |
5 | +uses | |
6 | + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
7 | + Dialogs, ExtCtrls, StdCtrls, ComCtrls, GikoListView, Menus, GikoXMLDoc, | |
8 | + NGWordUnit; | |
9 | + | |
10 | +type | |
11 | + TNGWordEditForm = class(TForm) | |
12 | + Panel1: TPanel; | |
13 | + Panel2: TPanel; | |
14 | + Panel3: TPanel; | |
15 | + AddButton: TButton; | |
16 | + DeleteButton: TButton; | |
17 | + Button3: TButton; | |
18 | + Button4: TButton; | |
19 | + Panel4: TPanel; | |
20 | + Panel5: TPanel; | |
21 | + GikoListView2: TGikoListView; | |
22 | + GikoListView1: TGikoListView; | |
23 | + ComboBox1: TComboBox; | |
24 | + Label1: TLabel; | |
25 | + NGWordEdit: TEdit; | |
26 | + Label2: TLabel; | |
27 | + ModifiedNGButton: TButton; | |
28 | + AddNGButton: TButton; | |
29 | + DeleteNGButton: TButton; | |
30 | + MainMenu1: TMainMenu; | |
31 | + File1: TMenuItem; | |
32 | + Load1: TMenuItem; | |
33 | + Save1: TMenuItem; | |
34 | + procedure Load1Click(Sender: TObject); | |
35 | + procedure Save1Click(Sender: TObject); | |
36 | + procedure FormDestroy(Sender: TObject); | |
37 | + procedure FormCreate(Sender: TObject); | |
38 | + procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem; | |
39 | + Selected: Boolean); | |
40 | + procedure AddNGButtonClick(Sender: TObject); | |
41 | + procedure DeleteNGButtonClick(Sender: TObject); | |
42 | + procedure AddButtonClick(Sender: TObject); | |
43 | + procedure DeleteButtonClick(Sender: TObject); | |
44 | + private | |
45 | + { Private é¾ } | |
46 | + FNGWordList : TNGWordList; | |
47 | + function AddNGWord(ngWord: TNGWords): TListItem; | |
48 | + procedure AddWord(word: TNGWord); | |
49 | + public | |
50 | + { Public é¾ } | |
51 | + end; | |
52 | + | |
53 | +var | |
54 | + NGWordEditForm: TNGWordEditForm; | |
55 | + | |
56 | +implementation | |
57 | + | |
58 | +uses | |
59 | + GikoSystem; | |
60 | +{$R *.dfm} | |
61 | + | |
62 | +procedure TNGWordEditForm.Load1Click(Sender: TObject); | |
63 | +var | |
64 | + fname : String; | |
65 | + i: Integer; | |
66 | +begin | |
67 | + fname := GikoSys.GetAppDir + 'ngwords.xml'; | |
68 | + if (FNGWordList <> nil) then begin | |
69 | + FNGWordList.Free; | |
70 | + end else begin | |
71 | + FNGWordList := TNGWordList.Create; | |
72 | + end; | |
73 | + FNGWordList.LoadFromFile(fname); | |
74 | + GikoListView1.Items.Clear; | |
75 | + for i :=0 to FNGWordList.Count - 1 do begin | |
76 | + AddNGWord(TNGWords(FNGWordList.Items[i])); | |
77 | + end; | |
78 | +end; | |
79 | +function TNGWordEditForm.AddNGWord(ngWord: TNGWords): TListItem; | |
80 | +begin | |
81 | + Result := GikoListView1.Items.Add; | |
82 | + Result.ImageIndex := -1; | |
83 | + Result.Caption := ''; | |
84 | + Result.SubItems.Clear; | |
85 | + Result.SubItems.Add(ngWord.ToString); | |
86 | + Result.Data := ngWord; | |
87 | +end; | |
88 | + | |
89 | +procedure TNGWordEditForm.Save1Click(Sender: TObject); | |
90 | +begin | |
91 | + if (FNGWordList <> nil) then begin | |
92 | + FNGWordList.SaveToFrile(GikoSys.GetAppDir + 'ngwords2.xml'); | |
93 | + end; | |
94 | +end; | |
95 | + | |
96 | +procedure TNGWordEditForm.FormDestroy(Sender: TObject); | |
97 | +begin | |
98 | + if (FNGWordList <> nil) then begin | |
99 | + FreeAndNil(FNGWordList); | |
100 | + end; | |
101 | +end; | |
102 | + | |
103 | +procedure TNGWordEditForm.FormCreate(Sender: TObject); | |
104 | +var | |
105 | + column1,column2: TListColumn; | |
106 | +begin | |
107 | + GikoListView1.Columns.BeginUpdate; | |
108 | + column1 := GikoListView1.Columns.Add; | |
109 | + column1.ImageIndex := -1; | |
110 | + column1.Caption := '§¾'; | |
111 | + column1.DisplayName := '§¾'; | |
112 | + column1.Width := 40; | |
113 | + column1 := GikoListView1.Columns.Add; | |
114 | + column1.ImageIndex := -1; | |
115 | + column1.Caption := 'NG[h'; | |
116 | + column1.DisplayName := 'NG[h'; | |
117 | + column1.Width := 250; | |
118 | + GikoListView1.Columns.EndUpdate; | |
119 | + | |
120 | + | |
121 | + GikoListView2.Columns.BeginUpdate; | |
122 | + column2 := GikoListView2.Columns.Add; | |
123 | + column2.ImageIndex := -1; | |
124 | + column2.Caption := 'Kê'; | |
125 | + column2.DisplayName := 'Kê'; | |
126 | + column2.Width := 100; | |
127 | + column2 := GikoListView2.Columns.Add; | |
128 | + column2.ImageIndex := -1; | |
129 | + column2.Caption := '[h'; | |
130 | + column2.DisplayName := '[h'; | |
131 | + column2.Width := 190; | |
132 | + GikoListView2.Columns.EndUpdate; | |
133 | + | |
134 | +end; | |
135 | +// ãXgIðCxg | |
136 | +procedure TNGWordEditForm.GikoListView1SelectItem(Sender: TObject; | |
137 | + Item: TListItem; Selected: Boolean); | |
138 | +var | |
139 | + ngWord : TNGWords; | |
140 | + i: Integer; | |
141 | +begin | |
142 | + if (Item <> nil) and (Item.Data <> nil) then begin | |
143 | + ngWord := TNGWords(item.Data); | |
144 | + GikoListView2.items.Clear; | |
145 | + for i := 0 to ngWord.Count - 1 do begin | |
146 | + AddWord( TNGWord(ngWord.Items[i]) ); | |
147 | + end; | |
148 | + end; | |
149 | +end; | |
150 | +// ºXgÇÁ\bh | |
151 | +procedure TNGWordEditForm.AddWord(word: TNGWord); | |
152 | +var | |
153 | + litem: TListItem; | |
154 | +begin | |
155 | + litem := GikoListView2.Items.Add; | |
156 | + litem.ImageIndex := -1; | |
157 | + case Integer(word.NGType) of | |
158 | + Integer(gntAll): litem.Caption := 'S'; | |
159 | + Integer(gntName): litem.Caption := '¼O'; | |
160 | + Integer(gntMail): litem.Caption := '['; | |
161 | + Integer(gntDateId):litem.Caption := 'útID'; | |
162 | + Integer(gntBody): litem.Caption := '{¶'; | |
163 | + end; | |
164 | + litem.SubItems.Clear; | |
165 | + litem.SubItems.Add(word.Word); | |
166 | + litem.Data := word; | |
167 | +end; | |
168 | +//! NG[hÇÁ{^ | |
169 | +procedure TNGWordEditForm.AddNGButtonClick(Sender: TObject); | |
170 | +var | |
171 | + litem: TListItem; | |
172 | + word: TNGWord; | |
173 | +begin | |
174 | + // »ÝIð³êÄ¢ésðæ¾·é | |
175 | + litem := GikoListView1.Selected; | |
176 | + if (litem <> nil) then begin | |
177 | + if NGWordEdit.Text <> '' then begin | |
178 | + word := TNGWord.Create; | |
179 | + word.NGType := TGikoNGType(ComboBox1.ItemIndex); | |
180 | + word.Word := NGWordEdit.Text; | |
181 | + TNGWords(litem.Data).Add(word); | |
182 | + AddWord(word); | |
183 | + litem.SubItems.Clear; | |
184 | + litem.SubItems.Add(TNGWords(litem.Data).ToString); | |
185 | + end else begin | |
186 | + ShowMessage('NG[hÍóÅo^ūܹñ'); | |
187 | + end; | |
188 | + end; | |
189 | +end; | |
190 | +//! NG[hí{^ | |
191 | +procedure TNGWordEditForm.DeleteNGButtonClick(Sender: TObject); | |
192 | +var | |
193 | + litem, litem2: TListItem; | |
194 | +begin | |
195 | + // »ÝIð³êÄ¢ésðæ¾·é | |
196 | + litem := GikoListView1.Selected; | |
197 | + if (litem <> nil) then begin | |
198 | + litem2 := GikoListView2.Selected; | |
199 | + if litem2 <> nil then begin | |
200 | + TNGWords(litem.Data).Delete(TNGWord(litem2.Data)); | |
201 | + litem.Caption := TNGWords(litem.Data).ToString; | |
202 | + end; | |
203 | + GikoListView2.DeleteSelected; | |
204 | + end; | |
205 | +end; | |
206 | +//! | |
207 | +procedure TNGWordEditForm.AddButtonClick(Sender: TObject); | |
208 | +var | |
209 | + ngWords: TNGWords; | |
210 | +begin | |
211 | + if (FNGWordList <> nil) then begin | |
212 | + ngWords := TNGWords.Create; | |
213 | + FNGWordList.Add(ngWords); | |
214 | + GikoListView1.Selected := AddNGWord(ngWords); | |
215 | + GikoListView1.SetFocus; | |
216 | + end; | |
217 | +end; | |
218 | +//! | |
219 | +procedure TNGWordEditForm.DeleteButtonClick(Sender: TObject); | |
220 | +var | |
221 | + litem: TListItem; | |
222 | +begin | |
223 | + // »ÝIð³êÄ¢ésðæ¾·é | |
224 | + litem := GikoListView1.Selected; | |
225 | + if (litem <> nil) and (FNGWordList <> nil) then begin | |
226 | + FNGWordList.Delte( TNGWords(litem.Data)); | |
227 | + GikoListView1.DeleteSelected; | |
228 | + end; | |
229 | +end; | |
230 | + | |
231 | + | |
232 | +end. |
@@ -0,0 +1,257 @@ | ||
1 | +unit NGWordUnit; | |
2 | + | |
3 | +interface | |
4 | +uses | |
5 | + Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils, | |
6 | + GikoXMLDoc; | |
7 | + | |
8 | +type | |
9 | + //XgÌ\¦ACeIð | |
10 | + TGikoNGType = (gntAll, gntName, gntMail, gntDateId, gntBody); | |
11 | + | |
12 | + {\ | |
13 | + NG[hNX | |
14 | + } | |
15 | + TNGWord = class( TObject ) | |
16 | + private | |
17 | + FRank : Integer; | |
18 | + FNGType : TGikoNGType; | |
19 | + FWord : String; | |
20 | + public | |
21 | + procedure ReadXMLElement(element :IXMLNode); | |
22 | + function ToXMLString(): String; | |
23 | + property Rank : Integer read FRank write FRank; | |
24 | + property NGType : TGikoNGType read FNGType write FNGType; | |
25 | + property Word : String read FWord write FWord; | |
26 | + end; | |
27 | + | |
28 | + {\ | |
29 | + NG[hWNX | |
30 | + } | |
31 | + TNGWords = class( TList ) | |
32 | + private | |
33 | + FRank : Integer; | |
34 | + FInvisible: Boolean; | |
35 | + public | |
36 | + constructor Create; | |
37 | + procedure Free; | |
38 | + property Rank : Integer read FRank write FRank; | |
39 | + property Invisible : Boolean read FInvisible write FInvisible; | |
40 | + function ReadXMLElement(element :IXMLNode): Boolean; | |
41 | + function ToXMLString(): String; | |
42 | + function ToString(): String; | |
43 | + procedure Delete(word: TNGWord); overload; | |
44 | + end; | |
45 | + | |
46 | + {\ | |
47 | + NG[hÇNX | |
48 | + } | |
49 | + TNGWordList = class( TList ) | |
50 | + private | |
51 | + public | |
52 | + procedure Free; | |
53 | + procedure LoadFromFile(fileName: String); | |
54 | + procedure SaveToFrile(fileName: String); | |
55 | + procedure Delte(NGWords: TNGWords); overload; | |
56 | + end; | |
57 | + | |
58 | + function CompareRank(Item1, Item2: Pointer): Integer; | |
59 | + | |
60 | +implementation | |
61 | + | |
62 | +uses | |
63 | + MojuUtils, Sort; | |
64 | + | |
65 | +function CompareRank(Item1, Item2: Pointer): Integer; | |
66 | +begin | |
67 | + if TObject(item1) is TNGWords then begin | |
68 | + Result := CompareInt( | |
69 | + TNGWords(Item1).Rank, TNGWords(Item2).Rank); | |
70 | + end else begin | |
71 | + Result := CompareInt( | |
72 | + TNGWord(Item1).Rank, TNGWord(Item2).Rank); | |
73 | + end; | |
74 | +end; | |
75 | +constructor TNGWords.Create; | |
76 | +begin | |
77 | + FRank := 0; | |
78 | +end; | |
79 | +procedure TNGWords.Free; | |
80 | +var | |
81 | + i: Integer; | |
82 | +begin | |
83 | + for i := 0 to Count - 1 do begin | |
84 | + TObject(Items[i]).Free; | |
85 | + end; | |
86 | + inherited Free; | |
87 | +end; | |
88 | +function TNGWords.ReadXMLElement(element :IXMLNode): Boolean; | |
89 | +var | |
90 | + i, bound : Integer; | |
91 | + NGWordNode: IXMLNode; | |
92 | + NG: TNGWord; | |
93 | +begin | |
94 | + Result := False; | |
95 | + if element.NodeName = 'NGWords' then begin | |
96 | + Rank := StrToIntDef(element.Attributes['rank'], | |
97 | + MaxInt); | |
98 | + Invisible := StrToBoolDef(element.Attributes['invisible'], | |
99 | + False); | |
100 | + bound := element.ChildNodes.Count - 1; | |
101 | + for i := 0 to bound do begin | |
102 | + NGWordNode := element.ChildNodes[i]; | |
103 | + if NGWordNode.NodeName = 'NGWord' then begin | |
104 | + NG := TNGWord.Create; | |
105 | + NG.ReadXMLElement( NGWordNode ); | |
106 | + Add(NG); | |
107 | + end; | |
108 | + end; | |
109 | + Sort(@CompareRank); | |
110 | + Result := True; | |
111 | + end; | |
112 | +end; | |
113 | +function TNGWords.ToXMLString(): String; | |
114 | +var | |
115 | + i: Integer; | |
116 | +begin | |
117 | + Result := '<NGWords ' + | |
118 | + 'rank="' + IntToStr(FRank) + '" ' + | |
119 | + 'invisible="' + BoolToStr(Invisible) + '" >'#13#10; | |
120 | + for i := 0 to Count - 1 do begin | |
121 | + Result := Result + TNGWord(Items[i]).ToXMLString + #13#10; | |
122 | + end; | |
123 | + Result := Result + '</NGWords>'; | |
124 | +end; | |
125 | +function TNGWords.ToString(): String; | |
126 | +var | |
127 | + i: Integer; | |
128 | +begin | |
129 | + Result := ''; | |
130 | + for i := 0 to Count - 1 do begin | |
131 | + Result := Result + TNGWord(Items[i]).Word + ' , '; | |
132 | + end; | |
133 | +end; | |
134 | +procedure TNGWords.Delete(word: TNGWord); | |
135 | +var | |
136 | + i: Integer; | |
137 | +begin | |
138 | + for i := Count - 1 downto 0 do begin | |
139 | + if ( Items[i] = word ) then begin | |
140 | + TNGWord(Items[i]).Free; | |
141 | + Self.Delete(i); | |
142 | + break; | |
143 | + end; | |
144 | + end; | |
145 | +end; | |
146 | +procedure TNGWord.ReadXMLElement(element :IXMLNode); | |
147 | +begin | |
148 | + FRank := StrToIntDef(element.Attributes['rank'], | |
149 | + MaxInt); | |
150 | + FNGType := TGikoNGType(StrToIntDef( | |
151 | + Trim(element.Attributes['ngtype']), | |
152 | + Integer(gntAll))); | |
153 | + | |
154 | + FWord := Trim(element.Attributes['word']); | |
155 | + if FWord <> '' then begin | |
156 | + FWord := MojuUtils.UnSanitize( FWord ); | |
157 | + end; | |
158 | +end; | |
159 | +function TNGWord.ToXMLString(): String; | |
160 | +begin | |
161 | + Result := '<NGWord ' + | |
162 | + 'rank="' + IntToStr(FRank) + '" ' + | |
163 | + 'ngtype="' + IntToStr(Integer(FNGType)) + '" ' + | |
164 | + 'word="' + MojuUtils.Sanitize(FWord) + '" />'; | |
165 | +end; | |
166 | + | |
167 | +procedure TNGWordList.Free; | |
168 | +var | |
169 | + i: Integer; | |
170 | +begin | |
171 | + for i := Self.Count - 1 downto 0 do begin | |
172 | + TNGWords(Self.Items[i]).Free; | |
173 | + end; | |
174 | + inherited Free; | |
175 | +end; | |
176 | + | |
177 | +procedure TNGWordList.SaveToFrile(fileName: String); | |
178 | +var | |
179 | + xmlStrings: TStringList; | |
180 | + i: Integer; | |
181 | +begin | |
182 | + xmlStrings := TStringList.Create; | |
183 | + try | |
184 | + xmlStrings.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>'); | |
185 | + xmlStrings.Add('<root>'); | |
186 | + for i := 0 to Self.Count - 1 do begin | |
187 | + xmlStrings.Add( | |
188 | + TNGWords(Self.Items[i]).ToXMLString); | |
189 | + | |
190 | + end; | |
191 | + xmlStrings.Add('</root>'); | |
192 | + xmlStrings.SaveToFile(fileName); | |
193 | + finally | |
194 | + xmlStrings.Free; | |
195 | + end; | |
196 | +end; | |
197 | + | |
198 | +procedure TNGWordList.LoadFromFile(fileName: String); | |
199 | + | |
200 | +var | |
201 | + i, bound : Integer; | |
202 | + XMLDoc : IXMLDocument; | |
203 | + XMLNode: IXMLNode; | |
204 | + NG : TNGWords; | |
205 | +{$IFDEF DEBUG} | |
206 | + st, rt : Cardinal; | |
207 | +{$ENDIF} | |
208 | +begin | |
209 | +{$IFDEF DEBUG} | |
210 | + st := GetTickCount; | |
211 | +{$ENDIF} | |
212 | + if FileExists( FileName ) then begin | |
213 | + if (Self.Count > 0) then begin | |
214 | + Self.Free; | |
215 | + Self.Capacity := 0; | |
216 | + end; | |
217 | + try | |
218 | + XMLDoc := IXMLDocument.Create; | |
219 | + //XMLDoc := LoadXMLDocument(FileName); | |
220 | + LoadXMLDocument(FileName, XMLDoc); | |
221 | + try | |
222 | + XMLNode := XMLDoc.DocumentElement; | |
223 | + | |
224 | + if XMLNode.NodeName = 'root' then begin | |
225 | + bound := XMLNode.ChildNodes.Count - 1; | |
226 | + for i := 0 to bound do begin | |
227 | + NG := TNGWords.Create; | |
228 | + if (NG.ReadXMLElement(XMLNode.ChildNodes[i])) then | |
229 | + Self.Add(NG); | |
230 | + end; | |
231 | + end; | |
232 | + Sort(@CompareRank); | |
233 | + finally | |
234 | + XMLDoc.Free; | |
235 | + end; | |
236 | + except | |
237 | + end; | |
238 | + end; | |
239 | +{$IFDEF DEBUG} | |
240 | + rt := GetTickCount - st; | |
241 | + Writeln('Runtime(Load NGWords) : ' + IntToStr(rt) + ' ms'); | |
242 | +{$ENDIF} | |
243 | +end; | |
244 | +procedure TNGWordList.Delte(NGWords: TNGWords); | |
245 | +var | |
246 | + i: Integer; | |
247 | +begin | |
248 | + for i := Count - 1 downto 0 do begin | |
249 | + if ( Items[i] = NGWords ) then begin | |
250 | + TNGWords(Items[i]).Free; | |
251 | + Self.Delete(i); | |
252 | + break; | |
253 | + end; | |
254 | + end; | |
255 | +end; | |
256 | + | |
257 | +end. |
@@ -76,7 +76,9 @@ uses | ||
76 | 76 | MoveHistoryItem in 'MoveHistoryItem.pas', |
77 | 77 | SambaTimer in 'SambaTimer.pas', |
78 | 78 | HistoryList in 'HistoryList.pas', |
79 | - NewBoardURL in 'NewBoardURL.pas' {NewBoardURLForm}; | |
79 | + NewBoardURL in 'NewBoardURL.pas' {NewBoardURLForm}, | |
80 | + NGWordUnit in 'NGWordUnit.pas', | |
81 | + NGWordEdit in 'NGWordEdit.pas' {NGWordEditForm}; | |
80 | 82 | |
81 | 83 | {$R *.RES} |
82 | 84 | {$R gikoResource.res} |