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/FormCategories.pas

    r218 r219  
    1 unit UFormCategories;
    2 
    3 {$mode delphi}
     1unit FormCategories;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ActnList, Menus, UAcronym, UListViewSort;
     7  ActnList, Menus, Acronym, ListViewSort, FormEx;
    108
    119type
     
    1311  { TFormCategories }
    1412
    15   TFormCategories = class(TForm)
     13  TFormCategories = class(TFormEx)
    1614    AAdd: TAction;
    1715    AEnable: TAction;
     
    4139    procedure ARemoveExecute(Sender: TObject);
    4240    procedure ASelectAllExecute(Sender: TObject);
    43     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4441    procedure FormCreate(Sender: TObject);
    4542    procedure FormShow(Sender: TObject);
     
    5350    function ListViewSort1CompareItem(Item1, Item2: TObject): Integer;
    5451    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
    55   private
    56     { private declarations }
    5752  public
    5853    Categories: TAcronymCategories;
     
    6156  end;
    6257
    63 var
    64   FormCategories: TFormCategories;
    6558
    6659implementation
     
    6962
    7063uses
    71   UCore;
     64  Core;
    7265
    7366resourcestring
     
    8275procedure TFormCategories.FormShow(Sender: TObject);
    8376begin
    84   Core.PersistentForm1.Load(Self);
    8577  UpdateList;
    86   Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
     78  Core.Core.ScaleDPI1.ScaleControl(ToolBar1, Core.Core.ScaleDPI1.DesignDPI);
    8779end;
    8880
     
    9284  if Assigned(Item) and (Change = ctState) then begin
    9385    TAcronymCategory(Item.Data).Enabled := Item.Checked;
    94     Core.AcronymDb.Modified := True;
     86    Core.Core.AcronymDb.Modified := True;
    9587  end;
    9688end;
     
    10294  S := InputBox(SCategory, SCategoryQuery, '');
    10395  if S <> '' then begin
    104     if not Assigned(Core.AcronymDb.Categories.SearchByName(S)) then begin;
    105       TAcronymCategory(Core.AcronymDb.Categories[Core.AcronymDb.Categories.Add(TAcronymCategory.Create)]).Name := S;
    106       Core.AcronymDb.Modified := True;
    107       Core.AcronymDb.Update;
     96    if not Assigned(Core.Core.AcronymDb.Categories.SearchByName(S)) then begin;
     97      TAcronymCategory(Core.Core.AcronymDb.Categories[Core.Core.AcronymDb.Categories.Add(TAcronymCategory.Create)]).Name := S;
     98      Core.Core.AcronymDb.Modified := True;
     99      Core.Core.AcronymDb.Update;
    108100      UpdateList;
    109101    end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
     
    118110  if ListViewCategories.Items[I].Selected then begin
    119111    TAcronymCategory(ListViewCategories.Items[I].Data).Enabled := False;
    120     Core.AcronymDb.Modified := True;
     112    Core.Core.AcronymDb.Modified := True;
    121113  end;
    122114  UpdateList;
     
    130122  if ListViewCategories.Items[I].Selected then begin
    131123    TAcronymCategory(ListViewCategories.Items[I].Data).Enabled := True;
    132     Core.AcronymDb.Modified := True;
     124    Core.Core.AcronymDb.Modified := True;
    133125  end;
    134126  UpdateList;
     
    142134    S := InputBox(SCategory, SCategoryQuery, ListViewCategories.Selected.Caption);
    143135    if S <> ListViewCategories.Selected.Caption then begin
    144       if not Assigned(Core.AcronymDb.Categories.SearchByName(S)) then begin;
     136      if not Assigned(Core.Core.AcronymDb.Categories.SearchByName(S)) then begin;
    145137        TAcronymCategory(ListViewCategories.Selected.Data).Name := S;
    146         Core.AcronymDb.Modified := True;
    147         Core.AcronymDb.Update;
     138        Core.Core.AcronymDb.Modified := True;
     139        Core.Core.AcronymDb.Update;
    148140        UpdateList;
    149141      end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
     
    177169end;
    178170
    179 procedure TFormCategories.FormClose(Sender: TObject;
    180   var CloseAction: TCloseAction);
    181 begin
    182   Core.PersistentForm1.Save(Self);
    183 end;
    184 
    185171procedure TFormCategories.FormCreate(Sender: TObject);
    186172var
    187173  I: Integer;
    188174begin
    189   Core.Translator.TranslateComponentRecursive(Self);
    190   Core.ThemeManager.UseTheme(Self);
    191175  for I := 0 to ToolBar1.ButtonCount - 1 do
    192176    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
     
    237221procedure TFormCategories.ListViewSort1Filter(ListViewSort: TListViewSort);
    238222begin
    239   Core.AcronymDb.Categories.AssignToList(ListViewSort1.List);
     223  Core.Core.AcronymDb.Categories.AssignToList(ListViewSort1.List);
    240224end;
    241225
     
    243227begin
    244228  ListViewSort1.Refresh;
    245   ListViewCategories.Items.Count := Core.AcronymDb.Categories.Count;
     229  ListViewCategories.Items.Count := Core.Core.AcronymDb.Categories.Count;
    246230  ListViewCategories.Refresh;
    247231  UpdateInterface;
Note: See TracChangeset for help on using the changeset viewer.