Changeset 145 for trunk/UAcronym.pas


Ignore:
Timestamp:
Jan 24, 2017, 1:55:43 PM (7 years ago)
Author:
chronos
Message:
  • Added: Allow to disable selected acronym categories so acronyms without any enabled category won't be shown in main acronym search filter.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UAcronym.pas

    r113 r145  
    7575    AcronymMeanings: TAcronymMeanings;
    7676    ImportSources: TImportSources;
     77    Enabled: Boolean;
    7778    procedure SaveToNode(Node: TDOMNode);
    7879    procedure LoadFromNode(Node: TDOMNode);
     
    9697    procedure AssignFromStrings(Strings: TStrings);
    9798    procedure AddFromStrings(Strings: TStrings);
     99    procedure AssignToList(List: TListObject);
    98100    function GetString: string;
    99101    procedure UpdateLinkImportSources(Item: TImportSource);
    100102    procedure UpdateLinkAcronymMeanings(Item: TAcronymMeaning);
     103    function IsAnyEnabled: Boolean;
    101104  end;
    102105
     
    230233    procedure RemoveMeaning(Meaning: TAcronymMeaning);
    231234    procedure RemoveAcronym(AcronymName, MeaningName: string);
    232     procedure AssignToList(List: TListObject);
     235    procedure AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False);
    233236  end;
    234237
     
    13001303end;
    13011304
     1305procedure TAcronymCategories.AssignToList(List: TListObject);
     1306var
     1307  I: Integer;
     1308begin
     1309  List.Clear;
     1310  for I := 0 to Count - 1 do
     1311    List.Add(TAcronymCategory(Items[I]))
     1312end;
     1313
    13021314function TAcronymCategories.GetString: string;
    13031315var
     
    13281340end;
    13291341
     1342function TAcronymCategories.IsAnyEnabled: Boolean;
     1343var
     1344  I: Integer;
     1345begin
     1346  Result := False;
     1347  for I := 0 to Count - 1 do
     1348  if TAcronymCategory(Items[I]).Enabled then begin
     1349    Result := True;
     1350    Break;
     1351  end;
     1352end;
    13301353
    13311354{ TAcronym }
     
    13711394  WriteString(Node, 'Name', Name);
    13721395  WriteInteger(Node, 'Id', Id);
     1396  WriteBoolean(Node, 'Enabled', Enabled);
    13731397end;
    13741398
     
    13771401  Name := ReadString(Node, 'Name', '');
    13781402  Id := ReadInteger(Node, 'Id', 0);
     1403  Enabled := ReadBoolean(Node, 'Enabled', True);
    13791404end;
    13801405
    13811406constructor TAcronymCategory.Create;
    13821407begin
     1408  Id := 0;
     1409  Name := '';
     1410  Enabled := True;
    13831411  AcronymMeanings := TAcronymMeanings.Create(False);
    13841412  ImportSources := TImportSources.Create(False);
     
    16571685end;
    16581686
    1659 procedure TAcronymDb.AssignToList(List: TListObject);
     1687procedure TAcronymDb.AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False);
    16601688var
    16611689  I: Integer;
     
    16661694  with TAcronym(Acronyms[I]) do begin
    16671695    for J := 0 to Meanings.Count - 1 do
    1668     with TAcronymMeaning(Meanings[J]) do begin
    1669       List.Add(TAcronymMeaning(Meanings[J]))
     1696    with TAcronymMeaning(Meanings[J]) do
     1697    if not EnabledCategoryOnly or (EnabledCategoryOnly and Categories.IsAnyEnabled) then begin
     1698      List.Add(TAcronymMeaning(Meanings[J]));
    16701699    end;
    16711700  end;
Note: See TracChangeset for help on using the changeset viewer.