| 15 |
{ Private 宣言 } |
{ Private 宣言 } |
| 16 |
FInit : Boolean; |
FInit : Boolean; |
| 17 |
FDictionary : TStringList; ///< 登録単語と定型文の辞書 |
FDictionary : TStringList; ///< 登録単語と定型文の辞書 |
| 18 |
|
FSorted : Boolean; |
| 19 |
function GetSorted: Boolean; ///< ソートの状態の取得 |
function GetSorted: Boolean; ///< ソートの状態の取得 |
| 20 |
procedure SetSorted(Value: Boolean); ///< ソート状態の設定 |
procedure SetSorted(Value: Boolean); ///< ソート状態の設定 |
| 21 |
|
|
| 58 |
end; |
end; |
| 59 |
|
|
| 60 |
function CategorySort(List: TStringList; Index1, Index2: Integer): Integer; |
function CategorySort(List: TStringList; Index1, Index2: Integer): Integer; |
| 61 |
|
function KeySort(List: TStringList; Index1, Index2: Integer): Integer; |
| 62 |
var |
var |
| 63 |
InputAssistDM: TInputAssistDM; |
InputAssistDM: TInputAssistDM; |
| 64 |
|
|
| 149 |
sections.Free; |
sections.Free; |
| 150 |
ini.Free; |
ini.Free; |
| 151 |
end; |
end; |
| 152 |
|
if FSorted Then begin |
| 153 |
|
FDictionary.CustomSort(KeySort); |
| 154 |
|
end; |
| 155 |
end; |
end; |
| 156 |
|
|
| 157 |
except |
except |
| 171 |
except |
except |
| 172 |
end; |
end; |
| 173 |
end; |
end; |
| 174 |
|
|
| 175 |
ini := TMemIniFile.Create(FilePath); |
ini := TMemIniFile.Create(FilePath); |
| 176 |
try |
try |
| 177 |
for i :=0 to FDictionary.Count - 1 do begin |
for i :=0 to FDictionary.Count - 1 do begin |
| 201 |
procedure TInputAssistDM.DataModuleCreate(Sender: TObject); |
procedure TInputAssistDM.DataModuleCreate(Sender: TObject); |
| 202 |
begin |
begin |
| 203 |
FDictionary := TStringList.Create; |
FDictionary := TStringList.Create; |
| 204 |
FDictionary.Duplicates := dupAccept; |
FDictionary.Sorted := False; |
| 205 |
FDictionary.Sorted := True; |
FSorted := True; |
| 206 |
end; |
end; |
| 207 |
//! 登録単語数取得 |
//! 登録単語数取得 |
| 208 |
function TInputAssistDM.ResistWordCount : Integer; |
function TInputAssistDM.ResistWordCount : Integer; |
| 235 |
break; |
break; |
| 236 |
end; |
end; |
| 237 |
end; |
end; |
| 238 |
|
if FSorted Then begin |
| 239 |
|
FDictionary.CustomSort(KeySort); |
| 240 |
|
end; |
| 241 |
end; |
end; |
| 242 |
end; |
end; |
| 243 |
//! 登録単語追加 |
//! 登録単語追加 |
| 253 |
resWord.SetText('定型文'); |
resWord.SetText('定型文'); |
| 254 |
FDictionary.AddObject(Key, resWord); |
FDictionary.AddObject(Key, resWord); |
| 255 |
Result := resWord; |
Result := resWord; |
| 256 |
|
if FSorted Then begin |
| 257 |
|
FDictionary.CustomSort(KeySort); |
| 258 |
|
end; |
| 259 |
end; |
end; |
| 260 |
end; |
end; |
| 261 |
//! 登録単語のキー変更 |
//! 登録単語のキー変更 |
| 270 |
break; |
break; |
| 271 |
end; |
end; |
| 272 |
end; |
end; |
| 273 |
|
if FSorted Then begin |
| 274 |
|
FDictionary.CustomSort(KeySort); |
| 275 |
|
end; |
| 276 |
|
|
| 277 |
end; |
end; |
| 278 |
end; |
end; |
| 279 |
//! Keyを持つ登録されている単語を取得 |
//! Keyを持つ登録されている単語を取得 |
| 323 |
//! ソートの状態の取得 |
//! ソートの状態の取得 |
| 324 |
function TInputAssistDM.GetSorted: Boolean; |
function TInputAssistDM.GetSorted: Boolean; |
| 325 |
begin |
begin |
| 326 |
Result := False; |
Result := FSorted; |
|
if (FDictionary <> nil) then begin |
|
|
Result := FDictionary.Sorted; |
|
|
end; |
|
| 327 |
end; |
end; |
| 328 |
//! ソート状態の設定 |
//! ソート状態の設定 |
| 329 |
procedure TInputAssistDM.SetSorted(Value: Boolean); |
procedure TInputAssistDM.SetSorted(Value: Boolean); |
| 330 |
begin |
begin |
| 331 |
if (FDictionary <> nil) then begin |
if (not FSorted) and (Value) then begin |
| 332 |
FDictionary.Sorted := Value; |
FDictionary.CustomSort(KeySort); |
| 333 |
end; |
end; |
| 334 |
|
FSorted := Value; |
| 335 |
end; |
end; |
| 336 |
//! Keyのカテゴリに登録されている単語を取得 |
//! Keyのカテゴリに登録されている単語を取得 |
| 337 |
function TInputAssistDM.GetCategoryResistWords(Key: String; var list: TStringList): Integer; |
function TInputAssistDM.GetCategoryResistWords(Key: String; var list: TStringList): Integer; |
| 381 |
try |
try |
| 382 |
resWord1 := TResistWord(List.Objects[Index1]); |
resWord1 := TResistWord(List.Objects[Index1]); |
| 383 |
resWord2 := TResistWord(List.Objects[Index2]); |
resWord2 := TResistWord(List.Objects[Index2]); |
| 384 |
Result := AnsiCompareStr(resWord1.GetCategory, resWord2.GetCategory); |
Result := CompareStr(ZenToHan(resWord1.GetCategory), |
| 385 |
|
ZenToHan(resWord2.GetCategory)); |
| 386 |
|
if (Result = 0) then begin |
| 387 |
|
Result := CompareStr(ZenToHan(resWord1.GetKey), |
| 388 |
|
ZenToHan(resWord2.GetKey)); |
| 389 |
|
end; |
| 390 |
|
except |
| 391 |
|
end; |
| 392 |
|
end; |
| 393 |
|
//! Keyを全半角無視の形でソートする際の比較メソッド |
| 394 |
|
function KeySort(List: TStringList; Index1, Index2: Integer): Integer; |
| 395 |
|
var |
| 396 |
|
resWord1 : TResistWord; |
| 397 |
|
resWord2 : TResistWord; |
| 398 |
|
begin |
| 399 |
|
Result := 0; |
| 400 |
|
try |
| 401 |
|
resWord1 := TResistWord(List.Objects[Index1]); |
| 402 |
|
resWord2 := TResistWord(List.Objects[Index2]); |
| 403 |
|
Result := CompareStr(ZenToHan(resWord1.FKey), |
| 404 |
|
ZenToHan(resWord2.FKey)); |
| 405 |
if (Result = 0) then begin |
if (Result = 0) then begin |
| 406 |
Result := AnsiCompareStr(resWord1.GetKey, resWord2.GetKey); |
Result := CompareStr(ZenToHan(resWord1.GetCategory), |
| 407 |
|
ZenToHan(resWord2.GetCategory)); |
| 408 |
end; |
end; |
| 409 |
except |
except |
| 410 |
end; |
end; |