Changeset 184 for trunk/UAcronym.pas


Ignore:
Timestamp:
Jul 4, 2018, 2:05:48 PM (6 years ago)
Author:
chronos
Message:
  • Added: New menu action Tools - Document check which shows a form for checking acronyms in text documents.
  • Added: Remember dimensions of Import, Export and Settings forms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UAcronym.pas

    r159 r184  
    1717  TImportSources = class;
    1818  TImportFormats = class;
     19
     20  TSearchFlag = (sfCaseInsensitive);
     21  TSearchFlags = set of TSearchFlag;
    1922
    2023  { TAcronym }
     
    3639    procedure SaveToNode(Node: TDOMNode);
    3740    procedure LoadFromNode(Node: TDOMNode);
    38     function SearchByName(Name: string): TAcronym;
     41    function SearchByName(Name: string; Flags: TSearchFlags = []): TAcronym;
    3942    function AddAcronym(Name: string): TAcronym;
    4043  end;
     
    6568    procedure SaveToNode(Node: TDOMNode);
    6669    procedure LoadFromNode(Node: TDOMNode);
    67     function SearchByName(Name: string): TAcronymMeaning;
     70    function SearchByName(Name: string; Flags: TSearchFlags = []): TAcronymMeaning;
    6871    function AddMeaning(Name: string): TAcronymMeaning;
    6972  end;
     
    237240    function GetMeaningsCount: Integer;
    238241    function AddAcronym(AcronymName, MeaningName: string): TAcronymMeaning;
     242    function SearchAcronym(AcronymName, MeaningName: string; Flags: TSearchFlags = []): TAcronymMeaning;
    239243    procedure RemoveMeaning(Meaning: TAcronymMeaning);
    240244    procedure RemoveAcronym(AcronymName, MeaningName: string);
     
    10311035end;
    10321036
    1033 function TAcronymMeanings.SearchByName(Name: string): TAcronymMeaning;
     1037function TAcronymMeanings.SearchByName(Name: string; Flags: TSearchFlags
     1038  ): TAcronymMeaning;
    10341039var
    10351040  I: Integer;
    10361041begin
    10371042  I := 0;
    1038   while (I < Count) and (TAcronymMeaning(Items[I]).Name <> Name) do Inc(I);
     1043  if sfCaseInsensitive in Flags then begin
     1044    while (I < Count) and (LowerCase(TAcronymMeaning(Items[I]).Name) <> LowerCase(Name)) do Inc(I);
     1045  end else begin
     1046    while (I < Count) and (TAcronymMeaning(Items[I]).Name <> Name) do Inc(I);
     1047  end;
    10391048  if I < Count then Result := TAcronymMeaning(Items[I])
    10401049    else Result := nil;
     
    11521161end;
    11531162
    1154 function TAcronyms.SearchByName(Name: string): TAcronym;
     1163function TAcronyms.SearchByName(Name: string; Flags: TSearchFlags = []): TAcronym;
    11551164var
    11561165  I: Integer;
    11571166begin
    11581167  I := 0;
    1159   while (I < Count) and (TAcronym(Items[I]).Name <> Name) do Inc(I);
     1168  if sfCaseInsensitive in Flags then begin
     1169    while (I < Count) and (LowerCase(TAcronym(Items[I]).Name) <> LowerCase(Name)) do Inc(I);
     1170  end else begin
     1171    while (I < Count) and (TAcronym(Items[I]).Name <> Name) do Inc(I);
     1172  end;
    11601173  if I < Count then Result := TAcronym(Items[I])
    11611174    else Result := nil;
     
    16841697end;
    16851698
     1699function TAcronymDb.SearchAcronym(AcronymName, MeaningName: string;
     1700  Flags: TSearchFlags = []): TAcronymMeaning;
     1701var
     1702  Acronym: TAcronym;
     1703  Meaning: TAcronymMeaning;
     1704begin
     1705  Result := nil;
     1706  Acronym := Acronyms.SearchByName(AcronymName);
     1707  if Assigned(Acronym) then begin
     1708    Meaning := Acronym.Meanings.SearchByName(MeaningName, Flags);
     1709    if Assigned(Meaning) then begin
     1710      Result := Meaning;
     1711    end;
     1712  end;
     1713end;
     1714
    16861715procedure TAcronymDb.RemoveMeaning(Meaning: TAcronymMeaning);
    16871716var
Note: See TracChangeset for help on using the changeset viewer.