Ignore:
Timestamp:
Jan 20, 2025, 11:38:55 AM (42 hours ago)
Author:
chronos
Message:
  • Modified: Do not reference global Core object if possible.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormAcronyms.pas

    r219 r227  
    5050    FAcronyms: TAcronyms;
    5151    MeaningCount: Integer;
     52    function CompareStrings(Strings1, Strings2: TStrings): Boolean;
    5253    function AcronymComparer(constref Item1, Item2: TAcronym): Integer;
    5354    procedure FilterList(List: TObjectList<TObject>);
     
    5556    procedure UpdateAcronymsList;
    5657  public
     58    AcronymDb: TAcronymDb;
    5759    FocusAcronym: TAcronymMeaning;
    5860    property Acronyms: TAcronyms read FAcronyms write SetAcronyms;
     
    6668
    6769uses
    68   Core, FormAcronym;
     70  FormAcronym;
    6971
    7072resourcestring
     
    116118  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    117119  UpdateAcronymsList;
    118   Core.Core.ScaleDPI1.ScaleControl(ToolBar1, Core.Core.ScaleDPI1.DesignDPI);
     120  ScaleDPI.ScaleControl(ToolBar1, ScaleDPI.DesignDPI);
    119121
    120122  // Focus line with acronym
     
    131133end;
    132134
     135function TFormAcronyms.CompareStrings(Strings1, Strings2: TStrings): Boolean;
     136var
     137  I: Integer;
     138begin
     139  Result := Strings1.Count = Strings2.Count;
     140  if not Result then Exit;
     141  for I := 0 to Strings1.Count - 1 do
     142    if (Strings1[I] <> Strings2[I]) or (Strings1.Objects[I] <> Strings2.Objects[I]) then begin
     143      Result := False;
     144      Exit;
     145    end;
     146end;
     147
    133148procedure TFormAcronyms.AAddExecute(Sender: TObject);
    134149var
     
    144159  FormAcronym := TFormAcronym.Create(Self);
    145160  try
     161    FormAcronym.AcronymDb := AcronymDb;
    146162    FormAcronym.Load(TempEntry);
    147163    if FormAcronym.ShowModal = mrOk then begin
     
    186202    FormAcronym := TFormAcronym.Create(Self);
    187203    try
     204      FormAcronym.AcronymDb := AcronymDb;
    188205      FormAcronym.Load(TempEntry);
    189206      if FormAcronym.ShowModal = mrOk then begin
     
    192209        (TempEntry.Meaning <> Name) or
    193210        (TempEntry.Description <> Description) or
    194         not Core.Core.CompareStrings(TempEntry.Categories, TempCategories) then begin
     211        not CompareStrings(TempEntry.Categories, TempCategories) then begin
    195212          // TODO: Update item inplace if possible
    196213          Acronyms.Db.RemoveMeaning(TAcronymMeaning(ListViewAcronyms.Selected.Data));
     
    201218          // Update reverse references
    202219          for I := 0 to Meaning.Categories.Count - 1 do
    203             if TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.IndexOf(Meaning) = -1 then
    204               TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.Add(Meaning);
     220            if Meaning.Categories.Items[I].AcronymMeanings.IndexOf(Meaning) = -1 then
     221              Meaning.Categories.Items[I].AcronymMeanings.Add(Meaning);
    205222          Acronyms.Db.Update;
    206223          UpdateAcronymsList;
Note: See TracChangeset for help on using the changeset viewer.