ギコナビ
Révision | 8c75b563f03558e13718e0ad85442da76b440247 (tree) |
---|---|
l'heure | 2007-07-22 19:23:51 |
Auteur | h677 <h677> |
Commiter | h677 |
追加・適用でカテゴリがクリアされないように修正。
カテゴリが設定されていない場合も登録できないように修正。
@@ -64,7 +64,8 @@ type | ||
64 | 64 | FSortColumn : Integer; |
65 | 65 | FInsertText : String; |
66 | 66 | procedure AddListViewItem(ResWord : TResistWord); |
67 | - procedure SetCategory(combo: TComboBox); | |
67 | + procedure SetCategory(combo: TComboBox; selected: String); | |
68 | + function ValidateKey(key, category: String): boolean; | |
68 | 69 | public |
69 | 70 | { Public é¾ } |
70 | 71 | procedure SetUpFromEditor(); |
@@ -143,22 +144,35 @@ procedure TInputAssistForm.AddButtonClick(Sender: TObject); | ||
143 | 144 | var |
144 | 145 | resWord : TResistWord; |
145 | 146 | begin |
146 | - if (Length(KeyNameEdit.Text) = 0) then begin | |
147 | - ShowMessage('L[¼ðÝèµÄ¾³¢B'); | |
148 | - end else begin | |
147 | + if (ValidateKey(KeyNameEdit.Text, CategoryNameComboBox.Text)) then begin | |
149 | 148 | if (not InputAssistDM.IsDupulicate( |
150 | 149 | KeyNameEdit.Text, CategoryNameComboBox.Text) ) then begin |
151 | 150 | resWord := InputAssistDM.Add(KeyNameEdit.Text); |
152 | 151 | resWord.SetCategory(CategoryNameComboBox.Text); |
153 | 152 | resWord.SetText(TextMemo.Text); |
154 | 153 | AddListViewItem(resWord); |
155 | - SetCategory(CategoryNameComboBox); | |
154 | + SetCategory(CategoryNameComboBox, resWord.GetCategory); | |
156 | 155 | GikoListView1.AlphaSort; |
157 | 156 | end else begin |
158 | 157 | ShowMessage('¯êÌL[¼EJeS¼ÅùÉo^ÏÝÅ·B'); |
159 | 158 | end; |
160 | 159 | end; |
161 | 160 | end; |
161 | +//! L[¼EJeSLø`FbN | |
162 | +function TInputAssistForm.ValidateKey(key, category: String): boolean; | |
163 | +begin | |
164 | + Result := True; | |
165 | + if (Length(key) = 0) then begin | |
166 | + ShowMessage('L[¼ðÝèµÄ¾³¢B'); | |
167 | + Result := False; | |
168 | + end else begin | |
169 | + if (Length(category) = 0) then begin | |
170 | + ShowMessage('JeSðÝèµÄ¾³¢B'); | |
171 | + Result := False; | |
172 | + end; | |
173 | + end; | |
174 | +end; | |
175 | + | |
162 | 176 | //! í{^ºÌCxg |
163 | 177 | procedure TInputAssistForm.DeleteButtonClick(Sender: TObject); |
164 | 178 | begin |
@@ -174,9 +188,7 @@ var | ||
174 | 188 | resWord : TResistWord; |
175 | 189 | begin |
176 | 190 | if GikoListView1.Selected <> nil then begin |
177 | - if (Length(KeyNameEdit.Text) = 0) then begin | |
178 | - ShowMessage('L[¼ð³µÉÍūܹñB'); | |
179 | - end else begin | |
191 | + if (ValidateKey(KeyNameEdit.Text, CategoryNameComboBox.Text)) then begin | |
180 | 192 | if (not InputAssistDM.IsDupulicate( |
181 | 193 | KeyNameEdit.Text, CategoryNameComboBox.Text) ) then begin |
182 | 194 | resWord := TResistWord(GikoListView1.Selected.Data); |
@@ -186,7 +198,7 @@ begin | ||
186 | 198 | // êÌXV |
187 | 199 | GikoListView1.Selected.Caption := resWord.GetKey; |
188 | 200 | GikoListView1.Selected.SubItems[0] := resWord.GetCategory; |
189 | - SetCategory(CategoryNameComboBox); | |
201 | + SetCategory(CategoryNameComboBox, resWord.GetCategory); | |
190 | 202 | GikoListView1.AlphaSort; |
191 | 203 | end else begin |
192 | 204 | ShowMessage('¯êÌL[¼EJeS¼ÅùÉo^ÏÝÅ·B'); |
@@ -297,9 +309,10 @@ begin | ||
297 | 309 | LockWindowUpdate(0); |
298 | 310 | end; |
299 | 311 | //! JeSR{{bNXÝè |
300 | -procedure TInputAssistForm.SetCategory(combo: TComboBox); | |
312 | +procedure TInputAssistForm.SetCategory(combo: TComboBox; selected: String); | |
301 | 313 | var |
302 | 314 | cat : TStringList; |
315 | + i : Integer; | |
303 | 316 | begin |
304 | 317 | // õp |
305 | 318 | cat := TStringList.Create; |
@@ -311,6 +324,11 @@ begin | ||
311 | 324 | combo.Items.AddStrings(cat); |
312 | 325 | combo.ItemIndex := 0; |
313 | 326 | combo.Items.EndUpdate; |
327 | + // IðÏÝÌJeSÉCfbNXðÏX | |
328 | + i := combo.Items.IndexOf(selected); | |
329 | + if (i <> -1) then begin | |
330 | + combo.ItemIndex := i; | |
331 | + end; | |
314 | 332 | finally |
315 | 333 | cat.Free; |
316 | 334 | end; |
@@ -326,11 +344,9 @@ begin | ||
326 | 344 | FInsertText := ''; |
327 | 345 | CloseAction.ShortCut := TShortCut(0); |
328 | 346 | // ÇÁpL[üÍOK |
329 | - SetCategory(CategoryNameComboBox); | |
347 | + SetCategory(CategoryNameComboBox, ''); | |
330 | 348 | end; |
331 | 349 | procedure TInputAssistForm.SetUpFromEditor(); |
332 | -var | |
333 | - cat : TStringList; | |
334 | 350 | begin |
335 | 351 | Self.Caption := 'üÍAVXg'; |
336 | 352 | Panel3.Visible := False; |
@@ -340,7 +356,7 @@ begin | ||
340 | 356 | FInsertText := ''; |
341 | 357 | CloseAction.ShortCut := ShortCut(VK_ESCAPE, []); |
342 | 358 | // õp |
343 | - SetCategory(CategoryComboBox); | |
359 | + SetCategory(CategoryComboBox, ''); | |
344 | 360 | end; |
345 | 361 | function TInputAssistForm.GetInsertText(): String; |
346 | 362 | begin |