Ignore:
Timestamp:
Jul 13, 2016, 2:51:53 PM (8 years ago)
Author:
chronos
Message:
  • Added: Now import sources have categories which are merged to new imported acronym meanings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormImportSource.pas

    r29 r33  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   UAcronym;
     9  ActnList, Menus, ExtCtrls, UAcronym;
    1010
    1111type
     
    1414
    1515  TFormImportSource = class(TForm)
     16    ACategoryAdd: TAction;
     17    ACategoryRemove: TAction;
     18    ActionList1: TActionList;
     19    Bevel1: TBevel;
     20    Button1: TButton;
     21    Button2: TButton;
    1622    ButtonShowFormat: TButton;
    1723    ButtonOk: TButton;
     
    2430    Label2: TLabel;
    2531    Label3: TLabel;
     32    Label4: TLabel;
     33    ListBox1: TListBox;
     34    MenuItem1: TMenuItem;
     35    MenuItem2: TMenuItem;
     36    PopupMenuCategory: TPopupMenu;
     37    procedure ACategoryAddExecute(Sender: TObject);
     38    procedure ACategoryRemoveExecute(Sender: TObject);
    2639    procedure ButtonShowFormatClick(Sender: TObject);
     40    procedure FormShow(Sender: TObject);
    2741  private
    2842    { private declarations }
    2943  public
     44    procedure UpdateInterface;
    3045    procedure Load(ImportSource: TImportSource);
    3146    procedure Save(ImportSource: TImportSource);
     
    4055
    4156uses
    42   UFormMain, UFormImportFormat;
     57  UFormMain, UFormImportFormat, UFormCategorySelect;
    4358
    4459{ TFormImportSource }
     
    6277end;
    6378
     79procedure TFormImportSource.FormShow(Sender: TObject);
     80begin
     81  UpdateInterface;
     82end;
     83
     84procedure TFormImportSource.UpdateInterface;
     85begin
     86  ACategoryRemove.Enabled := ListBox1.ItemIndex <> -1;
     87end;
     88
     89procedure TFormImportSource.ACategoryAddExecute(Sender: TObject);
     90var
     91  I: Integer;
     92begin
     93  FormCategorySelect.Load(ListBox1.Items);
     94  if FormCategorySelect.ShowModal = mrOk then begin
     95    for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
     96      if FormCategorySelect.ListBox1.Selected[I] then begin
     97        ListBox1.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
     98      end;
     99  end;
     100end;
     101
     102procedure TFormImportSource.ACategoryRemoveExecute(Sender: TObject);
     103var
     104  I: Integer;
     105begin
     106  if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
     107  TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
     108    for I := ListBox1.Items.Count - 1 downto 0 do
     109    if ListBox1.Selected[I] then
     110      ListBox1.Items.Delete(I);
     111    UpdateInterface;
     112  end;
     113end;
     114
    64115procedure TFormImportSource.Load(ImportSource: TImportSource);
    65116var
     
    80131    ComboBox1.ItemIndex := 0;
    81132  CheckBoxEnabled.Checked := ImportSource.Enabled;
     133  ImportSource.Categories.AssignToStrings(ListBox1.Items);
    82134end;
    83135
     
    88140  ImportSource.Format := TImportFormat(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
    89141  ImportSource.Enabled := CheckBoxEnabled.Checked;
     142  ImportSource.Categories.AssignFromStrings(ListBox1.Items);
    90143end;
    91144
Note: See TracChangeset for help on using the changeset viewer.