Ignore:
Timestamp:
Jan 17, 2025, 9:05:54 PM (4 days ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Modified: Remove U prefix from unit names.
  • Modified: Use Gneeric.Collections instead of fgl.
  • Modified: Do not use global form variables.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormAcronyms.pas

    r218 r219  
    1 unit UFormAcronyms;
    2 
    3 {$mode delphi}
     1unit FormAcronyms;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   Menus, ActnList, UListViewSort, UAcronym, LazUTF8, fgl;
     7  Menus, ActnList, ListViewSort, Acronym, LazUTF8, Generics.Collections,
     8  Generics.Defaults, FormEx;
    109
    1110type
     
    1312  { TFormAcronyms }
    1413
    15   TFormAcronyms = class(TForm)
     14  TFormAcronyms = class(TFormEx)
    1615    AAdd: TAction;
    1716    ASelectAll: TAction;
     
    3635    procedure ARemoveExecute(Sender: TObject);
    3736    procedure ASelectAllExecute(Sender: TObject);
    38     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3937    procedure FormCreate(Sender: TObject);
    4038    procedure FormShow(Sender: TObject);
     
    5250    FAcronyms: TAcronyms;
    5351    MeaningCount: Integer;
    54     procedure FilterList(List: TFPGObjectList<TObject>);
     52    function AcronymComparer(constref Item1, Item2: TAcronym): Integer;
     53    procedure FilterList(List: TObjectList<TObject>);
    5554    procedure SetAcronyms(AValue: TAcronyms);
    5655    procedure UpdateAcronymsList;
     
    6160  end;
    6261
    63 var
    64   FormAcronyms: TFormAcronyms;
    6562
    6663implementation
     
    6966
    7067uses
    71   UCore, UFormMain, UFormAcronym;
     68  Core, FormAcronym;
    7269
    7370resourcestring
     
    117114  I: Integer;
    118115begin
    119   Core.PersistentForm1.Load(Self);
    120116  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    121117  UpdateAcronymsList;
    122   Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
     118  Core.Core.ScaleDPI1.ScaleControl(ToolBar1, Core.Core.ScaleDPI1.DesignDPI);
    123119
    124120  // Focus line with acronym
     
    140136  Meaning: TAcronymMeaning;
    141137  I: Integer;
     138  FormAcronym: TFormAcronym;
    142139begin
    143140  TempEntry := TAcronymEntry.Create;
     
    175172  Meaning: TAcronymMeaning;
    176173  I: Integer;
     174  FormAcronym: TFormAcronym;
    177175begin
    178176  if Assigned(ListViewAcronyms.Selected) then
     
    194192        (TempEntry.Meaning <> Name) or
    195193        (TempEntry.Description <> Description) or
    196         not FormMain.CompareStrings(TempEntry.Categories, TempCategories) then begin
     194        not Core.Core.CompareStrings(TempEntry.Categories, TempCategories) then begin
    197195          // TODO: Update item inplace if possible
    198196          Acronyms.Db.RemoveMeaning(TAcronymMeaning(ListViewAcronyms.Selected.Data));
     
    246244end;
    247245
    248 procedure TFormAcronyms.FormClose(Sender: TObject; var CloseAction: TCloseAction
    249   );
    250 begin
    251   Core.PersistentForm1.Save(Self);
    252 end;
    253 
    254246procedure TFormAcronyms.FormCreate(Sender: TObject);
    255247var
     
    258250  FocusAcronym := nil;
    259251  MeaningCount := 0;
    260   Core.Translator.TranslateComponentRecursive(Self);
    261   Core.ThemeManager.UseTheme(Self);
    262252  for I := 0 to ToolBar1.ButtonCount - 1 do
    263253    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
     
    288278end;
    289279
     280function TFormAcronyms.AcronymComparer(constref Item1, Item2: TAcronym): Integer;
     281begin
     282  Result := CompareStr(TAcronym(Item1).Name, TAcronym(Item2).Name);
     283end;
     284
    290285procedure TFormAcronyms.ListViewSort1Filter(ListViewSort: TListViewSort);
    291286begin
    292   Acronyms.Db.Acronyms.Sort(AcronymComparer);
     287  Acronyms.Db.Acronyms.Sort(TComparer<TAcronym>.Construct(AcronymComparer));
    293288  Acronyms.Db.AssignToList(ListViewSort1.List);
    294289  MeaningCount := ListViewSort1.List.Count;
     
    296291end;
    297292
    298 procedure TFormAcronyms.FilterList(List: TFPGObjectList<TObject>);
     293procedure TFormAcronyms.FilterList(List: TObjectList<TObject>);
    299294var
    300295  I: Integer;
Note: See TracChangeset for help on using the changeset viewer.