Changeset 148 for trunk/UAcronym.pas


Ignore:
Timestamp:
Feb 6, 2017, 12:59:59 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Update filtered acronyms in main window if they were changed in acronyms and categories window.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UAcronym.pas

    r145 r148  
    77uses
    88  Classes, SysUtils, Contnrs, XMLRead, XMLWrite, DOM, UXMLUtils,
    9   SpecializedList, fphttpclient2, Dialogs, odbcconn, sqldb, LazUTF8;
     9  SpecializedList, fphttpclient2, Dialogs, odbcconn, sqldb, LazUTF8,
     10  fgl;
    1011
    1112type
     
    216217
    217218  TAcronymDb = class
     219  private
     220    FUpdateCount: Integer;
     221  public
    218222    FileName: string;
    219223    Acronyms: TAcronyms;
     
    223227    Modified: Boolean;
    224228    AddedCount: Integer;
     229    OnUpdate: TFPGList<TNotifyEvent>;
    225230    constructor Create;
    226231    destructor Destroy; override;
     
    234239    procedure RemoveAcronym(AcronymName, MeaningName: string);
    235240    procedure AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False);
     241    procedure BeginUpdate;
     242    procedure EndUpdate;
     243    procedure Update;
    236244  end;
    237245
     
    14361444  ImportSources.AcronymDb := Self;
    14371445  ImportFormats := TImportFormats.Create;
     1446  FUpdateCount := 0;
     1447  OnUpdate := TFPGList<TNotifyEvent>.Create;
    14381448end;
    14391449
    14401450destructor TAcronymDb.Destroy;
    14411451begin
     1452  FreeAndNil(OnUpdate);
    14421453  FreeAndNil(ImportFormats);
    14431454  FreeAndNil(ImportSources);
     
    17011712end;
    17021713
     1714procedure TAcronymDb.BeginUpdate;
     1715begin
     1716  Inc(FUpdateCount);
     1717end;
     1718
     1719procedure TAcronymDb.EndUpdate;
     1720begin
     1721  if FUpdateCount > 0 then Dec(FUpdateCount);
     1722  if FupdateCount = 0 then Update;
     1723end;
     1724
     1725procedure TAcronymDb.Update;
     1726var
     1727  I: Integer;
     1728begin
     1729  for I := 0 to OnUpdate.Count - 1 do
     1730    OnUpdate[I](Self);
     1731end;
     1732
    17031733end.
    17041734
Note: See TracChangeset for help on using the changeset viewer.