Changeset 20 for trunk/Forms


Ignore:
Timestamp:
May 4, 2016, 6:50:29 PM (9 years ago)
Author:
chronos
Message:
Location:
trunk/Forms
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCategories.lfm

    r19 r20  
    1010  LCLVersion = '1.6.0.4'
    1111  object ListViewCategories: TListView
    12     Left = 16
     12    Left = 9
    1313    Height = 432
    1414    Top = 8
    15     Width = 760
     15    Width = 767
    1616    Anchors = [akTop, akLeft, akRight, akBottom]
    1717    Columns = <   
  • trunk/Forms/UFormCategories.pas

    r14 r20  
    3636    { private declarations }
    3737  public
     38    Categories: TAcronymCategories;
    3839    procedure UpdateList;
    3940    procedure UpdateInterface;
     
    5354  SCategory = 'Category';
    5455  SCategoryQuery = 'Enter name of category';
    55   SRemoveCategory = 'Remove category';
    56   SRemoveCategoryQuery = 'Do you really want to remove category?';
     56  SRemoveCategory = 'Remove categories';
     57  SRemoveCategoryQuery = 'Do you really want to remove selected categories?';
    5758  SCategoryAlreadyExists = 'Category %s already exists!';
    5859
     
    9596
    9697procedure TFormCategories.ARemoveExecute(Sender: TObject);
     98var
     99  I: Integer;
    97100begin
    98101  if Assigned(ListViewCategories.Selected) then begin
    99102    if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
    100103    TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
    101       FormMain.AcronymDb.Categories.Remove(ListViewCategories.Selected.Data);
     104      for I := ListViewCategories.Items.Count - 1 downto 0 do
     105      if ListViewCategories.Items[I].Selected then
     106        Categories.Remove(ListViewCategories.Items[I].Data);
    102107      UpdateList;
    103108    end;
  • trunk/Forms/UFormMain.lfm

    r19 r20  
    11object FormMain: TFormMain
    2   Left = 393
     2  Left = 427
    33  Height = 446
    4   Top = 405
     4  Top = 423
    55  Width = 631
    66  Caption = 'Acronym Decoder'
     
    44164416      OnExecute = AShowAcronymsExecute
    44174417    end
     4418    object AShowImportSources: TAction
     4419      Caption = 'Import sources'
     4420      OnExecute = AShowImportSourcesExecute
     4421    end
    44184422  end
    44194423  object PersistentForm1: TPersistentForm
     
    44624466        Action = AShowCategories
    44634467      end
     4468      object MenuItem4: TMenuItem
     4469        Action = AShowImportSources
     4470      end
    44644471    end
    44654472    object MenuItem16: TMenuItem
  • trunk/Forms/UFormMain.lrt

    r19 r20  
    1515TFORMMAIN.ASHOWCATEGORIES.CAPTION=Categories
    1616TFORMMAIN.ASHOWACRONYMS.CAPTION=Acronyms
     17TFORMMAIN.ASHOWIMPORTSOURCES.CAPTION=Import sources
    1718TFORMMAIN.MENUITEM8.CAPTION=File
    1819TFORMMAIN.MENUITEMOPENRECENT.CAPTION=Open recent
  • trunk/Forms/UFormMain.pas

    r19 r20  
    1616
    1717  TFormMain = class(TForm)
     18    AShowImportSources: TAction;
    1819    AShowAcronyms: TAction;
    1920    AShowCategories: TAction;
     
    5051    MenuItem21: TMenuItem;
    5152    MenuItem22: TMenuItem;
     53    MenuItem4: TMenuItem;
    5254    MenuItemOpenRecent: TMenuItem;
    5355    MenuItem2: TMenuItem;
     
    7173    procedure AShowCategoriesExecute(Sender: TObject);
    7274    procedure AShowExecute(Sender: TObject);
     75    procedure AShowImportSourcesExecute(Sender: TObject);
    7376    procedure CheckBoxExactMathChange(Sender: TObject);
    7477    procedure EditSearchChange(Sender: TObject);
     
    111114
    112115uses
    113   UFormImport, UFormAcronym, UFormSettings, UFormCategories, UFormAcronyms;
     116  UFormImport, UFormAcronym, UFormSettings, UFormCategories, UFormAcronyms,
     117  UFormImportSource, UFormImportSources;
    114118
    115119resourcestring
     
    155159var
    156160  ModalResult: TModalResult;
    157 begin
    158   if Assigned(AcronymDb) and AcronymDb.Modified then begin
    159     ModalResult := MessageDlg(SAppExit, SAppExitQuery,
    160       mtConfirmation, [mbYes, mbNo, mbCancel], 0);
    161     if ModalResult = mrYes then begin
    162       AFileSave.Execute;
    163       FreeAndNil(AcronymDb);
    164       UpdateAcronymsList;
    165       UpdateInterface;
    166       ProjectClosed := True;
    167     end
    168     else if ModalResult = mrNo then begin
    169       FreeAndNil(AcronymDb);
    170       UpdateAcronymsList;
    171       UpdateInterface;
    172       ProjectClosed := True;
    173     end else ProjectClosed := False;
    174   end else ProjectClosed := True;
     161  DoClose: Boolean;
     162begin
     163  DoClose := False;
     164  if Assigned(AcronymDb) then begin
     165    if AcronymDb.Modified then begin
     166       ModalResult := MessageDlg(SAppExit, SAppExitQuery,
     167       mtConfirmation, [mbYes, mbNo, mbCancel], 0);
     168      if ModalResult = mrYes then begin
     169        AFileSave.Execute;
     170        DoClose := True;
     171      end
     172      else if ModalResult = mrNo then begin
     173        DoClose := True;
     174      end else ProjectClosed := False;
     175    end else DoClose := True;
     176  end;
     177  if DoClose then begin
     178    FreeAndNil(AcronymDb);
     179    UpdateAcronymsList;
     180    UpdateInterface;
     181    ProjectClosed := True;
     182  end;
    175183end;
    176184
     
    245253procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
    246254begin
     255  FormCategories.Categories := AcronymDb.Categories;
    247256  FormCategories.ShowModal;
    248257  UpdateAcronymsList;
     
    253262begin
    254263  Show;
     264end;
     265
     266procedure TFormMain.AShowImportSourcesExecute(Sender: TObject);
     267begin
     268  FormImportSources.ImportSources := AcronymDb.ImportSources;
     269  FormImportSources.ShowModal;
     270  UpdateInterface;
    255271end;
    256272
     
    418434  AImport.Enabled := Assigned(AcronymDb);
    419435  AShowCategories.Enabled := Assigned(AcronymDb);
     436  AShowAcronyms.Enabled := Assigned(AcronymDb);
     437  AShowImportSources.Enabled := Assigned(AcronymDb);
    420438
    421439  Title := Application.Title;
Note: See TracChangeset for help on using the changeset viewer.