Changeset 148 for trunk


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.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormAcronyms.pas

    r146 r148  
    156156          TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.Add(Meaning);
    157157
     158      Core.AcronymDb.Update;
    158159      UpdateAcronymsList;
    159160      UpdateInterface;
     
    201202            if TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.IndexOf(Meaning) = -1 then
    202203              TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.Add(Meaning);
    203 
     204          Core.AcronymDb.Update;
    204205          UpdateAcronymsList;
    205206          UpdateInterface;
     
    221222    if MessageDlg(SRemoveAcronym, SRemoveAcronymQuery,
    222223    TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
     224      Core.AcronymDb.BeginUpdate;
    223225      for I := ListViewAcronyms.Items.Count - 1 downto 0 do
    224226        if ListViewAcronyms.Items[I].Selected then begin
     
    228230      UpdateAcronymsList;
    229231      UpdateInterface;
     232      Core.AcronymDb.EndUpdate;
    230233    end;
    231234  end;
  • trunk/Forms/UFormCategories.pas

    r145 r148  
    105105      TAcronymCategory(Core.AcronymDb.Categories[Core.AcronymDb.Categories.Add(TAcronymCategory.Create)]).Name := S;
    106106      Core.AcronymDb.Modified := True;
     107      Core.AcronymDb.Update;
    107108      UpdateList;
    108109    end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
     
    144145        TAcronymCategory(ListViewCategories.Selected.Data).Name := S;
    145146        Core.AcronymDb.Modified := True;
     147        Core.AcronymDb.Update;
    146148        UpdateList;
    147149      end else ShowMessage(Format(SCategoryAlreadyExists, [S]));
     
    157159    if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
    158160    TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
     161      Categories.Db.BeginUpdate;
    159162      for I := ListViewCategories.Items.Count - 1 downto 0 do
    160163      if ListViewCategories.Items[I].Selected then
    161164        Categories.Remove(ListViewCategories.Items[I].Data);
     165      Categories.Db.EndUpdate;
    162166      UpdateList;
    163167    end;
  • trunk/Forms/UFormMain.pas

    r147 r148  
    134134    ProjectClosed: Boolean;
    135135    ImportTotalItemCount: Integer;
     136    procedure AcronymDbUpdate(Sender: TObject);
    136137    function FilterCell(Text1, Text2: string): Boolean;
    137138    procedure ProcessImportsJob(Job: TJob);
     
    258259begin
    259260  AFileClose.Execute;
    260   if ProjectClosed  then begin
     261  if not Assigned(Core.AcronymDb)  then begin
    261262    Core.AcronymDb := TAcronymDb.Create;
    262263    Core.AcronymDb.FileName := DefaultFileName;
    263264    Core.AcronymDb.Acronyms.Clear;
     265    Core.AcronymDb.OnUpdate.Add(AcronymDbUpdate);
    264266    UpdateAcronymsList;
    265267    UpdateInterface;
     
    533535end;
    534536
     537procedure TFormMain.AcronymDbUpdate(Sender: TObject);
     538begin
     539  UpdateAcronymsList;
     540end;
     541
    535542function TFormMain.FilterCell(Text1, Text2: string): Boolean;
    536543begin
     
    547554begin
    548555  AFileClose.Execute;
    549   if ProjectClosed then begin
     556  if not Assigned(Core.AcronymDb) then begin
    550557    try
    551558      AFileNew.Execute;
     
    604611begin
    605612  AFileClose.Execute;
    606   if ProjectClosed then begin
     613  if not Assigned(Core.AcronymDb) then begin
    607614    AFileNew.Execute;
    608615    Core.AcronymDb.LoadFromFile(TMenuItem(Sender).Caption);
  • trunk/Languages/AcronymDecoder.cs.po

    r146 r148  
    919919msgid "Process import sources"
    920920msgstr "Zpracovat zdroje importu"
     921
  • 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
  • trunk/UCore.pas

    r142 r148  
    7373procedure TCore.DataModuleCreate(Sender: TObject);
    7474begin
    75   AcronymDb := TAcronymDb.Create;
     75  AcronymDb := nil;
    7676  InitializeStarted := False;
    7777  InitializeFinished := False;
     
    129129    if FileNameOption <> '' then begin
    130130      // Open file specified as command line parameter
    131       AcronymDB.LoadFromFile(FileNameOption);
    132       FormMain.LastOpenedList1.AddItem(FileNameOption);
     131      FormMain.ProjectOpen(FileNameOption);
    133132    end else
    134133    if (FormMain.LastOpenedList1.Items.Count > 0) and FileExists(FormMain.LastOpenedList1.Items[0]) then begin
    135134      // Open last opened file
    136       AcronymDB.LoadFromFile(FormMain.LastOpenedList1.Items[0])
     135      FormMain.ProjectOpen(FormMain.LastOpenedList1.Items[0])
    137136    end else begin
    138137      // Open default database with examples if no item is in recent openned history
Note: See TracChangeset for help on using the changeset viewer.