interface
uses
- SysUtils, Classes;
+ SysUtils, Classes, Windows;
type
TResistWord = class;
{ Private \90é\8c¾ }
FInit : Boolean;
FDictionary : TStringList; ///< \93o\98^\92P\8cê\82Æ\92è\8c^\95¶\82Ì\8e«\8f\91
+ FSorted : Boolean;
function GetSorted: Boolean; ///< \83\\81[\83g\82Ì\8fó\91Ô\82Ì\8eæ\93¾
procedure SetSorted(Value: Boolean); ///< \83\\81[\83g\8fó\91Ô\82Ì\90Ý\92è
function GetCategoryResistWords(Key: String; var list: TStringList): Integer;
//! \93o\98^\8dÏ\82Ý\83L\81[\82Ì\91S\82Ä\82Ì\83J\83e\83S\83\8a\83\8a\83X\83g\8eæ\93¾
procedure GetCategoryList(var list: TStringList);
+ //! \8aù\82É\93o\98^\8dÏ\82Ý\82Ì\83L\81[\82Æ\83J\83e\83S\83\8a\82Ì\83Z\83b\83g\82©\82Ç\82¤\82©\83`\83F\83b\83N
+ function IsDupulicate(Key: String; Category: String): Boolean;
end;
end;
function CategorySort(List: TStringList; Index1, Index2: Integer): Integer;
+ function KeySort(List: TStringList; Index1, Index2: Integer): Integer;
var
InputAssistDM: TInputAssistDM;
keys: TStringList;
i, j : Integer;
resWord : TResistWord;
- tmpStr: String;
begin
FInit := True;
try
- // ini\83t\83@\83C\83\8b\82ª\96³\82¯\82ê\82Î\81A\83f\83t\83H\83\8b\83g\82ð\83\8a\83l\81[\83\80\82·\82é
- if not FileExists(FilePath) then begin
- RenameFile(ChangeFileExt(FilePath, '.default'), FilePath);
- end;
-
// \83t\83@\83C\83\8b\82Ì\91¶\8dÝ\82ð\8am\94F
if FileExists(FilePath) then begin
- ini := TMemIniFile.Create(FilePath);
+ ini := TMemIniFile.Create(FilePath);
sections := TStringList.Create;
keys := TStringList.Create;
try
sections.Free;
ini.Free;
end;
+ if FSorted Then begin
+ FDictionary.CustomSort(KeySort);
+ end;
end;
except
begin
if FileExists(FilePath) then begin
try
- DeleteFile(FilePath);
+ SysUtils.DeleteFile(FilePath);
except
end;
end;
+
ini := TMemIniFile.Create(FilePath);
try
for i :=0 to FDictionary.Count - 1 do begin
procedure TInputAssistDM.DataModuleCreate(Sender: TObject);
begin
FDictionary := TStringList.Create;
- FDictionary.Duplicates := dupAccept;
- FDictionary.Sorted := True;
+ FDictionary.Sorted := False;
+ FSorted := True;
end;
//! \93o\98^\92P\8cê\90\94\8eæ\93¾
function TInputAssistDM.ResistWordCount : Integer;
break;
end;
end;
+ if FSorted Then begin
+ FDictionary.CustomSort(KeySort);
+ end;
end;
end;
//! \93o\98^\92P\8cê\92Ç\89Á
resWord.SetText('\92è\8c^\95¶');
FDictionary.AddObject(Key, resWord);
Result := resWord;
+ if FSorted Then begin
+ FDictionary.CustomSort(KeySort);
+ end;
end;
end;
//! \93o\98^\92P\8cê\82Ì\83L\81[\95Ï\8dX
break;
end;
end;
+ if FSorted Then begin
+ FDictionary.CustomSort(KeySort);
+ end;
+
end;
end;
//! Key\82ð\8e\9d\82Â\93o\98^\82³\82ê\82Ä\82¢\82é\92P\8cê\82ð\8eæ\93¾
//! \83\\81[\83g\82Ì\8fó\91Ô\82Ì\8eæ\93¾
function TInputAssistDM.GetSorted: Boolean;
begin
- Result := False;
- if (FDictionary <> nil) then begin
- Result := FDictionary.Sorted;
- end;
+ Result := FSorted;
end;
//! \83\\81[\83g\8fó\91Ô\82Ì\90Ý\92è
procedure TInputAssistDM.SetSorted(Value: Boolean);
begin
- if (FDictionary <> nil) then begin
- FDictionary.Sorted := Value;
+ if (not FSorted) and (Value) then begin
+ FDictionary.CustomSort(KeySort);
end;
+ FSorted := Value;
end;
//! Key\82Ì\83J\83e\83S\83\8a\82É\93o\98^\82³\82ê\82Ä\82¢\82é\92P\8cê\82ð\8eæ\93¾
function TInputAssistDM.GetCategoryResistWords(Key: String; var list: TStringList): Integer;
try
resWord1 := TResistWord(List.Objects[Index1]);
resWord2 := TResistWord(List.Objects[Index2]);
- Result := AnsiCompareStr(resWord1.GetCategory, resWord2.GetCategory);
+ Result := CompareStr(ZenToHan(resWord1.GetCategory),
+ ZenToHan(resWord2.GetCategory));
if (Result = 0) then begin
- Result := AnsiCompareStr(resWord1.GetKey, resWord2.GetKey);
+ Result := CompareStr(ZenToHan(resWord1.GetKey),
+ ZenToHan(resWord2.GetKey));
end;
except
end;
end;
+//! Key\82ð\91S\94¼\8ap\96³\8e\8b\82Ì\8c`\82Å\83\\81[\83g\82·\82é\8dÛ\82Ì\94ä\8ar\83\81\83\\83b\83h
+function KeySort(List: TStringList; Index1, Index2: Integer): Integer;
+var
+ resWord1 : TResistWord;
+ resWord2 : TResistWord;
+begin
+ Result := 0;
+ try
+ resWord1 := TResistWord(List.Objects[Index1]);
+ resWord2 := TResistWord(List.Objects[Index2]);
+ Result := CompareStr(ZenToHan(resWord1.FKey),
+ ZenToHan(resWord2.FKey));
+ if (Result = 0) then begin
+ Result := CompareStr(ZenToHan(resWord1.GetCategory),
+ ZenToHan(resWord2.GetCategory));
+ end;
+ except
+ end;
+end;
+//! \8aù\82É\93o\98^\8dÏ\82Ý\82Ì\83L\81[\82Æ\83J\83e\83S\83\8a\82Ì\83Z\83b\83g\82©\82Ç\82¤\82©\83`\83F\83b\83N
+function TInputAssistDM.IsDupulicate(Key: String; Category: String): Boolean;
+var
+ i : Integer;
+// resWord : TResistWord;
+begin
+ // \82±\82Ì\83\81\83\\83b\83h\82Å\82Í\81A\83\\81[\83g\8dÏ\82Ý\82Æ\82Í\8cÀ\82ç\82È\82¢\82Ì\82Å\81A\91S\82Ä\82Ì\83L\81[\82ð\92T\8dõ\82µ\82Ä\82¢\82é
+ Result := False;
+ if (FDictionary <> nil) then begin
+ for i := 0 to FDictionary.Count - 1 do begin
+ if (Key = FDictionary.Strings[i]) and
+ (Category = TResistWord(FDictionary.Objects[i]).GetCategory)
+ then begin
+ Result := True;
+ Break;
+ end;
+ end;
+ end;
+end;
end.